@mpxjs/webpack-plugin 2.10.7-beta.7 → 2.10.7-beta.9
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/dependencies/RecordPageConfigsMapDependency.js +1 -1
- package/lib/platform/style/wx/index.js +7 -0
- package/lib/platform/template/wx/component-config/movable-view.js +1 -10
- package/lib/runtime/components/react/context.ts +12 -2
- package/lib/runtime/components/react/dist/context.js +1 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +63 -9
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +306 -61
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +15 -10
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +3 -1
- package/lib/runtime/components/react/mpx-movable-area.tsx +98 -11
- package/lib/runtime/components/react/mpx-movable-view.tsx +356 -62
- package/lib/runtime/components/react/mpx-scroll-view.tsx +16 -9
- package/lib/runtime/components/react/mpx-sticky-header.tsx +3 -1
- package/lib/runtime/components/web/mpx-scroll-view.vue +4 -7
- package/lib/runtime/components/web/mpx-sticky-header.vue +39 -31
- package/lib/template-compiler/bind-this.js +2 -1
- package/lib/template-compiler/compiler.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { computed } from 'vue'
|
|
2
3
|
import getInnerListeners, { getCustomEvent } from './getInnerListeners'
|
|
3
4
|
import { processSize } from '../../utils'
|
|
4
5
|
import BScroll from '@better-scroll/core'
|
|
@@ -60,12 +61,8 @@
|
|
|
60
61
|
},
|
|
61
62
|
provide () {
|
|
62
63
|
return {
|
|
63
|
-
scrollOffset:
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
refreshVersion: {
|
|
67
|
-
get: () => this.refreshVersion
|
|
68
|
-
}
|
|
64
|
+
scrollOffset: computed(() => -this.lastY || 0),
|
|
65
|
+
refreshVersion: computed(() => this.refreshVersion || 0)
|
|
69
66
|
}
|
|
70
67
|
},
|
|
71
68
|
data () {
|
|
@@ -342,7 +339,6 @@
|
|
|
342
339
|
const scrollWrapperHeight = wrapper?.clientHeight || 0
|
|
343
340
|
if (wrapper) {
|
|
344
341
|
const computedStyle = getComputedStyle(wrapper)
|
|
345
|
-
this.refreshVersion = this.refreshVersion + 1
|
|
346
342
|
// 考虑子元素样式可能会设置100%,如果直接继承 scrollContent 的样式可能会有问题
|
|
347
343
|
// 所以使用 wrapper 作为 innerWrapper 的宽高参考依据
|
|
348
344
|
this.$refs.innerWrapper.style.width = `${scrollWrapperWidth - parseInt(computedStyle.paddingLeft) - parseInt(computedStyle.paddingRight)}px`
|
|
@@ -408,6 +404,7 @@
|
|
|
408
404
|
this.lastContentHeight = scrollContentHeight
|
|
409
405
|
this.lastWrapperWidth = scrollWrapperWidth
|
|
410
406
|
this.lastWrapperHeight = scrollWrapperHeight
|
|
407
|
+
this.refreshVersion++
|
|
411
408
|
if (this.bs) this.bs.refresh()
|
|
412
409
|
}
|
|
413
410
|
},
|
|
@@ -6,10 +6,11 @@ import { getCustomEvent } from './getInnerListeners'
|
|
|
6
6
|
name: 'mpx-sticky-header',
|
|
7
7
|
inject: ['scrollOffset', 'refreshVersion'],
|
|
8
8
|
props: {
|
|
9
|
-
|
|
9
|
+
offsetTop: {
|
|
10
10
|
type: Number,
|
|
11
11
|
default: 0
|
|
12
|
-
}
|
|
12
|
+
},
|
|
13
|
+
padding: Array
|
|
13
14
|
},
|
|
14
15
|
data() {
|
|
15
16
|
return {
|
|
@@ -17,16 +18,8 @@ import { getCustomEvent } from './getInnerListeners'
|
|
|
17
18
|
isStickOnTop: false
|
|
18
19
|
}
|
|
19
20
|
},
|
|
20
|
-
computed: {
|
|
21
|
-
_scrollOffset() {
|
|
22
|
-
return -this.scrollOffset?.get() || 0
|
|
23
|
-
},
|
|
24
|
-
_refreshVersion() {
|
|
25
|
-
return this.refreshVersion?.get() || 0
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
21
|
watch: {
|
|
29
|
-
|
|
22
|
+
scrollOffset: {
|
|
30
23
|
handler(newScrollOffset) {
|
|
31
24
|
const newIsStickOnTop = newScrollOffset > this.headerTop
|
|
32
25
|
if (newIsStickOnTop !== this.isStickOnTop) {
|
|
@@ -35,19 +28,25 @@ import { getCustomEvent } from './getInnerListeners'
|
|
|
35
28
|
isStickOnTop: newIsStickOnTop
|
|
36
29
|
}, this))
|
|
37
30
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (this.isStickOnTop) {
|
|
41
|
-
stickyHeader.style.transform = `translateY(${newScrollOffset - this.headerTop + this.offsetTop}px)`
|
|
42
|
-
} else {
|
|
43
|
-
stickyHeader.style.transform = 'none'
|
|
44
|
-
}
|
|
31
|
+
|
|
32
|
+
this.setTransformStyle()
|
|
45
33
|
},
|
|
46
34
|
immediate: true
|
|
47
35
|
},
|
|
48
|
-
|
|
36
|
+
refreshVersion: {
|
|
49
37
|
handler() {
|
|
50
|
-
|
|
38
|
+
this.setHeaderTop()
|
|
39
|
+
this.setTransformStyle()
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
mounted() {
|
|
44
|
+
this.setPaddingStyle()
|
|
45
|
+
this.setHeaderTop()
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
setHeaderTop () {
|
|
49
|
+
const parentElement = this.$el.parentElement
|
|
51
50
|
if (!parentElement) return
|
|
52
51
|
|
|
53
52
|
const parentClass = parentElement.className || ''
|
|
@@ -58,20 +57,29 @@ import { getCustomEvent } from './getInnerListeners'
|
|
|
58
57
|
warn('sticky-header only supports being a direct child of a scroll-view or sticky-section component.')
|
|
59
58
|
return
|
|
60
59
|
}
|
|
61
|
-
|
|
62
60
|
this.headerTop = isStickySection
|
|
63
61
|
? this.$el.offsetTop + parentElement.offsetTop
|
|
64
62
|
: this.$el.offsetTop
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
},
|
|
64
|
+
setPaddingStyle() {
|
|
65
|
+
const stickyHeader = this.$refs.stickyHeader
|
|
66
|
+
if (!stickyHeader) return
|
|
67
|
+
|
|
68
|
+
if (this.padding && Array.isArray(this.padding)) {
|
|
69
|
+
const [top = 0, right = 0, bottom = 0, left = 0] = this.padding
|
|
70
|
+
stickyHeader.style.padding = `${top}px ${right}px ${bottom}px ${left}px`
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
setTransformStyle () {
|
|
74
|
+
const stickyHeader = this.$refs.stickyHeader
|
|
75
|
+
if (!stickyHeader) return
|
|
76
|
+
|
|
77
|
+
// 设置 transform
|
|
78
|
+
if (this.scrollOffset > this.headerTop) {
|
|
79
|
+
stickyHeader.style.transform = `translateY(${this.scrollOffset - this.headerTop + this.offsetTop}px)`
|
|
80
|
+
} else {
|
|
81
|
+
stickyHeader.style.transform = 'none'
|
|
82
|
+
}
|
|
75
83
|
}
|
|
76
84
|
},
|
|
77
85
|
render(h) {
|
|
@@ -2,6 +2,7 @@ const babylon = require('@babel/parser')
|
|
|
2
2
|
const traverse = require('@babel/traverse').default
|
|
3
3
|
const t = require('@babel/types')
|
|
4
4
|
const generate = require('@babel/generator').default
|
|
5
|
+
const isValidIdentifierStr = require('../utils/is-valid-identifier-str')
|
|
5
6
|
|
|
6
7
|
const names = 'Infinity,undefined,NaN,isFinite,isNaN,' +
|
|
7
8
|
'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
|
|
@@ -41,7 +42,7 @@ function getCollectPath (path) {
|
|
|
41
42
|
if (current.node.computed) {
|
|
42
43
|
if (t.isLiteral(current.node.property)) {
|
|
43
44
|
if (t.isStringLiteral(current.node.property)) {
|
|
44
|
-
if (dangerousKeyMap[current.node.property.value]) {
|
|
45
|
+
if (dangerousKeyMap[current.node.property.value] || !isValidIdentifierStr(current.node.property.value)) {
|
|
45
46
|
break
|
|
46
47
|
}
|
|
47
48
|
keyPath += `.${current.node.property.value}`
|