{
const touch = e.touches[0];
const container = $refs.feedContainer;
if (container.scrollTop <= 0) {
validPullStart = true
pullToRefresh.startY = touch.clientY;
pullToRefresh.currentY = touch.clientY;
} else {
validPullStart = false
}
}"
@touchmove="e => {
const container = $refs.feedContainer;
if (container.scrollTop > 0 || !validPullStart) {
return
}
const newY = e.touches[0].clientY;
const diff = newY - pullToRefresh.startY
if (newY > pullToRefresh.startY && diff > 100) {
pullToRefresh.pulling = true;
}
if (pullToRefresh.pulling) {
if (newY > pullToRefresh.currentY || newY > pullToRefresh.startY) {
pullToRefresh.currentY = newY;
e.preventDefault();
} else {
// Cancel pull-to-refresh if pulling upward
pullToRefresh.pulling = false;
}
}
}"
@touchend="e => {
const container = $refs.feedContainer;
if (container.scrollTop > 0) {
return
}
if (pullToRefresh.pulling) {
if (pullToRefresh.currentY - pullToRefresh.startY >= pullToRefresh.threshold) {
pullToRefresh.refreshing = true;
// Trigger your refresh function here
loadPosts(true).then(() => {
pullToRefresh.refreshing = false;
});
}
pullToRefresh.pulling = false;
}
}"
x-ref="feedContainer">
Get Better Video Recommendations
Save your profile to get personalized video recommendations tailored just for you.