Gadget:oouiup.js:修订间差异

删除224字节 、​ 2023年7月23日 (星期日)
// Edit via Wikiplus
(// Edit via Wikiplus)
(// Edit via Wikiplus)
$( function () {
var const body = document.body,
html = document.documentElement;
var const innerWidth = window.innerWidth;
var let scrollbarWidth;
switch (" 'scroll"' ) {
case getComputedStyle( body ).overflowY:
scrollbarWidth = innerWidth - body.clientWidth;
break;
case getComputedStyle( html ).overflowY:
scrollbarWidth = innerWidth - html.clientWidth;
break;
default:
var const backup = body.style.overflowY;
body.style.overflowY = "'scroll"';
scrollbarWidth = innerWidth - body.clientWidth;
body.style.overflowY = backup;
}
var const btnObj = new OO.ui.ButtonWidget( {
icon: 'collapse',
label: "'ABC"',
title: "'TIT"',
invisibleLabel: true,
classes: [ 'backToTop' ]
} );
btnObj.on(" 'click"', function () {
$(" 'html, body"' ).animate( {
scrollTop: 0
}, 120 );
}
}
);
var const $btn = btnObj.$element;
$btn.appendTo( 'body' );
if ( scrollbarWidth === 0 ) {
$btn.css( 'right', '20px' );
btn.css("right", "20px"); // 修复新版 Chrome 的自动隐藏式滚动条导致的按钮被覆盖 chrome://flags/#overlay-scrollbars
}
$( window).on("scroll",onscroll = function () {
if ( $(document).scrollingElement.scrollTop() > 0 ? btn.fadeIn() : btn.fadeOut();{
}) $btn.scrollfadeIn();
} else {
});
$btn.fadeOut();
}
};
} );
维护员、​界面管理员、​巡查员、​监督员、​小部件编辑者
3,462

个编辑