「MediaWiki:Mobile.js」の版間の差分
提供:パルワールド 攻略Wiki
編集の要約なし タグ: 差し戻し済み モバイル編集 モバイルウェブ編集 |
編集の要約なし タグ: 差し戻し済み モバイル編集 モバイルウェブ編集 |
||
27行目: | 27行目: | ||
}); | }); | ||
//Menu | //Menu | ||
/*メニューバー*/ | /*メニューバー*/ | ||
55行目: | 36行目: | ||
// スクロールイベントリスナー | // スクロールイベントリスナー | ||
window.addEventListener('scroll', function() { | window.addEventListener('scroll', function() { | ||
// ページの最上部からのスクロール距離を取得 | // モバイルデバイスでの表示をチェック(例:幅が768px以下) | ||
if (window.innerWidth <= 768) { | |||
// ページの最上部からのスクロール距離を取得 | |||
var scrollDistance = window.scrollY; | |||
if (scrollDistance > 100) { | |||
// 100px以上スクロールした場合、mobileMenuBarを表示 | |||
mobileMenuBar.style.display = ' | mobileMenuBar.style.display = 'block'; | ||
} else { | |||
// 100px未満に戻った場合、mobileMenuBarを非表示 | |||
mobileMenuBar.style.display = 'none'; | |||
} | |||
} else { | } else { | ||
// | // モバイルデバイスでない場合、常に非表示 | ||
mobileMenuBar.style.display = 'none'; | |||
} | |||
}); | |||
// ウィンドウのサイズ変更時にもチェック | |||
window.addEventListener('resize', function() { | |||
if (window.innerWidth > 768) { | |||
mobileMenuBar.style.display = 'none'; | mobileMenuBar.style.display = 'none'; | ||
} | } | ||
}); | }); | ||
}); | }); |
2024年1月15日 (月) 23:20時点における版
//トップに戻るボタン
$(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();
});
//Menu
/*メニューバー*/
document.addEventListener("DOMContentLoaded", function() {
// 初期状態ではmobileMenuBarを非表示に設定
var mobileMenuBar = document.getElementById('mobileMenuBar');
mobileMenuBar.style.display = 'none';
// スクロールイベントリスナー
window.addEventListener('scroll', function() {
// モバイルデバイスでの表示をチェック(例:幅が768px以下)
if (window.innerWidth <= 768) {
// ページの最上部からのスクロール距離を取得
var scrollDistance = window.scrollY;
if (scrollDistance > 100) {
// 100px以上スクロールした場合、mobileMenuBarを表示
mobileMenuBar.style.display = 'block';
} else {
// 100px未満に戻った場合、mobileMenuBarを非表示
mobileMenuBar.style.display = 'none';
}
} else {
// モバイルデバイスでない場合、常に非表示
mobileMenuBar.style.display = 'none';
}
});
// ウィンドウのサイズ変更時にもチェック
window.addEventListener('resize', function() {
if (window.innerWidth > 768) {
mobileMenuBar.style.display = 'none';
}
});
});