@@ -141,7 +141,6 @@ export class TranslatePlugin extends BookReaderPlugin {
141141 }
142142
143143 const pageIndex = page . dataset . index ;
144-
145144 let pageTranslationLayer ;
146145 if ( ! page . querySelector ( '.BRPageLayer.BRtranslateLayer' ) ) {
147146 pageTranslationLayer = document . createElement ( 'div' ) ;
@@ -151,16 +150,17 @@ export class TranslatePlugin extends BookReaderPlugin {
151150 } else {
152151 pageTranslationLayer = page . querySelector ( '.BRPageLayer.BRtranslateLayer' ) ;
153152 }
154-
153+ /** @type { HTMLElement } textLayerElement */
155154 const textLayerElement = page . querySelector ( '.BRtextLayer' ) ;
156- textLayerElement . classList . add ( 'showingTranslation' ) ;
155+ // Should use native DOM element.style method instead of $().css method, specific issue with rendering / style calculation in Chrome
157156 $ ( pageTranslationLayer ) . css ( {
158- "width" : $ ( textLayerElement ) . css ( " width" ) ,
159- "height" : $ ( textLayerElement ) . css ( " height" ) ,
160- "transform" : $ ( textLayerElement ) . css ( " transform" ) ,
161- "pointer-events" : $ ( textLayerElement ) . css ( "pointer-events" ) ,
157+ "width" : textLayerElement . style . width ,
158+ "height" : textLayerElement . style . height ,
159+ "transform" : textLayerElement . style . transform ,
160+ "pointer-events" : textLayerElement . style . pointerEvents ,
162161 "z-index" : 3 ,
163162 } ) ;
163+ textLayerElement . classList . add ( 'showingTranslation' ) ;
164164 const paragraphs = this . getParagraphsOnPage ( page ) ;
165165
166166 const paragraphTranslationPromises = paragraphs . map ( async ( paragraph , pidx ) => {
@@ -252,17 +252,6 @@ export class TranslatePlugin extends BookReaderPlugin {
252252 * @param {Element } paragEl
253253 */
254254 fitVisiblePage ( paragEl ) {
255- // For some reason, Chrome does not detect the transform property for the translation + text layers
256- // Could not get it to fetch the transform value using $().css method
257- // Oddly enough the value is retrieved if using .style.transform instead?
258- const translateLayerEl = paragEl . parentElement ;
259- if ( $ ( translateLayerEl ) . css ( 'transform' ) == 'none' ) {
260- const pageNumber = paragEl . getAttribute ( 'data-translate-index' ) . split ( '-' ) [ 0 ] ;
261- /** @type {HTMLElement } selectionTransform */
262- const textLayerEl = document . querySelector ( `[data-index='${ pageNumber } '] .BRtextLayer` ) ;
263- $ ( translateLayerEl ) . css ( { 'transform' : textLayerEl . style . transform } ) ;
264- }
265-
266255 const originalFontSize = parseInt ( $ ( paragEl ) . css ( "font-size" ) ) ;
267256 let adjustedFontSize = originalFontSize ;
268257 while ( paragEl . clientHeight < paragEl . scrollHeight && adjustedFontSize > 0 ) {
0 commit comments