@@ -174,36 +174,31 @@ BookReader.prototype.setup = function(options) {
174174 /** @deprecated */
175175 this . bookPath = options . bookPath ;
176176 this . fader = utils . debounce (
177- ( source ) => {
178- console . log ( 'Fading UI' ) ;
179- $ ( document . body )
180- . addClass ( 'faded' )
181- . toggleClass ( 'faded--scroll' , source === 'scroll' ) ;
182- // const animation = this.$('.BRfooter')[0].getAnimations()[0];
183- // if (!animation) return;
184- // if (source === 'scroll') animation.pause();
185- // animation.currentTime = 0;
186- } ,
177+ ( source ) => this . fader . hide ( source ) ,
187178 2000 ,
188- ( source ) => {
189- console . log ( 'Show UI' ) ;
190- $ ( document . body )
191- . removeClass ( 'faded' )
192- . toggleClass ( 'faded--scroll' , source === 'scroll' ) ;
193- } ,
179+ ( source ) => this . fader . show ( source ) ,
194180 {
195181 tap : ( source ) => {
196182 console . log ( 'Show UI ...' , source ) ;
197- // if (source === 'scroll') {
198- // const animation = this.$('.BRfooter')[0].getAnimations()[0];
199- // if (animation) {
200- // // const max = animation.effect.getComputedTiming().duration;
201- // animation.currentTime += 1;
202- // }
203- // }
204183 } ,
205184 } ,
206185 ) ;
186+ this . fader . show = ( source ) => {
187+ console . log ( 'Show UI' ) ;
188+ $ ( document . body ) . removeClass ( 'BRfaded' ) ;
189+ } ;
190+ this . fader . hide = ( source ) => {
191+ console . log ( 'Hide UI' ) ;
192+ $ ( document . body ) . addClass ( 'BRfaded' ) ;
193+ } ;
194+ this . fader . toggle = ( source ) => {
195+ if ( $ ( document . body ) . hasClass ( 'BRfaded' ) ) {
196+ this . fader . show ( source ) ;
197+ this . fader ( source ) ;
198+ } else {
199+ this . fader . hide ( source ) ;
200+ }
201+ } ;
207202
208203 // Construct the usual plugins first to get type hints
209204 this . plugins = {
@@ -773,8 +768,16 @@ BookReader.prototype.init = function() {
773768 }
774769 }
775770
776- this . refs . $br . on ( 'mousemove' , ( ) => this . fader ( 'mousemove' ) ) ;
777- this . refs . $brContainer [ 0 ] . addEventListener ( 'scroll' , utils . eventFilterScrollUp ( ( ) => this . fader ( 'scroll' ) ) , { passive : true } ) ;
771+ // Init modes
772+ for ( const mode of Object . values ( this . _modes ) ) {
773+ mode . init ( ) ;
774+ }
775+
776+ if ( this . plugins . experiments ?. isExperimentEnabled ( 'hideable-chrome' ) ) {
777+ this . refs . $br . on ( 'pointermove' , utils . eventFilterMouseMove ( ev => ev . pointerType != 'touch' && this . fader ( 'pointermove' ) ) ) ;
778+ this . refs . $brContainer [ 0 ] . addEventListener ( 'scroll' , utils . eventFilterScrollUp ( ( ) => this . fader ( 'scroll' ) ) , { passive : true } ) ;
779+ this . refs . $brContainer [ 0 ] . addEventListener ( 'touchstart' , utils . eventFilterSameElement ( ( ) => this . fader ( 'touchstart' ) ) , { passive : true } ) ;
780+ }
778781
779782 this . init . initComplete = true ;
780783 this . trigger ( BookReader . eventNames . PostInit ) ;
@@ -1050,16 +1053,12 @@ BookReader.prototype.zoom = function(direction) {
10501053 * So resize isn't perceived sharp/jerky
10511054 */
10521055BookReader . prototype . resizeBRcontainer = function ( animate ) {
1056+ const top = this . getToolBarHeight ( ) ;
1057+ const bottom = this . plugins . experiments ?. isExperimentEnabled ( 'hideable-chrome' ) ? 0 : this . getFooterHeight ( ) ;
10531058 if ( animate ) {
1054- this . refs . $brContainer . animate ( {
1055- top : this . getToolBarHeight ( ) ,
1056- // bottom: this.getFooterHeight(),
1057- } , this . constResizeAnimationDuration , 'linear' ) ;
1059+ this . refs . $brContainer . animate ( { top, bottom } , this . constResizeAnimationDuration , 'linear' ) ;
10581060 } else {
1059- this . refs . $brContainer . css ( {
1060- top : this . getToolBarHeight ( ) ,
1061- // bottom: this.getFooterHeight(),
1062- } ) ;
1061+ this . refs . $brContainer . css ( { top, bottom } ) ;
10631062 }
10641063} ;
10651064
0 commit comments