@mpxjs/webpack-plugin 2.10.17 → 2.10.18-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.js +60 -0
- package/lib/file-loader.js +4 -1
- package/lib/global.d.ts +231 -0
- package/lib/index.js +70 -73
- package/lib/init.js +3 -0
- package/lib/json-compiler/index.js +13 -4
- package/lib/loader.js +4 -0
- package/lib/platform/json/wx/index.js +6 -0
- package/lib/platform/style/wx/index.js +102 -72
- package/lib/platform/template/wx/component-config/ad.js +5 -0
- package/lib/platform/template/wx/component-config/button.js +10 -3
- package/lib/platform/template/wx/component-config/camera.js +25 -3
- package/lib/platform/template/wx/component-config/canvas.js +8 -1
- package/lib/platform/template/wx/component-config/cover-image.js +7 -2
- package/lib/platform/template/wx/component-config/cover-view.js +3 -1
- package/lib/platform/template/wx/component-config/form.js +27 -2
- package/lib/platform/template/wx/component-config/image.js +5 -0
- package/lib/platform/template/wx/component-config/input.js +10 -0
- package/lib/platform/template/wx/component-config/label.js +10 -2
- package/lib/platform/template/wx/component-config/map.js +11 -0
- package/lib/platform/template/wx/component-config/movable-area.js +4 -1
- package/lib/platform/template/wx/component-config/movable-view.js +17 -2
- package/lib/platform/template/wx/component-config/navigator.js +26 -0
- package/lib/platform/template/wx/component-config/picker-view.js +12 -0
- package/lib/platform/template/wx/component-config/picker.js +3 -1
- package/lib/platform/template/wx/component-config/progress.js +11 -1
- package/lib/platform/template/wx/component-config/rich-text.js +5 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
- package/lib/platform/template/wx/component-config/slider.js +8 -0
- package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
- package/lib/platform/template/wx/component-config/swiper.js +10 -0
- package/lib/platform/template/wx/component-config/text.js +5 -0
- package/lib/platform/template/wx/component-config/textarea.js +19 -2
- package/lib/platform/template/wx/component-config/unsupported.js +10 -1
- package/lib/platform/template/wx/component-config/video.js +10 -0
- package/lib/platform/template/wx/index.js +21 -1
- package/lib/react/LoadAsyncChunkModule.js +1 -1
- package/lib/react/processStyles.js +21 -9
- package/lib/react/script-helper.js +2 -2
- package/lib/react/style-helper.js +76 -13
- package/lib/resolver/AddModePlugin.js +17 -7
- package/lib/resolver/ExtendComponentsPlugin.js +60 -0
- package/lib/runtime/components/ali/mpx-section-list.mpx +566 -0
- package/lib/runtime/components/ali/mpx-sticky-header.mpx +212 -0
- package/lib/runtime/components/ali/mpx-sticky-section.mpx +17 -0
- package/lib/runtime/components/react/animationHooks/index.ts +75 -0
- package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +197 -0
- package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +301 -0
- package/lib/runtime/components/react/animationHooks/utils.ts +197 -0
- package/lib/runtime/components/react/context.ts +12 -3
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +15 -0
- package/lib/runtime/components/react/dist/animationHooks/index.js +67 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +181 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +279 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.js +151 -0
- package/lib/runtime/components/react/dist/context.d.ts +10 -3
- package/lib/runtime/components/react/dist/context.js +1 -2
- package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-camera.jsx +236 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +66 -50
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +35 -6
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +84 -78
- package/lib/runtime/components/react/dist/mpx-section-list.d.ts +48 -0
- package/lib/runtime/components/react/dist/mpx-section-list.jsx +292 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +20 -20
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +11 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +136 -83
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts +3 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +22 -8
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/parser.d.ts +0 -1
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts +10 -9
- package/lib/runtime/components/react/dist/utils.jsx +47 -24
- package/lib/runtime/components/react/mpx-async-suspense.tsx +3 -1
- package/lib/runtime/components/react/mpx-camera.tsx +327 -0
- package/lib/runtime/components/react/mpx-image.tsx +2 -2
- package/lib/runtime/components/react/mpx-input.tsx +77 -54
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +35 -6
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
- package/lib/runtime/components/react/mpx-scroll-view.tsx +110 -114
- package/lib/runtime/components/react/mpx-section-list.tsx +439 -0
- package/lib/runtime/components/react/mpx-sticky-header.tsx +24 -24
- package/lib/runtime/components/react/mpx-swiper.tsx +156 -81
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -0
- package/lib/runtime/components/react/mpx-view.tsx +27 -12
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/tsconfig.json +26 -0
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +51 -27
- package/lib/runtime/components/web/mpx-scroll-view.vue +5 -2
- package/lib/runtime/components/web/mpx-section-list.vue +551 -0
- package/lib/runtime/components/wx/mpx-section-list-default/list-footer.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list-default/list-header.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list-default/list-item.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list-default/section-header.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list.mpx +209 -0
- package/lib/runtime/components/wx/mpx-sticky-header.mpx +40 -0
- package/lib/runtime/components/wx/mpx-sticky-section.mpx +31 -0
- package/lib/runtime/optionProcessor.js +5 -0
- package/lib/runtime/optionProcessorReact.js +7 -0
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +1 -2
- package/lib/style-compiler/strip-conditional.js +244 -0
- package/lib/template-compiler/compiler.js +9 -8
- package/lib/utils/const.js +29 -0
- package/lib/utils/dom-tag-config.js +1 -1
- package/lib/utils/string.js +25 -1
- package/lib/wxss/loader.js +4 -1
- package/lib/wxss/utils.js +7 -2
- package/package.json +7 -14
- package/LICENSE +0 -433
- package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.js +0 -289
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +0 -320
- package/lib/style-compiler/strip-conditional-loader.js +0 -289
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="mpx-sticky-header-container">
|
|
3
|
+
<view class="mpx-sticky-header" wx:ref="stickyHeader" wx:style="{{stickyHeaderStyle}}">
|
|
4
|
+
<slot></slot>
|
|
5
|
+
</view>
|
|
6
|
+
<view
|
|
7
|
+
class="mpx-sticky-header-placeholder"
|
|
8
|
+
id="{{stickyId}}"
|
|
9
|
+
wx:style="{{placeholderStyle}}"
|
|
10
|
+
></view>
|
|
11
|
+
</view>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import mpx, { createComponent } from '@mpxjs/core'
|
|
16
|
+
|
|
17
|
+
createComponent({
|
|
18
|
+
properties: {
|
|
19
|
+
offsetTop: {
|
|
20
|
+
type: Number,
|
|
21
|
+
value: 0
|
|
22
|
+
},
|
|
23
|
+
scrollViewId: {
|
|
24
|
+
type: String,
|
|
25
|
+
value: ''
|
|
26
|
+
},
|
|
27
|
+
stickyId: {
|
|
28
|
+
type: String,
|
|
29
|
+
value: ''
|
|
30
|
+
},
|
|
31
|
+
padding: Array,
|
|
32
|
+
enablePolling: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
value: false
|
|
35
|
+
},
|
|
36
|
+
pollingDuration: {
|
|
37
|
+
type: Number,
|
|
38
|
+
value: 300
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
data: {
|
|
42
|
+
isStickOnTop: false,
|
|
43
|
+
scrollOffsetTop: 0,
|
|
44
|
+
headerHeight: 0,
|
|
45
|
+
stickyHeader: '',
|
|
46
|
+
headerTop: 0,
|
|
47
|
+
lastIntersectionRatio: -1,
|
|
48
|
+
pollingTimer: null
|
|
49
|
+
},
|
|
50
|
+
computed: {
|
|
51
|
+
paddingStyle() {
|
|
52
|
+
if (!this.padding || !Array.isArray(this.padding)) {
|
|
53
|
+
return ''
|
|
54
|
+
}
|
|
55
|
+
const [top = 0, right = 0, bottom = 0, left = 0] = this.padding
|
|
56
|
+
return `padding: ${top}px ${right}px ${bottom}px ${left}px;`
|
|
57
|
+
},
|
|
58
|
+
stickyHeaderStyle() {
|
|
59
|
+
const baseStyle = this.isStickOnTop
|
|
60
|
+
? `position: fixed;top: ${this.scrollOffsetTop + this.offsetTop}px;`
|
|
61
|
+
: ''
|
|
62
|
+
return baseStyle + this.paddingStyle
|
|
63
|
+
},
|
|
64
|
+
placeholderStyle() {
|
|
65
|
+
const position = this.isStickOnTop ? 'relative' : 'absolute'
|
|
66
|
+
return `position: ${position};height: ${this.headerHeight}px;`
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
ready() {
|
|
70
|
+
if (!this.scrollViewId) {
|
|
71
|
+
console.error('[mpx runtime error]: scroll-view-id is necessary property in ali environment')
|
|
72
|
+
}
|
|
73
|
+
if (!this.stickyId) {
|
|
74
|
+
console.error('[mpx runtime error]: sticky-id is necessary property in ali environment')
|
|
75
|
+
}
|
|
76
|
+
this.initStickyHeader()
|
|
77
|
+
// 启动轮询
|
|
78
|
+
if (this.enablePolling) {
|
|
79
|
+
this.startPolling()
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
methods: {
|
|
83
|
+
initStickyHeader() {
|
|
84
|
+
this.createSelectorQuery()
|
|
85
|
+
.select('.mpx-sticky-header')
|
|
86
|
+
.boundingClientRect()
|
|
87
|
+
.exec((rect = []) => {
|
|
88
|
+
this.headerHeight = rect[0]?.height || 0
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
mpx
|
|
92
|
+
.createSelectorQuery()
|
|
93
|
+
.select(`#${this.scrollViewId}`)
|
|
94
|
+
.boundingClientRect()
|
|
95
|
+
.exec((res) => {
|
|
96
|
+
if (!res) return
|
|
97
|
+
this.scrollOffsetTop = res[0]?.top || 0
|
|
98
|
+
this.stickyHeader = mpx.createIntersectionObserver({
|
|
99
|
+
thresholds: [0.1, 0.9]
|
|
100
|
+
})
|
|
101
|
+
this.initObserver()
|
|
102
|
+
})
|
|
103
|
+
},
|
|
104
|
+
initObserver() {
|
|
105
|
+
this.stickyHeader.relativeTo(`#${this.scrollViewId}`).observe(`#${this.stickyId}`, (res) => {
|
|
106
|
+
const { intersectionRatio, intersectionRect, relativeRect, boundingClientRect } = res
|
|
107
|
+
if (intersectionRatio < this.lastIntersectionRatio) {
|
|
108
|
+
// boundingClientRect.top < relativeRect.top fixed,否则默认布局
|
|
109
|
+
this.handleStickyStateChange(boundingClientRect.top < relativeRect.top)
|
|
110
|
+
} else if (intersectionRatio > this.lastIntersectionRatio) {
|
|
111
|
+
this.handleStickyStateChange(false)
|
|
112
|
+
}
|
|
113
|
+
this.lastIntersectionRatio = intersectionRatio
|
|
114
|
+
})
|
|
115
|
+
},
|
|
116
|
+
refresh() {
|
|
117
|
+
// 并行执行两个独立的查询
|
|
118
|
+
Promise.all([
|
|
119
|
+
// 查询1:组件内部元素
|
|
120
|
+
new Promise((resolve) => {
|
|
121
|
+
this.createSelectorQuery()
|
|
122
|
+
.select('.mpx-sticky-header')
|
|
123
|
+
.boundingClientRect()
|
|
124
|
+
.select('.mpx-sticky-header-placeholder')
|
|
125
|
+
.boundingClientRect()
|
|
126
|
+
.exec((results) => {
|
|
127
|
+
resolve(results)
|
|
128
|
+
})
|
|
129
|
+
}),
|
|
130
|
+
// 查询2:页面级scrollView
|
|
131
|
+
new Promise((resolve) => {
|
|
132
|
+
mpx.createSelectorQuery()
|
|
133
|
+
.select(`#${this.scrollViewId}`)
|
|
134
|
+
.boundingClientRect()
|
|
135
|
+
.select(`#${this.scrollViewId}`)
|
|
136
|
+
.scrollOffset()
|
|
137
|
+
.exec((results) => {
|
|
138
|
+
resolve(results)
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
]).then(([componentResults, scrollResults]) => {
|
|
142
|
+
const [stickyHeaderRect, placeholderRect] = componentResults
|
|
143
|
+
const [scrollViewRect, scrollOffsetData] = scrollResults
|
|
144
|
+
|
|
145
|
+
if (!stickyHeaderRect || !placeholderRect || !scrollViewRect || !scrollOffsetData) return
|
|
146
|
+
|
|
147
|
+
this.scrollOffsetTop = scrollViewRect.top || 0
|
|
148
|
+
this.headerHeight = stickyHeaderRect.height
|
|
149
|
+
|
|
150
|
+
// 模拟 offsetTop 计算:sticky placeholder具体顶部距离 - scrollView顶部 + scrollView滚动位置
|
|
151
|
+
// 必须用 placeholder 到顶部距离,用 sticky 如果刚好差值为 0, 区分不出是本身就在顶部还是 fixed 在顶部
|
|
152
|
+
this.headerTop = placeholderRect.top - this.scrollOffsetTop + scrollOffsetData.scrollTop
|
|
153
|
+
|
|
154
|
+
this.handleStickyStateChange(scrollOffsetData.scrollTop > this.headerTop)
|
|
155
|
+
})
|
|
156
|
+
},
|
|
157
|
+
handleStickyStateChange(shouldStick) {
|
|
158
|
+
// 如果状态没有变化,直接返回
|
|
159
|
+
if (shouldStick === this.isStickOnTop) {
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
// 更新状态
|
|
163
|
+
this.isStickOnTop = shouldStick
|
|
164
|
+
// 触发事件
|
|
165
|
+
this.triggerEvent('stickontopchange', {
|
|
166
|
+
isStickOnTop: shouldStick,
|
|
167
|
+
id: this.stickyId
|
|
168
|
+
})
|
|
169
|
+
},
|
|
170
|
+
// 启动轮询
|
|
171
|
+
startPolling() {
|
|
172
|
+
if (this.pollingTimer) {
|
|
173
|
+
clearInterval(this.pollingTimer)
|
|
174
|
+
}
|
|
175
|
+
this.pollingTimer = setInterval(() => {
|
|
176
|
+
this.refresh()
|
|
177
|
+
}, this.pollingDuration)
|
|
178
|
+
},
|
|
179
|
+
// 停止轮询
|
|
180
|
+
stopPolling() {
|
|
181
|
+
if (this.pollingTimer) {
|
|
182
|
+
clearInterval(this.pollingTimer)
|
|
183
|
+
this.pollingTimer = null
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
detached() {
|
|
188
|
+
// 清理观察器
|
|
189
|
+
if (this.stickyHeader) {
|
|
190
|
+
this.stickyHeader.disconnect()
|
|
191
|
+
}
|
|
192
|
+
// 清理轮询定时器
|
|
193
|
+
if (this.pollingTimer) {
|
|
194
|
+
clearInterval(this.pollingTimer)
|
|
195
|
+
this.pollingTimer = null
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
</script>
|
|
200
|
+
<style lang="stylus" scoped>
|
|
201
|
+
.mpx-sticky-header-container
|
|
202
|
+
position relative
|
|
203
|
+
.mpx-sticky-header-placeholder
|
|
204
|
+
position absolute
|
|
205
|
+
left 0
|
|
206
|
+
right 0
|
|
207
|
+
top 0
|
|
208
|
+
pointer-events none
|
|
209
|
+
.mpx-sticky-header
|
|
210
|
+
width 100%
|
|
211
|
+
box-sizing border-box
|
|
212
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="mpx-sticky-section">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { createComponent } from '@mpxjs/core'
|
|
9
|
+
|
|
10
|
+
createComponent({
|
|
11
|
+
|
|
12
|
+
})
|
|
13
|
+
</script>
|
|
14
|
+
<style lang="stylus" scoped>
|
|
15
|
+
.mpx-sticky-section
|
|
16
|
+
position relative
|
|
17
|
+
</style>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { error, collectDataset, hasOwn } from '@mpxjs/utils'
|
|
2
|
+
import { useRef } from 'react'
|
|
3
|
+
import useAnimationAPIHooks from './useAnimationAPIHooks'
|
|
4
|
+
import useTransitionHooks from './useTransitionHooks'
|
|
5
|
+
import type { AnimatableValue } from 'react-native-reanimated'
|
|
6
|
+
import type { MutableRefObject } from 'react'
|
|
7
|
+
import type { NativeSyntheticEvent } from 'react-native'
|
|
8
|
+
import type { _ViewProps } from '../mpx-view'
|
|
9
|
+
|
|
10
|
+
// 动画类型
|
|
11
|
+
export type AnimationType = 'api'|'animation'|'transition'|'none'
|
|
12
|
+
|
|
13
|
+
export default function useAnimationHooks<T, P> (props: _ViewProps & { enableAnimation?: boolean | AnimationType, layoutRef: MutableRefObject<any>, transitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void }) {
|
|
14
|
+
const { style: originalStyle = {}, enableAnimation, animation, transitionend, layoutRef } = props
|
|
15
|
+
// 记录动画类型
|
|
16
|
+
let animationType = ''
|
|
17
|
+
if (hasOwn(originalStyle, 'animation') || (hasOwn(originalStyle, 'animationName') && hasOwn(originalStyle, 'animationDuration'))) {
|
|
18
|
+
// css animation 只做检测提示
|
|
19
|
+
animationType = 'animation'
|
|
20
|
+
}
|
|
21
|
+
if (!!animation || enableAnimation === true) {
|
|
22
|
+
animationType = 'api'
|
|
23
|
+
}
|
|
24
|
+
// 优先级 css transition > API
|
|
25
|
+
if (hasOwn(originalStyle, 'transition') || (hasOwn(originalStyle, 'transitionProperty') && hasOwn(originalStyle, 'transitionDuration'))) {
|
|
26
|
+
animationType = 'transition'
|
|
27
|
+
}
|
|
28
|
+
// 优先以 enableAnimation 定义类型为准
|
|
29
|
+
if (enableAnimation === 'api' || enableAnimation === 'transition' || enableAnimation === 'animation') {
|
|
30
|
+
animationType = enableAnimation
|
|
31
|
+
}
|
|
32
|
+
const animationTypeRef = useRef(animationType)
|
|
33
|
+
if (animationType! && animationTypeRef.current !== animationType) {
|
|
34
|
+
// 允许 API、CssTransition 到 none,不允许 API、CssTransition 互切,不允许 none 到 API、CssTransition
|
|
35
|
+
error('[Mpx runtime error]: The animation type should be stable in the component lifecycle, or you can set animation type with [enable-animation].')
|
|
36
|
+
}
|
|
37
|
+
if (animationType === 'animation') {
|
|
38
|
+
// 暂不支持 CssAnimation 提示
|
|
39
|
+
error('[Mpx runtime error]: CSS animation is not supported yet')
|
|
40
|
+
return { enableStyleAnimation: false }
|
|
41
|
+
}
|
|
42
|
+
if (!animationTypeRef.current) return { enableStyleAnimation: false }
|
|
43
|
+
|
|
44
|
+
const hooksProps = { style: originalStyle }
|
|
45
|
+
if (transitionend && typeof transitionend === 'function') {
|
|
46
|
+
function withTimingCallback (finished?: boolean, current?: AnimatableValue, duration?: number) {
|
|
47
|
+
const target = {
|
|
48
|
+
id: animation?.id || -1,
|
|
49
|
+
dataset: collectDataset(props),
|
|
50
|
+
offsetLeft: layoutRef?.current?.offsetLeft || 0,
|
|
51
|
+
offsetTop: layoutRef?.current?.offsetTop || 0
|
|
52
|
+
}
|
|
53
|
+
transitionend!({
|
|
54
|
+
type: 'transitionend',
|
|
55
|
+
// elapsedTime 对齐wx 单位s
|
|
56
|
+
detail: { elapsedTime: duration ? duration / 1000 : 0, finished, current },
|
|
57
|
+
target,
|
|
58
|
+
currentTarget: target,
|
|
59
|
+
timeStamp: Date.now()
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
Object.assign(hooksProps, { transitionend: withTimingCallback })
|
|
63
|
+
}
|
|
64
|
+
if (animationTypeRef.current === 'api') {
|
|
65
|
+
Object.assign(hooksProps, { animation })
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
enableStyleAnimation: !!animationTypeRef.current,
|
|
69
|
+
animationStyle: animationTypeRef.current === 'api'
|
|
70
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
71
|
+
? useAnimationAPIHooks(hooksProps)
|
|
72
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
73
|
+
: useTransitionHooks(hooksProps)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { useMemo, useRef, useEffect } from 'react'
|
|
2
|
+
import { error, hasOwn } from '@mpxjs/utils'
|
|
3
|
+
import {
|
|
4
|
+
Easing,
|
|
5
|
+
withSequence,
|
|
6
|
+
makeMutable,
|
|
7
|
+
runOnJS,
|
|
8
|
+
useSharedValue,
|
|
9
|
+
useAnimatedStyle,
|
|
10
|
+
cancelAnimation
|
|
11
|
+
} from 'react-native-reanimated'
|
|
12
|
+
import {
|
|
13
|
+
easingKey,
|
|
14
|
+
animationAPIInitialValue,
|
|
15
|
+
percentExp,
|
|
16
|
+
isTransform,
|
|
17
|
+
getInitialVal,
|
|
18
|
+
getAnimation,
|
|
19
|
+
getTransformObj,
|
|
20
|
+
formatAnimatedKeys
|
|
21
|
+
} from './utils'
|
|
22
|
+
import { useRunOnJSCallback } from '../utils'
|
|
23
|
+
import type { NativeSyntheticEvent, TransformsStyle } from 'react-native'
|
|
24
|
+
import type { AnimationCallback, SharedValue, AnimatableValue } from 'react-native-reanimated'
|
|
25
|
+
import type { ExtendedViewStyle } from '../types/common'
|
|
26
|
+
import type { AnimationHooksPropsType } from './utils'
|
|
27
|
+
|
|
28
|
+
export default function useAnimationAPIHooks<T, P> (props: AnimationHooksPropsType) {
|
|
29
|
+
// console.log(`useAnimationAPIHooks, props=`, props)
|
|
30
|
+
const { style: originalStyle = {}, animation, transitionend } = props
|
|
31
|
+
// style变更标识(首次render不执行)
|
|
32
|
+
const animationDeps = useRef(-1)
|
|
33
|
+
// animation API 使用 animation.id 为依赖
|
|
34
|
+
if (animation?.id) {
|
|
35
|
+
animationDeps.current = animation.id
|
|
36
|
+
}
|
|
37
|
+
// 有动画样式的 style key(useAnimatedStyle使用)
|
|
38
|
+
const animatedStyleKeys = useSharedValue([] as (string|string[])[])
|
|
39
|
+
// 记录需要执行动画的 propName
|
|
40
|
+
const animatedKeys = useRef([] as string[])
|
|
41
|
+
// 记录上次style map
|
|
42
|
+
const lastStyleRef = useRef({} as {[propName: keyof ExtendedViewStyle]: number|string})
|
|
43
|
+
// ** 全量 style prop sharedValue
|
|
44
|
+
const shareValMap = useMemo(() => {
|
|
45
|
+
return Object.keys(animationAPIInitialValue).reduce((valMap, key) => {
|
|
46
|
+
const defaultVal = getInitialVal(originalStyle, key)
|
|
47
|
+
valMap[key] = makeMutable(defaultVal)
|
|
48
|
+
return valMap
|
|
49
|
+
}, {} as { [propName: keyof ExtendedViewStyle]: SharedValue<string|number> })
|
|
50
|
+
}, [])
|
|
51
|
+
const runOnJSCallbackRef = useRef({})
|
|
52
|
+
if (transitionend) {
|
|
53
|
+
runOnJSCallbackRef.current = {
|
|
54
|
+
transitionend
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const runOnJSCallback = useRunOnJSCallback(runOnJSCallbackRef)
|
|
58
|
+
// 设置 lastShareValRef & shareValMap
|
|
59
|
+
function updateStyleVal () {
|
|
60
|
+
Object.keys(shareValMap).forEach(key => {
|
|
61
|
+
let value = originalStyle[key]
|
|
62
|
+
if (isTransform(key)) {
|
|
63
|
+
value = originalStyle.transform
|
|
64
|
+
Object.entries(getTransformObj(value)).forEach(([key, value]) => {
|
|
65
|
+
if (value !== lastStyleRef.current[key]) {
|
|
66
|
+
lastStyleRef.current[key] = value
|
|
67
|
+
shareValMap[key].value = value
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
} else {
|
|
71
|
+
if (value !== lastStyleRef.current[key]) {
|
|
72
|
+
lastStyleRef.current[key] = value
|
|
73
|
+
shareValMap[key].value = value
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
// 根据 animation action 创建&驱动动画
|
|
79
|
+
function createAnimation (animatedKeys: string[] = []) {
|
|
80
|
+
const actions = animation?.actions || []
|
|
81
|
+
const sequence = {} as { [propName: keyof ExtendedViewStyle]: (string|number)[] }
|
|
82
|
+
const lastValueMap = {} as { [propName: keyof ExtendedViewStyle]: string|number }
|
|
83
|
+
actions.forEach(({ animatedOption, rules, transform }, index) => {
|
|
84
|
+
const { delay, duration, timingFunction, transformOrigin } = animatedOption
|
|
85
|
+
const easing = timingFunction ? easingKey[timingFunction] : Easing.inOut(Easing.quad)
|
|
86
|
+
let needSetCallback = true
|
|
87
|
+
const callback: AnimationCallback = (finished?: boolean, current?: AnimatableValue) => {
|
|
88
|
+
'worklet'
|
|
89
|
+
// 动画结束后设置下一次transformOrigin
|
|
90
|
+
if (finished) {
|
|
91
|
+
if (index < actions.length - 1) {
|
|
92
|
+
const transformOrigin = actions[index + 1].animatedOption?.transformOrigin
|
|
93
|
+
transformOrigin && (shareValMap.transformOrigin.value = transformOrigin)
|
|
94
|
+
}
|
|
95
|
+
transitionend && runOnJS(runOnJSCallback)('transitionend', finished, current, duration)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (index === 0 && transformOrigin) {
|
|
99
|
+
// 设置当次中心
|
|
100
|
+
shareValMap.transformOrigin.value = transformOrigin
|
|
101
|
+
}
|
|
102
|
+
// 添加每个key的多次step动画
|
|
103
|
+
animatedKeys.forEach(key => {
|
|
104
|
+
const shareVal = shareValMap[key].value
|
|
105
|
+
const ruleV = isTransform(key) ? transform.get(key) : rules.get(key)
|
|
106
|
+
// color 设置为 1
|
|
107
|
+
// key不存在,第一轮取shareValMap[key]value,非第一轮取上一轮的
|
|
108
|
+
let toVal = ruleV !== undefined
|
|
109
|
+
? ruleV
|
|
110
|
+
: index > 0
|
|
111
|
+
? lastValueMap[key]
|
|
112
|
+
: shareVal
|
|
113
|
+
if (percentExp.test(`${toVal}`) && !percentExp.test(shareVal as string) && !isNaN(+shareVal)) {
|
|
114
|
+
// 获取到的toVal为百分比格式化shareValMap为百分比
|
|
115
|
+
shareValMap[key].value = `${shareVal as number * 100}%`
|
|
116
|
+
} else if (percentExp.test(shareVal as string) && !percentExp.test(toVal as string) && !isNaN(+toVal)) {
|
|
117
|
+
// 初始值为百分比则格式化toVal为百分比
|
|
118
|
+
toVal = `${toVal as number * 100}%`
|
|
119
|
+
} else if (typeof toVal !== typeof shareVal) {
|
|
120
|
+
// 动画起始值和终态值类型不一致报错提示一下
|
|
121
|
+
error(`[Mpx runtime error]: Value types of property ${key} must be consistent during the animation`)
|
|
122
|
+
}
|
|
123
|
+
const animation = (toVal === 'auto' && !isNaN(+shareVal)) || (shareVal === 'auto' && !isNaN(+toVal)) ? toVal : getAnimation({ key, value: toVal! }, { delay, duration, easing }, needSetCallback ? callback : undefined)
|
|
124
|
+
needSetCallback = false
|
|
125
|
+
if (!sequence[key]) {
|
|
126
|
+
sequence[key] = [animation]
|
|
127
|
+
} else {
|
|
128
|
+
sequence[key].push(animation)
|
|
129
|
+
}
|
|
130
|
+
// 更新一下 lastValueMap
|
|
131
|
+
lastValueMap[key] = toVal!
|
|
132
|
+
})
|
|
133
|
+
// 赋值驱动动画
|
|
134
|
+
animatedKeys.forEach((key) => {
|
|
135
|
+
const animations = sequence[key]
|
|
136
|
+
shareValMap[key].value = animations.length > 1 ? withSequence(...animations) : animations[0]
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
// 循环 animation actions 获取所有有动画的 style prop name
|
|
141
|
+
function getAnimatedStyleKeys () {
|
|
142
|
+
return (animation?.actions || []).reduce((keyMap, action) => {
|
|
143
|
+
const { rules, transform } = action
|
|
144
|
+
const ruleArr = [...rules.keys(), ...transform.keys()]
|
|
145
|
+
ruleArr.forEach(key => {
|
|
146
|
+
keyMap.push(key)
|
|
147
|
+
})
|
|
148
|
+
// console.log('getAnimatedStyleKeys keyMap=', keyMap)
|
|
149
|
+
return keyMap
|
|
150
|
+
}, [] as string[])
|
|
151
|
+
}
|
|
152
|
+
// 获取动画样式&驱动动画
|
|
153
|
+
function startAnimation () {
|
|
154
|
+
// 更新动画样式 key map
|
|
155
|
+
animatedKeys.current = getAnimatedStyleKeys()
|
|
156
|
+
animatedStyleKeys.value = formatAnimatedKeys(['transformOrigin', ...animatedKeys.current])
|
|
157
|
+
// 驱动动画
|
|
158
|
+
createAnimation(animatedKeys.current)
|
|
159
|
+
}
|
|
160
|
+
// ** style 更新
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
// animation api style 更新同步更新 shareVal(默认)
|
|
163
|
+
updateStyleVal()
|
|
164
|
+
}, [originalStyle])
|
|
165
|
+
// ** 获取动画样式prop & 驱动动画
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if (animationDeps.current <= 0) return
|
|
168
|
+
startAnimation()
|
|
169
|
+
}, [animationDeps.current])
|
|
170
|
+
// ** 清空动画
|
|
171
|
+
useEffect(() => {
|
|
172
|
+
return () => {
|
|
173
|
+
Object.values(shareValMap).forEach((value) => {
|
|
174
|
+
cancelAnimation(value)
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
}, [])
|
|
178
|
+
// ** 生成动画样式
|
|
179
|
+
return useAnimatedStyle(() => {
|
|
180
|
+
// console.info(`useAnimatedStyle styles=`, originalStyle)
|
|
181
|
+
return animatedStyleKeys.value.reduce((styles, key) => {
|
|
182
|
+
if (Array.isArray(key)) {
|
|
183
|
+
const transformStyle = getTransformObj(originalStyle.transform || [])
|
|
184
|
+
key.forEach((transformKey) => {
|
|
185
|
+
transformStyle[transformKey] = shareValMap[transformKey].value
|
|
186
|
+
})
|
|
187
|
+
styles.transform = Object.entries(transformStyle).map(([key, value]) => {
|
|
188
|
+
return { [key]: value }
|
|
189
|
+
}) as Extract<'transform', TransformsStyle>
|
|
190
|
+
} else {
|
|
191
|
+
styles[key] = shareValMap[key].value
|
|
192
|
+
}
|
|
193
|
+
// console.log('animationStyle', styles)
|
|
194
|
+
return styles
|
|
195
|
+
}, {} as ExtendedViewStyle)
|
|
196
|
+
})
|
|
197
|
+
}
|