MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 5: Line 5:
var topButton = document.createElement('div');
var topButton = document.createElement('div');
topButton.id = 'top-button';
topButton.id = 'top-button';
document.body.appendChild(topButton);
window.addEventListener('scroll', function (e) {
    if (window.scrollY > 300) {
        topButton.classList.add('active');
    } else {
        topButton.classList.remove('active');
    }
});
topButton.addEventListener('click', function (e) {
    try {
        window.scrollTo({
            top: 0,
            left: 0,
            behavior: 'smooth',
        });
    } catch (e) {
        window.scrollTo(0, 0);
    }
});


/* 대문 섹션 토글 */
/* 대문 섹션 토글 */