mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-20 16:12:50 +00:00
fixed reader updates
This commit is contained in:
parent
2cc03e251c
commit
b9eb5f2700
1 changed files with 19 additions and 3 deletions
|
|
@ -1255,9 +1255,25 @@ struct HTMLView: UIViewRepresentable {
|
|||
}
|
||||
|
||||
let script = """
|
||||
document.addEventListener('scroll', function() {
|
||||
window.webkit.messageHandlers.scrollHandler.postMessage('scroll');
|
||||
}, { passive: true });
|
||||
(function() {
|
||||
let lastUpdate = 0;
|
||||
const throttleInterval = 16;
|
||||
|
||||
function updateProgress() {
|
||||
const now = Date.now();
|
||||
if (now - lastUpdate >= throttleInterval) {
|
||||
window.webkit.messageHandlers.scrollHandler.postMessage('scroll');
|
||||
lastUpdate = now;
|
||||
}
|
||||
requestAnimationFrame(updateProgress);
|
||||
}
|
||||
|
||||
requestAnimationFrame(updateProgress);
|
||||
|
||||
document.addEventListener('scroll', function() {
|
||||
requestAnimationFrame(updateProgress);
|
||||
}, { passive: true });
|
||||
})();
|
||||
"""
|
||||
|
||||
let userScript = WKUserScript(source: script, injectionTime: .atDocumentEnd, forMainFrameOnly: true)
|
||||
|
|
|
|||
Loading…
Reference in a new issue