Skip to content

Commit

Permalink
fix(refresher): skip refresh outside the header
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaraa committed Jun 5, 2024
1 parent d348eba commit 5dc7cf2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/static/js/refresher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

const mainContentsEl = document.getElementById("main-contents");
const headerEl = document.getElementById("dank-header");
let _startY = 0;

async function simulateRefreshAction() {
Expand Down Expand Up @@ -51,11 +51,14 @@ document.body.addEventListener(
const y = e.touches[0].pageY;
if (
document.scrollingElement.scrollTop === 0 &&
y > _startY + 150 &&
y <=
headerEl.getBoundingClientRect().y +
headerEl.getBoundingClientRect().height &&
y > _startY + 75 &&
!document.body.classList.contains("refreshing")
) {
await simulateRefreshAction();
await updateMainContent(window.location.pathname);
await Router.updateMainContent(window.location.pathname);
}
},
{ passive: true },
Expand Down

0 comments on commit 5dc7cf2

Please sign in to comment.