Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
let startY = 0; const threshold = 80; $(window).on("touchstart", e => { startY = e.originalEvent.touches[0].clientY; }); $(window).on("touchmove", function(e) { if (window.scrollY === 0) { const dy = e.originalEvent.touches[0].clientY - startY; if (dy > 0) { e.preventDefault(); const pct = Math.min(dy / threshold, 1); $("#pull-indicator").css("opacity", pct).text(pct >= 1 ? "Release to refresh" : "Pull to refresh"); } } }); $(window).on("touchend", function(e) { const dy = e.originalEvent.changedTouches[0].clientY - startY; if (window.scrollY === 0 && dy >= threshold) reloadContent(); $("#pull-indicator").css("opacity", 0); });
Result
Open