...
This commit is contained in:
@@ -359,7 +359,10 @@ function toast(msg) {
|
||||
port.postMessage(JSON.stringify({type:"MSG",msg:msg}));
|
||||
}
|
||||
|
||||
var mainContentsEl = null
|
||||
var mainContentsEl = null;
|
||||
let lastState = null; // 이전 상태 저장 (-1, 0, 1)
|
||||
let throttleTimer = null;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const currentUrl = location.href;
|
||||
@@ -382,6 +385,40 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
// toast("connect port on " + location.href);
|
||||
time1 = setTimeout(autoScrollAndSave(false), 3500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
window.onscroll = function() {
|
||||
if (throttleTimer) return; // 이미 타이머가 동작 중이면 무시
|
||||
|
||||
throttleTimer = setTimeout(() => {
|
||||
const scrollY = window.scrollY;
|
||||
const innerHeight = window.innerHeight;
|
||||
const offsetHeight = document.body.offsetHeight;
|
||||
|
||||
let currentState;
|
||||
|
||||
if (scrollY <= 2) {
|
||||
currentState = -1; // 최상단
|
||||
} else if ((innerHeight + scrollY) >= offsetHeight - 10) {
|
||||
currentState = 1; // 최하단
|
||||
} else {
|
||||
currentState = 0; // 중간
|
||||
}
|
||||
|
||||
// 💡 상태가 바뀌었을 때만 앱으로 전송
|
||||
if (currentState !== lastState) {
|
||||
lastState = currentState;
|
||||
sendMessage({
|
||||
type: "SCROLL_STATE",
|
||||
value: currentState
|
||||
});
|
||||
}
|
||||
|
||||
throttleTimer = null;
|
||||
}, 150); // 0.15초 간격으로 체크 (사용성에 따라 조절 가능)
|
||||
};
|
||||
})
|
||||
|
||||
const keywords = ["youtube", "mojeek"];
|
||||
|
||||
Reference in New Issue
Block a user