Files
prop-ai-hr/mobile-uni/src/services/navigation.ts
T

31 lines
696 B
TypeScript

export const resetPageScroll = () => {
const scrollTop = () => {
uni.pageScrollTo({ scrollTop: 0, duration: 0 });
if (typeof window !== 'undefined') {
window.scrollTo({ top: 0, left: 0, behavior: 'auto' });
document.documentElement.scrollTop = 0;
document.body.scrollTop = 0;
}
};
scrollTop();
setTimeout(scrollTop, 0);
setTimeout(scrollTop, 80);
setTimeout(scrollTop, 240);
};
const switchToToday = () => {
uni.switchTab({ url: '/pages/user/today/index' });
};
export const navigateBackToToday = () => {
if (getCurrentPages().length <= 1) {
switchToToday();
return;
}
uni.navigateBack({
delta: 1,
fail: switchToToday
});
};