@mpxjs/webpack-plugin 2.9.0-beta.3 → 2.9.0-beta.5
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/index.js +3 -10
- package/lib/platform/json/wx/index.js +3 -3
- package/lib/platform/template/wx/component-config/fix-html-tag.js +2 -2
- package/lib/platform/template/wx/index.js +13 -2
- package/lib/runtime/components/web/mpx-keep-alive.vue +2 -0
- package/lib/runtime/components/web/mpx-movable-view.vue +83 -20
- package/lib/runtime/components/web/mpx-scroll-view.vue +50 -15
- package/lib/runtime/components/web/mpx-swiper.vue +152 -62
- package/lib/runtime/optionProcessor.js +4 -3
- package/lib/template-compiler/bind-this.js +45 -14
- package/lib/template-compiler/compiler.js +103 -67
- package/lib/template-compiler/index.js +32 -35
- package/lib/utils/dom-tag-config.js +14 -0
- package/lib/web/processTemplate.js +1 -11
- package/lib/web/script-helper.js +3 -3
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -124,7 +124,6 @@ class MpxWebpackPlugin {
|
|
|
124
124
|
options.resolveMode = options.resolveMode || 'webpack'
|
|
125
125
|
options.writeMode = options.writeMode || 'changed'
|
|
126
126
|
options.autoScopeRules = options.autoScopeRules || {}
|
|
127
|
-
options.renderOptimizeRules = options.renderOptimizeRules || {}
|
|
128
127
|
options.autoVirtualHostRules = options.autoVirtualHostRules || {}
|
|
129
128
|
options.forceDisableProxyCtor = options.forceDisableProxyCtor || false
|
|
130
129
|
options.transMpxRules = options.transMpxRules || {
|
|
@@ -168,16 +167,11 @@ class MpxWebpackPlugin {
|
|
|
168
167
|
}, options.nativeConfig)
|
|
169
168
|
options.webConfig = options.webConfig || {}
|
|
170
169
|
options.partialCompile = options.mode !== 'web' && options.partialCompile
|
|
171
|
-
options.asyncSubpackageRules = options.asyncSubpackageRules ||
|
|
170
|
+
options.asyncSubpackageRules = options.asyncSubpackageRules || []
|
|
171
|
+
options.optimizeRenderRules = options.optimizeRenderRules || {}
|
|
172
172
|
options.retryRequireAsync = options.retryRequireAsync || false
|
|
173
173
|
options.enableAliRequireAsync = options.enableAliRequireAsync || false
|
|
174
174
|
options.optimizeSize = options.optimizeSize || false
|
|
175
|
-
let proxyComponentEventsRules = []
|
|
176
|
-
const proxyComponentEventsRulesRaw = options.proxyComponentEventsRules
|
|
177
|
-
if (proxyComponentEventsRulesRaw) {
|
|
178
|
-
proxyComponentEventsRules = Array.isArray(proxyComponentEventsRulesRaw) ? proxyComponentEventsRulesRaw : [proxyComponentEventsRulesRaw]
|
|
179
|
-
}
|
|
180
|
-
options.proxyComponentEventsRules = proxyComponentEventsRules
|
|
181
175
|
this.options = options
|
|
182
176
|
// Hack for buildDependencies
|
|
183
177
|
const rawResolveBuildDependencies = FileSystemInfo.prototype.resolveBuildDependencies
|
|
@@ -638,7 +632,6 @@ class MpxWebpackPlugin {
|
|
|
638
632
|
appTitle: 'Mpx homepage',
|
|
639
633
|
attributes: this.options.attributes,
|
|
640
634
|
externals: this.options.externals,
|
|
641
|
-
renderOptimizeRules: this.options.renderOptimizeRules,
|
|
642
635
|
useRelativePath: this.options.useRelativePath,
|
|
643
636
|
removedChunks: [],
|
|
644
637
|
forceProxyEventRules: this.options.forceProxyEventRules,
|
|
@@ -657,7 +650,7 @@ class MpxWebpackPlugin {
|
|
|
657
650
|
})
|
|
658
651
|
},
|
|
659
652
|
asyncSubpackageRules: this.options.asyncSubpackageRules,
|
|
660
|
-
|
|
653
|
+
optimizeRenderRules: this.options.optimizeRenderRules,
|
|
661
654
|
pathHash: (resourcePath) => {
|
|
662
655
|
if (this.options.pathHashMode === 'relative' && this.options.projectRoot) {
|
|
663
656
|
return hash(path.relative(this.options.projectRoot, resourcePath))
|
|
@@ -3,7 +3,7 @@ const normalizeTest = require('../normalize-test')
|
|
|
3
3
|
const changeKey = require('../change-key')
|
|
4
4
|
const normalize = require('../../../utils/normalize')
|
|
5
5
|
const { capitalToHyphen } = require('../../../utils/string')
|
|
6
|
-
const { isOriginTag } = require('../../../utils/dom-tag-config')
|
|
6
|
+
const { isOriginTag, isBuildInTag } = require('../../../utils/dom-tag-config')
|
|
7
7
|
|
|
8
8
|
const mpxViewPath = normalize.lib('runtime/components/ali/mpx-view.mpx')
|
|
9
9
|
const mpxTextPath = normalize.lib('runtime/components/ali/mpx-text.mpx')
|
|
@@ -127,7 +127,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
|
-
* 将小程序代码中使用的与原生 HTML tag
|
|
130
|
+
* 将小程序代码中使用的与原生 HTML tag 或 内建组件 同名的组件进行转化,以解决与原生tag命名冲突问题。
|
|
131
131
|
* @param {string} type usingComponents
|
|
132
132
|
* @returns input
|
|
133
133
|
*/
|
|
@@ -136,7 +136,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
136
136
|
const usingComponents = input[type]
|
|
137
137
|
if (usingComponents) {
|
|
138
138
|
Object.keys(usingComponents).forEach(tag => {
|
|
139
|
-
if (isOriginTag(tag)) {
|
|
139
|
+
if (isOriginTag(tag) || isBuildInTag(tag)) {
|
|
140
140
|
usingComponents[`mpx-com-${tag}`] = usingComponents[tag]
|
|
141
141
|
delete usingComponents[tag]
|
|
142
142
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const { isOriginTag } = require('../../../../utils/dom-tag-config')
|
|
1
|
+
const { isOriginTag, isBuildInTag } = require('../../../../utils/dom-tag-config')
|
|
2
2
|
|
|
3
3
|
module.exports = function () {
|
|
4
4
|
return {
|
|
5
5
|
waterfall: true,
|
|
6
|
-
test: (input) => isOriginTag(input),
|
|
6
|
+
test: (input) => isOriginTag(input) || isBuildInTag(input),
|
|
7
7
|
// 处理原生tag
|
|
8
8
|
web (tag, data = {}) {
|
|
9
9
|
// @see packages/webpack-plugin/lib/platform/json/wx/index.js webHTMLTagProcesser
|
|
@@ -355,7 +355,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
355
355
|
value
|
|
356
356
|
}
|
|
357
357
|
},
|
|
358
|
-
web ({ name, value }, { eventRules, el }) {
|
|
358
|
+
web ({ name, value }, { eventRules, el, usingComponents }) {
|
|
359
359
|
if (parseMustacheWithContext(value).hasBinding) {
|
|
360
360
|
error('Web environment does not support mustache binding in event props!')
|
|
361
361
|
return
|
|
@@ -367,10 +367,11 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
367
367
|
const meta = {
|
|
368
368
|
modifierStr
|
|
369
369
|
}
|
|
370
|
+
const isComponent = usingComponents.indexOf(el.tag) !== -1 || el.tag === 'component'
|
|
370
371
|
// 记录event监听信息用于后续判断是否需要使用内置基础组件
|
|
371
372
|
el.hasEvent = true
|
|
372
373
|
const rPrefix = runRules(spec.event.prefix, prefix, { mode: 'web', meta })
|
|
373
|
-
const rEventName = runRules(eventRules, eventName, { mode: 'web' })
|
|
374
|
+
const rEventName = runRules(eventRules, eventName, { mode: 'web', data: { isComponent } })
|
|
374
375
|
return {
|
|
375
376
|
name: rPrefix + rEventName + meta.modifierStr,
|
|
376
377
|
value
|
|
@@ -453,6 +454,16 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
453
454
|
error(`Web environment does not support [${eventName}] event!`)
|
|
454
455
|
}
|
|
455
456
|
}
|
|
457
|
+
},
|
|
458
|
+
// 特殊web事件
|
|
459
|
+
{
|
|
460
|
+
test: /^click$/,
|
|
461
|
+
web (eventName, data) {
|
|
462
|
+
// 自定义组件根节点
|
|
463
|
+
if (data.isComponent) {
|
|
464
|
+
return '_' + eventName
|
|
465
|
+
}
|
|
466
|
+
}
|
|
456
467
|
}
|
|
457
468
|
]
|
|
458
469
|
}
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
import {getCustomEvent, extendEvent} from './getInnerListeners'
|
|
11
11
|
import BScroll from '@better-scroll/core'
|
|
12
12
|
import Movable from '@better-scroll/movable'
|
|
13
|
+
import ObserveDOM from '@better-scroll/observe-dom'
|
|
13
14
|
import Zoom from '@better-scroll/zoom'
|
|
14
15
|
|
|
15
16
|
BScroll.use(Movable)
|
|
16
17
|
BScroll.use(Zoom)
|
|
18
|
+
BScroll.use(ObserveDOM)
|
|
17
19
|
|
|
18
20
|
export default {
|
|
19
21
|
data () {
|
|
@@ -23,6 +25,8 @@
|
|
|
23
25
|
maxScrollX: 0,
|
|
24
26
|
minScrollY: 0,
|
|
25
27
|
maxScrollY: 0,
|
|
28
|
+
currentX: this.x,
|
|
29
|
+
currentY: this.y,
|
|
26
30
|
lastestX: 0,
|
|
27
31
|
lastestY: 0,
|
|
28
32
|
lastestScale: 1,
|
|
@@ -30,7 +34,10 @@
|
|
|
30
34
|
isZooming: false,
|
|
31
35
|
isFirstTouch: true,
|
|
32
36
|
source: '',
|
|
33
|
-
touchEvent: ''
|
|
37
|
+
touchEvent: '',
|
|
38
|
+
isInited: false,
|
|
39
|
+
deactivatedX: 0,
|
|
40
|
+
deactivatedY: 0
|
|
34
41
|
}
|
|
35
42
|
},
|
|
36
43
|
props: {
|
|
@@ -89,7 +96,13 @@
|
|
|
89
96
|
speed: {
|
|
90
97
|
type: Number,
|
|
91
98
|
default: 1000
|
|
92
|
-
}
|
|
99
|
+
},
|
|
100
|
+
scrollOptions: {
|
|
101
|
+
type: Object,
|
|
102
|
+
default: () => {
|
|
103
|
+
return {}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
93
106
|
},
|
|
94
107
|
watch: {
|
|
95
108
|
x (newVal) {
|
|
@@ -100,6 +113,7 @@
|
|
|
100
113
|
if (newVal < this.bs.maxScrollX) {
|
|
101
114
|
newVal = this.bs.maxScrollX
|
|
102
115
|
}
|
|
116
|
+
this.currentX = newVal
|
|
103
117
|
this.bs.scrollTo(newVal, this.bs.y, this.speed)
|
|
104
118
|
},
|
|
105
119
|
y (newVal) {
|
|
@@ -110,6 +124,7 @@
|
|
|
110
124
|
if (newVal < this.bs.maxScrollY) {
|
|
111
125
|
newVal = this.bs.maxScrollY
|
|
112
126
|
}
|
|
127
|
+
this.currentY = newVal
|
|
113
128
|
this.bs.scrollTo(this.bs.x, newVal, this.speed)
|
|
114
129
|
},
|
|
115
130
|
scaleValue (newVal) {
|
|
@@ -122,22 +137,60 @@
|
|
|
122
137
|
}
|
|
123
138
|
this.bs.zoomTo(newVal, 'center', 'center')
|
|
124
139
|
},
|
|
125
|
-
disabled (
|
|
126
|
-
|
|
127
|
-
this.bs && this.bs.disable()
|
|
128
|
-
} else {
|
|
129
|
-
this.bs && this.bs.enable()
|
|
130
|
-
}
|
|
140
|
+
disabled () {
|
|
141
|
+
this.init()
|
|
131
142
|
}
|
|
132
143
|
},
|
|
133
144
|
mounted () {
|
|
145
|
+
if (!this.scrollOptions.closeResizeObserver) {
|
|
146
|
+
this.createResizeObserver()
|
|
147
|
+
}
|
|
134
148
|
this.init()
|
|
135
149
|
},
|
|
150
|
+
activated () {
|
|
151
|
+
if (this.deactivatedX || this.deactivatedY) {
|
|
152
|
+
this.refresh()
|
|
153
|
+
this.bs.putAt(this.deactivatedX, this.deactivatedY, 0)
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
deactivated () {
|
|
157
|
+
// when the hook is triggered
|
|
158
|
+
// bs will recalculate the boundary of movable to 0
|
|
159
|
+
// so record the position of the movable
|
|
160
|
+
this.deactivatedX = this.bs.x
|
|
161
|
+
this.deactivatedY = this.bs.y
|
|
162
|
+
},
|
|
136
163
|
beforeDestroy () {
|
|
137
|
-
this.
|
|
164
|
+
this.destroyBs()
|
|
165
|
+
if (this.resizeObserver) {
|
|
166
|
+
this.resizeObserver.disconnect()
|
|
167
|
+
this.resizeObserver = null
|
|
168
|
+
}
|
|
138
169
|
},
|
|
139
170
|
methods: {
|
|
171
|
+
createResizeObserver () {
|
|
172
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
173
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
174
|
+
if (!this.isInited) {
|
|
175
|
+
this.isInited = true
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
this.refresh()
|
|
179
|
+
})
|
|
180
|
+
const elementToObserve = document.querySelector('.mpx-movable-scroll-content')
|
|
181
|
+
this.resizeObserver.observe(elementToObserve)
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
refresh () {
|
|
185
|
+
this.bs && this.bs.refresh()
|
|
186
|
+
},
|
|
187
|
+
destroyBs () {
|
|
188
|
+
if (!this.bs) return
|
|
189
|
+
this.bs.destroy()
|
|
190
|
+
delete this.bs
|
|
191
|
+
},
|
|
140
192
|
init () {
|
|
193
|
+
this.destroyBs()
|
|
141
194
|
if (!this.$refs.scrollContent.parentNode || (this.$refs.scrollContent.parentNode && this.$refs.scrollContent.parentNode.className !== 'mpx-movable-scroll-wrapper')) {
|
|
142
195
|
return
|
|
143
196
|
}
|
|
@@ -150,8 +203,8 @@
|
|
|
150
203
|
scrollX: false,
|
|
151
204
|
scrollY: false,
|
|
152
205
|
movable: true,
|
|
153
|
-
startX: this.
|
|
154
|
-
startY: this.
|
|
206
|
+
startX: this.currentX,
|
|
207
|
+
startY: this.currentY,
|
|
155
208
|
bounce: this.outOfBounds,
|
|
156
209
|
bounceTime: 800 / (this.damping / 20),
|
|
157
210
|
probeType: 3,
|
|
@@ -160,7 +213,7 @@
|
|
|
160
213
|
const BehaviorHooks = this.bs.scroller.scrollBehaviorY.hooks
|
|
161
214
|
const actionsHandlerHooks = this.bs.scroller.actionsHandler.hooks
|
|
162
215
|
const scrollerHooks = this.bs.scroller.hooks
|
|
163
|
-
this.bs.putAt(this.
|
|
216
|
+
this.bs.putAt(this.currentX, this.currentY, 0)
|
|
164
217
|
this.lastestX = this.roundFun(this.x)
|
|
165
218
|
this.lastestY = this.roundFun(this.y)
|
|
166
219
|
this.lastestScale = this.roundFun(this.scaleValue)
|
|
@@ -191,6 +244,10 @@
|
|
|
191
244
|
this.lastestX = this.roundFun(position.x)
|
|
192
245
|
this.lastestY = this.roundFun(position.y)
|
|
193
246
|
})
|
|
247
|
+
scrollerHooks.on('scrollEnd', (position) =>{
|
|
248
|
+
this.currentX = this.bs.x
|
|
249
|
+
this.currentY = this.bs.y
|
|
250
|
+
})
|
|
194
251
|
scrollerHooks.on('touchEnd', (position) => {
|
|
195
252
|
this.isFirstTouch = true
|
|
196
253
|
if (position.x > this.minScrollX || position.x < this.maxScrollX ||
|
|
@@ -257,9 +314,6 @@
|
|
|
257
314
|
this.isZooming = false
|
|
258
315
|
})
|
|
259
316
|
}
|
|
260
|
-
if (this.disabled) { // 禁用
|
|
261
|
-
this.bs.disable()
|
|
262
|
-
}
|
|
263
317
|
},
|
|
264
318
|
initOptions () {
|
|
265
319
|
if (!this.friction || this.friction < 0) {
|
|
@@ -290,19 +344,24 @@
|
|
|
290
344
|
swipeTime: 50
|
|
291
345
|
}
|
|
292
346
|
}
|
|
293
|
-
if (this.
|
|
347
|
+
if (this.disabled) {
|
|
348
|
+
this.bsOptions = {
|
|
349
|
+
...this.bsOptions,
|
|
350
|
+
freeScroll: false,
|
|
351
|
+
scrollY: false,
|
|
352
|
+
scrollX: false
|
|
353
|
+
}
|
|
354
|
+
} else if (this.direction === 'vertical') {
|
|
294
355
|
this.bsOptions = {
|
|
295
356
|
...this.bsOptions,
|
|
296
357
|
scrollY: true
|
|
297
358
|
}
|
|
298
|
-
}
|
|
299
|
-
if (this.direction === 'horizontal') {
|
|
359
|
+
} else if (this.direction === 'horizontal') {
|
|
300
360
|
this.bsOptions = {
|
|
301
361
|
...this.bsOptions,
|
|
302
362
|
scrollX: true
|
|
303
363
|
}
|
|
304
|
-
}
|
|
305
|
-
if (this.direction === 'all') {
|
|
364
|
+
} else if (this.direction === 'all') {
|
|
306
365
|
this.bsOptions = {
|
|
307
366
|
...this.bsOptions,
|
|
308
367
|
freeScroll: true,
|
|
@@ -310,6 +369,10 @@
|
|
|
310
369
|
scrollY: true
|
|
311
370
|
}
|
|
312
371
|
}
|
|
372
|
+
this.bsOptions = {
|
|
373
|
+
...this.bsOptions,
|
|
374
|
+
...this.scrollOptions
|
|
375
|
+
}
|
|
313
376
|
},
|
|
314
377
|
// 处理小数点,四舍五入,默认保留一位小数
|
|
315
378
|
roundFun(value, n = 1) {
|
|
@@ -30,7 +30,12 @@
|
|
|
30
30
|
type: [Number, String],
|
|
31
31
|
default: 0
|
|
32
32
|
},
|
|
33
|
-
scrollOptions:
|
|
33
|
+
scrollOptions: {
|
|
34
|
+
type: Object,
|
|
35
|
+
default: () => {
|
|
36
|
+
return {}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
34
39
|
updateRefresh: {
|
|
35
40
|
type: Boolean,
|
|
36
41
|
default: true
|
|
@@ -57,15 +62,23 @@
|
|
|
57
62
|
data () {
|
|
58
63
|
return {
|
|
59
64
|
isLoading: false,
|
|
60
|
-
isAutoPullDown: true
|
|
65
|
+
isAutoPullDown: true,
|
|
66
|
+
currentX: 0,
|
|
67
|
+
currentY: 0,
|
|
68
|
+
lastX: 0,
|
|
69
|
+
lastY: 0
|
|
61
70
|
}
|
|
62
71
|
},
|
|
63
72
|
computed: {
|
|
64
73
|
_scrollTop () {
|
|
65
|
-
|
|
74
|
+
const size = processSize(this.scrollTop)
|
|
75
|
+
this.currentY = size
|
|
76
|
+
return size
|
|
66
77
|
},
|
|
67
78
|
_scrollLeft () {
|
|
68
|
-
|
|
79
|
+
const size = processSize(this.scrollLeft)
|
|
80
|
+
this.currentX = size
|
|
81
|
+
return size
|
|
69
82
|
},
|
|
70
83
|
_lowerThreshold () {
|
|
71
84
|
return processSize(this.lowerThreshold)
|
|
@@ -87,10 +100,13 @@
|
|
|
87
100
|
className += ' active'
|
|
88
101
|
}
|
|
89
102
|
return className
|
|
103
|
+
},
|
|
104
|
+
scroll() {
|
|
105
|
+
return this.scrollX || this.scrollY
|
|
90
106
|
}
|
|
91
107
|
},
|
|
92
108
|
mounted () {
|
|
93
|
-
this.
|
|
109
|
+
this.initBs()
|
|
94
110
|
},
|
|
95
111
|
activated () {
|
|
96
112
|
if (!this.__mpx_deactivated) {
|
|
@@ -106,7 +122,7 @@
|
|
|
106
122
|
this.__mpx_deactivated = true
|
|
107
123
|
},
|
|
108
124
|
beforeDestroy () {
|
|
109
|
-
this.
|
|
125
|
+
this.destroyBs()
|
|
110
126
|
},
|
|
111
127
|
updated () {
|
|
112
128
|
if (this.updateRefresh) this.refresh()
|
|
@@ -136,20 +152,33 @@
|
|
|
136
152
|
}
|
|
137
153
|
}
|
|
138
154
|
},
|
|
155
|
+
},
|
|
156
|
+
scroll(val) {
|
|
157
|
+
if (val) {
|
|
158
|
+
this.initBs()
|
|
159
|
+
} else {
|
|
160
|
+
this.disableBs()
|
|
161
|
+
}
|
|
139
162
|
}
|
|
140
163
|
},
|
|
141
164
|
methods: {
|
|
142
|
-
|
|
165
|
+
destroyBs () {
|
|
143
166
|
if (!this.bs) return
|
|
144
167
|
this.bs.destroy()
|
|
145
168
|
delete this.bs
|
|
146
169
|
},
|
|
147
|
-
|
|
148
|
-
if (this.bs) return
|
|
170
|
+
disableBs() {
|
|
171
|
+
if (!this.bs) return
|
|
172
|
+
this.bs.disable()
|
|
173
|
+
this.currentX = -this.bs.x
|
|
174
|
+
this.currentY = -this.bs.y
|
|
175
|
+
},
|
|
176
|
+
initBs () {
|
|
177
|
+
this.destroyBs()
|
|
149
178
|
this.initLayerComputed()
|
|
150
179
|
const originBsOptions = {
|
|
151
|
-
startX: -this.
|
|
152
|
-
startY: -this.
|
|
180
|
+
startX: -this.currentX,
|
|
181
|
+
startY: -this.currentY,
|
|
153
182
|
scrollX: this.scrollX,
|
|
154
183
|
scrollY: this.scrollY,
|
|
155
184
|
probeType: 3,
|
|
@@ -170,8 +199,8 @@
|
|
|
170
199
|
this.bs.scroller.hooks.on('beforeRefresh', () => {
|
|
171
200
|
this.initLayerComputed()
|
|
172
201
|
})
|
|
173
|
-
this.lastX = -this.
|
|
174
|
-
this.lastY = -this.
|
|
202
|
+
this.lastX = -this.currentX
|
|
203
|
+
this.lastY = -this.currentY
|
|
175
204
|
this.bs.on('scroll', throttle(({ x, y }) => {
|
|
176
205
|
const deltaX = x - this.lastX
|
|
177
206
|
const deltaY = y - this.lastY
|
|
@@ -201,6 +230,10 @@
|
|
|
201
230
|
leading: true,
|
|
202
231
|
trailing: false
|
|
203
232
|
}))
|
|
233
|
+
this.bs.on('scrollEnd', () => {
|
|
234
|
+
this.currentX = -this.bs.x
|
|
235
|
+
this.currentY = -this.bs.y
|
|
236
|
+
})
|
|
204
237
|
if (this.scrollIntoView) this.scrollToView(this.scrollIntoView)
|
|
205
238
|
// 若开启自定义下拉刷新 或 开启 scroll-view 增强特性
|
|
206
239
|
if (this.refresherEnabled || this.enhanced) {
|
|
@@ -265,8 +298,10 @@
|
|
|
265
298
|
initLayerComputed () {
|
|
266
299
|
const wrapper = this.$refs.wrapper
|
|
267
300
|
const computedStyle = getComputedStyle(wrapper)
|
|
268
|
-
|
|
269
|
-
|
|
301
|
+
// 考虑子元素样式可能会设置100%,如果直接继承 scrollContent 的样式可能会有问题
|
|
302
|
+
// 所以使用 wrapper 作为 innerWrapper 的宽高参考依据
|
|
303
|
+
this.$refs.innerWrapper.style.width = `${wrapper.clientWidth - parseInt(computedStyle.paddingLeft) - parseInt(computedStyle.paddingRight)}px`
|
|
304
|
+
this.$refs.innerWrapper.style.height = `${wrapper.clientHeight - parseInt(computedStyle.paddingTop) - parseInt(computedStyle.paddingBottom)}px`
|
|
270
305
|
const innerWrapper = this.$refs.innerWrapper
|
|
271
306
|
const childrenArr = Array.from(innerWrapper.children)
|
|
272
307
|
|