| 123456789101112131415161718192021222324252627282930313233 |
- function toggleRemindWithAnimation(page, {
- remindKey = 'IsShowRemind',
- animationKey = 'remindAnimation',
- duration = 300,
- showAnimation = 'remind-slide-up',
- hideAnimation = 'remind-slide-down'
- } = {}) {
- // 获取当前显示状态
- const isCurrentlyShown = page.data[remindKey];
- if (isCurrentlyShown) {
- // 如果当前是显示状态,先播放隐藏动画,然后再隐藏
- const animationData = {};
- animationData[animationKey] = hideAnimation;
- page.setData(animationData);
-
- // 等待动画完成后再隐藏弹窗
- setTimeout(function() {
- const hideData = {};
- hideData[remindKey] = false;
- page.setData(hideData);
- }, duration);
- } else {
- // 如果当前是隐藏状态,直接显示并播放显示动画
- const showData = {};
- showData[remindKey] = true;
- showData[animationKey] = showAnimation;
- page.setData(showData);
- }
- }
- module.exports = {
- toggleRemindWithAnimation:toggleRemindWithAnimation,
- }
|