mediawiki-skins-MinervaNeue/resources/skins.minerva.options/backtotop.js
Ed Sanders def03877ce Remove obsolete aliases from closures
Bug: T208951
Change-Id: I7cd5ab010596d964fc0896ed250f40d5b6344f6e
2018-11-16 15:16:25 +00:00

23 lines
624 B
JavaScript

( function ( M ) {
var BackToTopOverlay = M.require( 'skins.minerva.options/BackToTopOverlay' ),
backtotop = new BackToTopOverlay(),
features = mw.config.get( 'wgMinervaFeatures', {} ),
browser = M.require( 'mobile.startup/Browser' ).getSingleton();
// check if browser user agent is iOS (T141598)
if ( browser.isIos() || !features.backToTop ) {
return;
}
// initialize the back to top element
backtotop.appendTo( 'body' );
M.on( 'scroll', function () {
if ( $( window ).height() - $( window ).scrollTop() <= 0 ) {
backtotop.show();
} else {
backtotop.hide();
}
} );
}( mw.mobileFrontend ) );