「MediaWiki:Mobile.js」の版間の差分
提供:パルワールド 攻略Wiki
編集の要約なし タグ: モバイル編集 モバイルウェブ編集 |
編集の要約なし タグ: モバイル編集 モバイルウェブ編集 |
||
1行目: | 1行目: | ||
/ | //トップに戻るボタン | ||
$(document).ready(function() { | $(document).ready(function() { | ||
var backToTopButton = $('<div/>', { | var backToTopButton = $('<div/>', { | ||
id: 'back-to-top', | id: 'back-to-top', | ||
111行目: | 9行目: | ||
}).appendTo('body'); | }).appendTo('body'); | ||
backToTopButton.show(); | backToTopButton.show(); | ||
var inactivityTimer; | var inactivityTimer; | ||
function resetInactivityTimer() { | function resetInactivityTimer() { | ||
backToTopButton.show(); | backToTopButton.show(); | ||
clearTimeout(inactivityTimer); | clearTimeout(inactivityTimer); | ||
inactivityTimer = setTimeout(function() { | inactivityTimer = setTimeout(function() { | ||
backToTopButton.fadeOut(); | backToTopButton.fadeOut(); | ||
}, 2000); | }, 2000); | ||
} | } | ||
$(window).scroll(resetInactivityTimer); | $(window).scroll(resetInactivityTimer); | ||
$(window).mousemove(resetInactivityTimer); | $(window).mousemove(resetInactivityTimer); | ||
resetInactivityTimer(); | resetInactivityTimer(); | ||
}); | }); |
2024年1月15日 (月) 21:24時点における版
//トップに戻るボタン
$(document).ready(function() {
var backToTopButton = $('<div/>', {
id: 'back-to-top',
html: '<i class="fa-solid fa-chevron-up"></i>',
click: function() {
window.scrollTo(0, 0);
}
}).appendTo('body');
backToTopButton.show();
var inactivityTimer;
function resetInactivityTimer() {
backToTopButton.show();
clearTimeout(inactivityTimer);
inactivityTimer = setTimeout(function() {
backToTopButton.fadeOut();
}, 2000);
}
$(window).scroll(resetInactivityTimer);
$(window).mousemove(resetInactivityTimer);
resetInactivityTimer();
});