animate popup
This commit is contained in:
@ -90,11 +90,17 @@
|
|||||||
z-index: 999;
|
z-index: 999;
|
||||||
display: flex;
|
display: flex;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
transition: transform 350ms cubic-bezier(.19, .1, .22, 1);
|
||||||
|
transform: translateY(100%);
|
||||||
background: var(--theme-bg-card);
|
background: var(--theme-bg-card);
|
||||||
box-shadow: 0 -2rpx 20rpx rgba(0, 0, 0, .15);
|
box-shadow: 0 -2rpx 20rpx rgba(0, 0, 0, .15);
|
||||||
border-radius: 24rpx 24rpx 0 0;
|
border-radius: 24rpx 24rpx 0 0;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
&.visible {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
.detail-content {
|
.detail-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import config from "../../../config/index";
|
|||||||
import Time from "../../../utils/Time";
|
import Time from "../../../utils/Time";
|
||||||
import { Journal, JournalPageType } from "../../../types/Journal";
|
import { Journal, JournalPageType } from "../../../types/Journal";
|
||||||
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
|
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
|
||||||
|
import Toolkit from "../../../utils/Toolkit";
|
||||||
|
|
||||||
interface MapMarker {
|
interface MapMarker {
|
||||||
id: number;
|
id: number;
|
||||||
@ -40,6 +41,8 @@ interface JournalMapData {
|
|||||||
journals: JournalMarker[];
|
journals: JournalMarker[];
|
||||||
customCalloutMarkerIds: number[];
|
customCalloutMarkerIds: number[];
|
||||||
selectedMarker: JournalMarker | null;
|
selectedMarker: JournalMarker | null;
|
||||||
|
showDetail: boolean; // 是否显示详情(控制 DOM 存在)
|
||||||
|
detailVisible: boolean; // 详情是否可见(控制动画)
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +55,8 @@ Page({
|
|||||||
journals: [],
|
journals: [],
|
||||||
customCalloutMarkerIds: [],
|
customCalloutMarkerIds: [],
|
||||||
selectedMarker: null,
|
selectedMarker: null,
|
||||||
|
showDetail: false,
|
||||||
|
detailVisible: false,
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
},
|
},
|
||||||
async onLoad() {
|
async onLoad() {
|
||||||
@ -225,8 +230,7 @@ Page({
|
|||||||
mongoId: thumbItem.mongoId,
|
mongoId: thumbItem.mongoId,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
this.setData({
|
const selectedMarker = {
|
||||||
selectedMarker: {
|
|
||||||
id: journal.id,
|
id: journal.id,
|
||||||
date: Time.toPassedDateTime(journal.createdAt),
|
date: Time.toPassedDateTime(journal.createdAt),
|
||||||
location: journal.location,
|
location: journal.location,
|
||||||
@ -234,7 +238,12 @@ Page({
|
|||||||
lng: journal.lng,
|
lng: journal.lng,
|
||||||
idea: journal.idea,
|
idea: journal.idea,
|
||||||
items: mediaItems
|
items: mediaItems
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// 先显示元素,再触发动画
|
||||||
|
this.setData({ selectedMarker, showDetail: true });
|
||||||
|
wx.nextTick(() => {
|
||||||
|
this.setData({ detailVisible: true });
|
||||||
});
|
});
|
||||||
wx.hideLoading();
|
wx.hideLoading();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
@ -246,8 +255,10 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 关闭详情 */
|
/** 关闭详情 */
|
||||||
closeDetail() {
|
async closeDetail() {
|
||||||
this.setData({ selectedMarker: null });
|
this.setData({ detailVisible: false });
|
||||||
|
await Toolkit.sleep(350);
|
||||||
|
this.setData({ showDetail: false, selectedMarker: null });
|
||||||
},
|
},
|
||||||
/** 预览媒体 */
|
/** 预览媒体 */
|
||||||
previewMedia(e: WechatMiniprogram.BaseEvent) {
|
previewMedia(e: WechatMiniprogram.BaseEvent) {
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
<cover-view wx:if="{{isLoading}}" class="loading">
|
<cover-view wx:if="{{isLoading}}" class="loading">
|
||||||
<cover-view class="loading-text">加载中...</cover-view>
|
<cover-view class="loading-text">加载中...</cover-view>
|
||||||
</cover-view>
|
</cover-view>
|
||||||
<cover-view wx:if="{{selectedMarker}}" class="marker-detail">
|
<cover-view wx:if="{{showDetail}}" class="marker-detail {{detailVisible ? 'visible' : ''}}">
|
||||||
<cover-view class="detail-content">
|
<cover-view class="detail-content">
|
||||||
<cover-view class="header">
|
<cover-view class="header">
|
||||||
<cover-view class="info">
|
<cover-view class="info">
|
||||||
|
|||||||
Reference in New Issue
Block a user