mediawiki-skins-MinervaNeue/resources/skins.minerva.backtotop/init.js
jdlrobson 038103299a Minerva owns BacktoTopOverlay
Not used in MobileFrontend so it is moved here from that repo.
t r
Change-Id: I97e6010026daf4c6610bcfbedf140fb2a45b1130
2017-10-26 16:34:16 -04:00

22 lines
559 B
JavaScript

( function ( M, $ ) {
var BackToTopOverlay = M.require( 'skins.minerva.backtotop/BackToTopOverlay' ),
backtotop = new BackToTopOverlay(),
browser = M.require( 'mobile.startup/Browser' ).getSingleton();
// check if browser user agent is iOS (T141598)
if ( browser.isIos() ) {
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, jQuery ) );