Gadget:oouiup.js:修订间差异

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

个编辑