File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -255,7 +255,12 @@ export class BookreaderUrlPlugin extends BookReader {
255255 if ( location . includes ( "text=" ) ) {
256256 this . on ( 'textLayerVisible' , async ( _ , { pageContainerEl} ) => {
257257 const visiblePageNum = pageContainerEl . getAttribute ( 'data-page-num' ) ;
258- await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
258+ let renderPageDelay = 100 ;
259+ if ( this . mode === 1 ) {
260+ // maybe add some more time to have the page "settle down" from user scrolling
261+ renderPageDelay = 900 ;
262+ }
263+ await new Promise ( resolve => setTimeout ( resolve , renderPageDelay ) ) ;
259264 // No textFragment found or the textFragment stored doesn't match current visible page loaded
260265 if ( ! this . textFragment || this . textFragmentPage !== visiblePageNum ) return ;
261266 if ( this . options . urlMode === 'history' ) {
Original file line number Diff line number Diff line change @@ -453,6 +453,8 @@ class BRSelectMenu extends LitElement {
453453 const currentSelection = window . getSelection ( ) ;
454454 /** @type {HTMLElement } */
455455 const textLayer = currentSelection . anchorNode . parentElement . closest ( '.BRtextLayer' ) ;
456+ // To do - updateResumeValue + getCookiePath in plugin.resume.js overrides the adjustedUrlPageNumPath, check how to workaround this
457+ const adjustedUrlPageNumPath = currentUrl . pathname . toString ( ) . replace ( / (?< = \/ p a g e \/ ) \d + (? = \/ ) / , textLayer . parentElement . getAttribute ( 'data-page-num' ) ) ;
456458 if ( currentParams . includes ( 'text=' ) ) {
457459 currentParams = currentParams . replace ( / ( t e x t = ) [ \w \W \d % ] + / , createTextFragmentUrlParam ( currentSelection , textLayer ) ) ;
458460 } else {
@@ -463,9 +465,9 @@ class BRSelectMenu extends LitElement {
463465 }
464466 }
465467 if ( this . br . options . urlMode === 'history' ) {
466- navigator . clipboard . writeText ( `${ currentUrl . origin } ${ currentUrl . pathname } ${ currentParams } ` ) ;
468+ navigator . clipboard . writeText ( `${ currentUrl . origin } ${ adjustedUrlPageNumPath } ${ currentParams } ` ) ;
467469 } else {
468- navigator . clipboard . writeText ( `${ currentUrl . origin } ${ currentUrl . pathname } ${ currentParams } ${ currentUrl ?. hash } ` ) ;
470+ navigator . clipboard . writeText ( `${ currentUrl . origin } ${ adjustedUrlPageNumPath } ${ currentParams } ${ currentUrl ?. hash } ` ) ;
469471 }
470472 }
471473
You can’t perform that action at this time.
0 commit comments