@dcloudio/uni-h5 2.0.0 → 2.0.1-32920211122002
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/dist/automator.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.umd.min.js +1 -1
- package/lib/apis.js +14 -4
- package/lib/h5/uni.automator.js +1 -1
- package/lib/modules.json +4 -1
- package/manifest.json +49 -0
- package/package.json +2 -3
- package/src/core/helpers/api.js +1 -1
- package/src/core/helpers/constants.js +1 -0
- package/src/core/helpers/i18n/en.json +4 -2
- package/src/core/helpers/i18n/es.json +4 -1
- package/src/core/helpers/i18n/fr.json +4 -1
- package/src/core/helpers/i18n/index.js +155 -4
- package/src/core/helpers/i18n/zh-Hans.json +4 -1
- package/src/core/helpers/i18n/zh-Hant.json +4 -1
- package/src/core/helpers/index.js +1 -1
- package/src/core/helpers/interceptor.js +19 -15
- package/src/core/helpers/promise.js +1 -1
- package/src/core/helpers/protocol/device/set-clipboard-data.js +11 -2
- package/src/core/helpers/protocol/network/request.js +14 -1
- package/src/core/helpers/protocol/network/upload-file.js +1 -1
- package/src/core/helpers/protocol/ui/popup.js +2 -2
- package/src/core/runtime/base.js +2 -0
- package/src/core/runtime/locale.js +37 -0
- package/src/core/runtime/web-view/index.js +4 -0
- package/src/core/runtime/wrapper/create-subpackage-app.js +7 -6
- package/src/core/runtime/wrapper/util.js +6 -1
- package/src/core/service/api/base/interceptor.js +1 -1
- package/src/core/service/api/context/canvas.js +3 -2
- package/src/core/service/api/context/create-map-context.js +8 -1
- package/src/core/service/api/ui/locale.js +50 -0
- package/src/core/service/plugins/app/create-app.js +8 -3
- package/src/core/service/plugins/app/index.js +2 -2
- package/src/core/service/plugins/index.js +8 -2
- package/src/core/view/bridge/subscribe/api/request-component-observer.js +16 -1
- package/src/core/view/components/canvas/index.vue +3 -1
- package/src/core/view/components/editor/formats/image.js +3 -1
- package/src/core/view/components/editor/formats/index.js +3 -1
- package/src/core/view/components/editor/formats/link.js +9 -0
- package/src/core/view/components/editor/index.vue +33 -3
- package/src/core/view/components/image/index.vue +4 -5
- package/src/core/view/components/input/index.vue +53 -25
- package/src/core/view/components/picker-view-column/index.vue +1 -0
- package/src/core/view/components/progress/index.vue +20 -13
- package/src/core/view/components/rich-text/index.vue +13 -1
- package/src/core/view/components/rich-text/nodes-parser.js +23 -4
- package/src/core/view/components/scroll-view/index.vue +253 -122
- package/src/core/view/components/slider/index.vue +1 -1
- package/src/core/view/components/swiper/index.vue +3 -0
- package/src/core/view/components/textarea/index.vue +7 -3
- package/src/core/view/index.css +4 -0
- package/src/core/view/mixins/field.js +27 -9
- package/src/core/view/mixins/interact.js +13 -11
- package/src/core/view/mixins/keyboard.js +42 -26
- package/src/core/view/mixins/touchtrack.js +2 -2
- package/src/core/view/plugins/index.js +1 -1
- package/src/platforms/app-plus/constants.js +1 -0
- package/src/platforms/app-plus/helpers/get-real-path.js +7 -4
- package/src/platforms/app-plus/helpers/uuid.js +1 -1
- package/src/platforms/app-plus/service/api/ad/ad-base.js +159 -0
- package/src/platforms/app-plus/service/api/ad/ad.js +4 -8
- package/src/platforms/app-plus/service/api/ad/full-screen-video-ad.js +5 -98
- package/src/platforms/app-plus/service/api/ad/interactive-ad.js +257 -0
- package/src/platforms/app-plus/service/api/ad/interstitial-ad.js +15 -0
- package/src/platforms/app-plus/service/api/ad/rewarded-video-ad.js +15 -2
- package/src/platforms/app-plus/service/api/device/system.js +3 -2
- package/src/platforms/app-plus/service/api/file/open-document.js +7 -15
- package/src/platforms/app-plus/service/api/index.js +2 -0
- package/src/platforms/app-plus/service/api/location/get-location.js +8 -7
- package/src/platforms/app-plus/service/api/media/choose-image.js +22 -51
- package/src/platforms/app-plus/service/api/media/choose-video.js +19 -36
- package/src/platforms/app-plus/service/api/media/compress-video.js +2 -2
- package/src/platforms/app-plus/service/api/media/get-video-info.js +5 -2
- package/src/platforms/app-plus/service/api/network/request.js +27 -1
- package/src/platforms/app-plus/service/api/network/upload-file.js +1 -1
- package/src/platforms/app-plus/service/api/plugin/oauth.js +140 -8
- package/src/platforms/app-plus/service/api/storage/storage.js +1 -1
- package/src/platforms/app-plus/service/api/ui/popup.js +21 -11
- package/src/platforms/app-plus/service/api/ui/tab-bar.js +3 -2
- package/src/platforms/app-plus/service/api/util.js +5 -1
- package/src/platforms/app-plus/service/framework/app.js +21 -5
- package/src/platforms/app-plus/service/framework/config.js +1 -0
- package/src/platforms/app-plus/service/framework/plugins/index.js +8 -2
- package/src/platforms/app-plus/service/framework/plugins/lifecycle.js +2 -2
- package/src/platforms/app-plus/service/framework/subscribe-handlers/index.js +1 -1
- package/src/platforms/app-plus/service/framework/tab-bar.js +12 -2
- package/src/platforms/app-plus/service/framework/webview/index.js +2 -2
- package/src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js +73 -30
- package/src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js +16 -16
- package/src/platforms/app-plus/service/index.js +10 -3
- package/src/platforms/app-plus/service/publish-handler.js +3 -0
- package/src/platforms/app-plus/view/bridge/subscribe/index.js +5 -3
- package/src/platforms/app-plus/view/components/ad/index.vue +53 -44
- package/src/platforms/app-plus/view/components/cover-view/index.vue +13 -7
- package/src/platforms/app-plus/view/components/map/index.vue +29 -27
- package/src/platforms/app-plus/view/components/video/index.vue +40 -24
- package/src/platforms/app-plus/view/framework/plugins/gesture.js +17 -0
- package/src/platforms/app-plus/view/framework/plugins/index.js +3 -1
- package/src/platforms/app-plus/view/index.css +4 -0
- package/src/platforms/app-plus/view/mixins/cover.js +10 -15
- package/src/platforms/app-plus/view/mixins/native.js +45 -3
- package/src/platforms/app-plus-nvue/service/api/context/operate-map-player.js +3 -0
- package/src/platforms/h5/components/app/observable.js +3 -2
- package/src/platforms/h5/components/app/popup/mixins/modal.js +3 -3
- package/src/platforms/h5/components/app/popup/modal.vue +38 -2
- package/src/platforms/h5/components/app/popup/toast.vue +9 -1
- package/src/platforms/h5/components/app/tabBar.vue +39 -17
- package/src/platforms/h5/components/page/index.vue +5 -3
- package/src/platforms/h5/components/page/pageHead.vue +94 -75
- package/src/platforms/h5/components/system-routes/choose-location/index.vue +127 -66
- package/src/platforms/h5/components/system-routes/open-location/index.vue +193 -38
- package/src/platforms/h5/helpers/location.js +26 -0
- package/src/platforms/h5/helpers/todo-api.js +2 -2
- package/src/platforms/h5/service/api/device/clipboard.js +41 -0
- package/src/platforms/h5/service/api/device/get-system-info.js +75 -0
- package/src/platforms/h5/service/api/location/get-location.js +47 -18
- package/src/platforms/h5/service/api/media/MIMEType.js +53 -0
- package/src/platforms/h5/service/api/media/choose-file.js +9 -1
- package/src/platforms/h5/service/api/media/choose-image.js +9 -2
- package/src/platforms/h5/service/api/media/choose-video.js +9 -1
- package/src/platforms/h5/service/api/media/create_input.js +12 -3
- package/src/platforms/h5/service/api/ui/popup.js +3 -5
- package/src/platforms/h5/service/api/ui/tab-bar.js +1 -1
- package/src/platforms/h5/service/index.js +5 -0
- package/src/platforms/h5/view/bridge/subscribe/index.js +3 -2
- package/src/platforms/h5/view/components/ad/index.vue +112 -69
- package/src/platforms/h5/view/components/map/index.vue +96 -349
- package/src/platforms/h5/view/components/map/map-marker.js +287 -0
- package/src/platforms/h5/view/components/map/maps/callout.js +117 -0
- package/src/platforms/h5/view/components/map/maps/index.js +55 -0
- package/src/platforms/h5/view/components/video/index.vue +1 -1
- package/src/platforms/h5/view/index.css +4 -0
- package/src/platforms/mp-alipay/runtime/api/protocols.js +30 -3
- package/src/platforms/mp-baidu/runtime/api/protocols.js +5 -0
- package/src/platforms/mp-baidu/runtime/wrapper/component-parser.js +20 -18
- package/src/platforms/mp-baidu/runtime/wrapper/util.js +2 -1
- package/src/platforms/mp-kuaishou/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js +21 -1
- package/src/platforms/mp-lark/runtime/api/index.js +0 -0
- package/src/platforms/mp-lark/runtime/api/protocols.js +68 -0
- package/src/platforms/mp-lark/runtime/api/providers.js +6 -0
- package/src/platforms/mp-lark/runtime/index.js +1 -0
- package/src/platforms/mp-lark/runtime/web-view.js +11 -0
- package/src/platforms/mp-lark/runtime/wrapper/app-parser.js +33 -0
- package/src/platforms/mp-lark/runtime/wrapper/component-parser.js +50 -0
- package/src/platforms/mp-lark/runtime/wrapper/page-parser.js +39 -0
- package/src/platforms/mp-lark/runtime/wrapper/util.js +64 -0
- package/src/platforms/mp-qq/runtime/api/protocols.js +3 -1
- package/src/platforms/mp-toutiao/runtime/api/protocols.js +2 -0
- package/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js +35 -19
- package/src/platforms/mp-weixin/helpers/get-user-profile.js +6 -0
- package/src/platforms/mp-weixin/runtime/index.js +6 -7
- package/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js +197 -126
- package/src/platforms/mp-weixin/runtime/wrapper/fix-set-data.js +37 -0
- package/src/shared/uni-id-mixin.js +77 -0
- package/src/shared/util.js +2 -0
|
@@ -32,13 +32,22 @@ export default {
|
|
|
32
32
|
},
|
|
33
33
|
methods: {
|
|
34
34
|
_renderNodes (nodes) {
|
|
35
|
+
let scopeId = ''
|
|
36
|
+
let $vm = this
|
|
37
|
+
while ($vm) {
|
|
38
|
+
!scopeId && (scopeId = $vm.$options._scopeId)
|
|
39
|
+
$vm = $vm.$parent
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const hasItemClick = !!this.$listeners.itemclick
|
|
43
|
+
|
|
35
44
|
if (!this._isMounted) {
|
|
36
45
|
return
|
|
37
46
|
}
|
|
38
47
|
if (typeof nodes === 'string') {
|
|
39
48
|
nodes = parseHtml(nodes)
|
|
40
49
|
}
|
|
41
|
-
const nodeList = parseNodes(nodes, document.createDocumentFragment())
|
|
50
|
+
const nodeList = parseNodes(nodes, document.createDocumentFragment(), scopeId, hasItemClick && this.triggerItemClick)
|
|
42
51
|
nodeList.appendChild(this.$refs.sensor.$el)
|
|
43
52
|
const content = this.$refs.content
|
|
44
53
|
content.innerHTML = ''
|
|
@@ -46,6 +55,9 @@ export default {
|
|
|
46
55
|
},
|
|
47
56
|
_updateView () {
|
|
48
57
|
window.dispatchEvent(new CustomEvent('updateview'))
|
|
58
|
+
},
|
|
59
|
+
triggerItemClick (e, detail = {}) {
|
|
60
|
+
this.$trigger('itemclick', e, detail)
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
63
|
}
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
hasOwn,
|
|
3
3
|
isPlainObject
|
|
4
4
|
} from 'uni-shared'
|
|
5
|
+
import getRealPath from 'uni-platform/helpers/get-real-path'
|
|
5
6
|
|
|
6
7
|
const TAGS = {
|
|
7
8
|
a: '',
|
|
@@ -96,7 +97,12 @@ function decodeEntities (htmlString) {
|
|
|
96
97
|
})
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
|
|
100
|
+
function normlizeValue (tagName, name, value) {
|
|
101
|
+
if (tagName === 'img' && name === 'src') return getRealPath(value)
|
|
102
|
+
return value
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default function parseNodes (nodes, parentNode, scopeId, triggerItemClick) {
|
|
100
106
|
nodes.forEach(function (node) {
|
|
101
107
|
if (!isPlainObject(node)) {
|
|
102
108
|
return
|
|
@@ -124,18 +130,21 @@ export default function parseNodes (nodes, parentNode) {
|
|
|
124
130
|
Array.isArray(value) && (value = value.join(' '))
|
|
125
131
|
case 'style':
|
|
126
132
|
elem.setAttribute(name, value)
|
|
133
|
+
scopeId && elem.setAttribute(scopeId, '')
|
|
127
134
|
break
|
|
128
135
|
default:
|
|
129
136
|
if (tagAttrs.indexOf(name) !== -1) {
|
|
130
|
-
elem.setAttribute(name, value)
|
|
137
|
+
elem.setAttribute(name, normlizeValue(tagName, name, value))
|
|
131
138
|
}
|
|
132
139
|
}
|
|
133
140
|
})
|
|
134
141
|
}
|
|
135
142
|
|
|
143
|
+
processClickEvent(node, elem, triggerItemClick)
|
|
144
|
+
|
|
136
145
|
const children = node.children
|
|
137
146
|
if (Array.isArray(children) && children.length) {
|
|
138
|
-
parseNodes(node.children, elem)
|
|
147
|
+
parseNodes(node.children, elem, scopeId, triggerItemClick)
|
|
139
148
|
}
|
|
140
149
|
|
|
141
150
|
parentNode.appendChild(elem)
|
|
@@ -146,4 +155,14 @@ export default function parseNodes (nodes, parentNode) {
|
|
|
146
155
|
}
|
|
147
156
|
})
|
|
148
157
|
return parentNode
|
|
149
|
-
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function processClickEvent (node, elem, triggerItemClick) {
|
|
161
|
+
if (['a', 'img'].includes(node.name) && triggerItemClick) {
|
|
162
|
+
elem.setAttribute('onClick', 'return false;')
|
|
163
|
+
elem.addEventListener('click', (e) => {
|
|
164
|
+
triggerItemClick(e, { node })
|
|
165
|
+
e.stopPropagation()
|
|
166
|
+
}, true)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
>
|
|
7
7
|
<div
|
|
8
8
|
ref="main"
|
|
9
|
-
:style="{
|
|
9
|
+
:style="{
|
|
10
|
+
'overflow-x': scrollX ? 'auto' : 'hidden',
|
|
11
|
+
'overflow-y': scrollY ? 'auto' : 'hidden',
|
|
12
|
+
}"
|
|
10
13
|
class="uni-scroll-view"
|
|
11
14
|
>
|
|
12
15
|
<div
|
|
@@ -16,7 +19,10 @@
|
|
|
16
19
|
<div
|
|
17
20
|
v-if="refresherEnabled"
|
|
18
21
|
ref="refresherinner"
|
|
19
|
-
:style="{
|
|
22
|
+
:style="{
|
|
23
|
+
'background-color': refresherBackground,
|
|
24
|
+
height: refresherHeight + 'px',
|
|
25
|
+
}"
|
|
20
26
|
class="uni-scroll-view-refresher"
|
|
21
27
|
>
|
|
22
28
|
<div
|
|
@@ -25,22 +31,26 @@
|
|
|
25
31
|
>
|
|
26
32
|
<div class="uni-scroll-view-refresh-inner">
|
|
27
33
|
<svg
|
|
28
|
-
v-if="refreshState=='pulling'"
|
|
29
|
-
|
|
34
|
+
v-if="refreshState == 'pulling'"
|
|
35
|
+
key="refresh__icon"
|
|
36
|
+
:style="{ transform: 'rotate(' + refreshRotate + 'deg)' }"
|
|
30
37
|
fill="#2BD009"
|
|
31
38
|
class="uni-scroll-view-refresh__icon"
|
|
32
39
|
width="24"
|
|
33
40
|
height="24"
|
|
34
41
|
viewBox="0 0 24 24"
|
|
35
42
|
>
|
|
36
|
-
<path
|
|
43
|
+
<path
|
|
44
|
+
d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"
|
|
45
|
+
/>
|
|
37
46
|
<path
|
|
38
47
|
d="M0 0h24v24H0z"
|
|
39
48
|
fill="none"
|
|
40
49
|
/>
|
|
41
50
|
</svg>
|
|
42
51
|
<svg
|
|
43
|
-
v-if="refreshState=='refreshing'"
|
|
52
|
+
v-if="refreshState == 'refreshing'"
|
|
53
|
+
key="refresh__spinner"
|
|
44
54
|
class="uni-scroll-view-refresh__spinner"
|
|
45
55
|
width="24"
|
|
46
56
|
height="24"
|
|
@@ -51,14 +61,14 @@
|
|
|
51
61
|
cy="50"
|
|
52
62
|
r="20"
|
|
53
63
|
fill="none"
|
|
54
|
-
style="color: #
|
|
64
|
+
style="color: #2bd009"
|
|
55
65
|
stroke-width="3"
|
|
56
66
|
/>
|
|
57
67
|
</svg>
|
|
58
68
|
</div>
|
|
59
69
|
</div>
|
|
60
70
|
<slot
|
|
61
|
-
v-if="refresherDefaultStyle=='none'"
|
|
71
|
+
v-if="refresherDefaultStyle == 'none'"
|
|
62
72
|
name="refresher"
|
|
63
73
|
/>
|
|
64
74
|
</div>
|
|
@@ -70,17 +80,17 @@
|
|
|
70
80
|
</template>
|
|
71
81
|
<script>
|
|
72
82
|
import scroller from 'uni-mixins/scroller/index'
|
|
73
|
-
import {
|
|
74
|
-
supportsPassive
|
|
75
|
-
} from 'uni-shared'
|
|
83
|
+
import { supportsPassive } from 'uni-shared'
|
|
76
84
|
import {
|
|
77
85
|
initScrollBounce,
|
|
78
86
|
disableScrollBounce
|
|
79
87
|
} from 'uni-platform/helpers/scroll'
|
|
80
88
|
|
|
81
|
-
const passiveOptions = supportsPassive
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
const passiveOptions = supportsPassive
|
|
90
|
+
? {
|
|
91
|
+
passive: true
|
|
92
|
+
}
|
|
93
|
+
: false
|
|
84
94
|
|
|
85
95
|
// const PULLING = 'pulling'
|
|
86
96
|
// const REFRESHING = 'refreshing'
|
|
@@ -194,7 +204,14 @@ export default {
|
|
|
194
204
|
},
|
|
195
205
|
mounted () {
|
|
196
206
|
var self = this
|
|
207
|
+
var touchStart = null
|
|
208
|
+
var needStop = null
|
|
209
|
+
|
|
197
210
|
this._attached = true
|
|
211
|
+
this.toUpperNumber = 0 // 容器触顶时,此时鼠标Y轴位置
|
|
212
|
+
this.triggerAbort = false
|
|
213
|
+
this.beforeRefreshing = false
|
|
214
|
+
|
|
198
215
|
this._scrollTopChanged(this.scrollTopNumber)
|
|
199
216
|
this._scrollLeftChanged(this.scrollLeftNumber)
|
|
200
217
|
this._scrollIntoViewChanged(this.scrollIntoView)
|
|
@@ -203,62 +220,83 @@ export default {
|
|
|
203
220
|
event.stopPropagation()
|
|
204
221
|
self._handleScroll.bind(self, event)()
|
|
205
222
|
}
|
|
206
|
-
|
|
207
|
-
var needStop = null
|
|
223
|
+
|
|
208
224
|
this.__handleTouchMove = function (event) {
|
|
209
225
|
var x = event.touches[0].pageX
|
|
210
226
|
var y = event.touches[0].pageY
|
|
211
227
|
var main = self.$refs.main
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
needStop = true
|
|
224
|
-
} else {
|
|
228
|
+
|
|
229
|
+
if (Math.abs(x - touchStart.x) > Math.abs(y - touchStart.y)) {
|
|
230
|
+
// 横向滑动
|
|
231
|
+
if (self.scrollX) {
|
|
232
|
+
if (main.scrollLeft === 0 && x > touchStart.x) {
|
|
233
|
+
needStop = false
|
|
234
|
+
return
|
|
235
|
+
} else if (
|
|
236
|
+
main.scrollWidth === main.offsetWidth + main.scrollLeft &&
|
|
237
|
+
x < touchStart.x
|
|
238
|
+
) {
|
|
225
239
|
needStop = false
|
|
240
|
+
return
|
|
226
241
|
}
|
|
242
|
+
needStop = true
|
|
227
243
|
} else {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
244
|
+
needStop = false
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
// 纵向滑动
|
|
248
|
+
if (self.scrollY) {
|
|
249
|
+
if (main.scrollTop === 0 && y > touchStart.y) {
|
|
250
|
+
needStop = false
|
|
251
|
+
// 刷新时,阻止页面滚动
|
|
252
|
+
if (self.refresherEnabled && event.cancelable !== false) {
|
|
253
|
+
event.preventDefault()
|
|
236
254
|
}
|
|
237
|
-
|
|
238
|
-
|
|
255
|
+
} else if (
|
|
256
|
+
main.scrollHeight === main.offsetHeight + main.scrollTop &&
|
|
257
|
+
y < touchStart.y
|
|
258
|
+
) {
|
|
239
259
|
needStop = false
|
|
260
|
+
return
|
|
261
|
+
} else {
|
|
262
|
+
needStop = true
|
|
240
263
|
}
|
|
264
|
+
} else {
|
|
265
|
+
needStop = false
|
|
241
266
|
}
|
|
242
267
|
}
|
|
268
|
+
|
|
243
269
|
if (needStop) {
|
|
244
270
|
event.stopPropagation()
|
|
245
271
|
}
|
|
246
272
|
|
|
273
|
+
if (main.scrollTop === 0 && event.touches.length === 1) {
|
|
274
|
+
// 如果容器滑动到达顶端,则进入下拉状态
|
|
275
|
+
self.refreshState = 'pulling'
|
|
276
|
+
}
|
|
277
|
+
|
|
247
278
|
if (self.refresherEnabled && self.refreshState === 'pulling') {
|
|
248
279
|
const dy = y - touchStart.y
|
|
249
|
-
self.
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if (
|
|
253
|
-
|
|
280
|
+
if (self.toUpperNumber === 0) {
|
|
281
|
+
self.toUpperNumber = y
|
|
282
|
+
}
|
|
283
|
+
if (!self.beforeRefreshing) {
|
|
284
|
+
self.refresherHeight = y - self.toUpperNumber
|
|
285
|
+
// 之前为刷新状态则不再触发pulling
|
|
286
|
+
if (self.refresherHeight > 0) {
|
|
287
|
+
self.triggerAbort = true
|
|
288
|
+
self.$trigger('refresherpulling', event, {
|
|
289
|
+
deltaY: dy
|
|
290
|
+
})
|
|
291
|
+
}
|
|
254
292
|
} else {
|
|
255
|
-
|
|
293
|
+
self.refresherHeight = dy + self.refresherThreshold
|
|
294
|
+
// 如果之前在刷新状态,则不触发刷新中断
|
|
295
|
+
self.triggerAbort = false
|
|
256
296
|
}
|
|
257
|
-
self.refreshRotate = rotate
|
|
258
297
|
|
|
259
|
-
self
|
|
260
|
-
|
|
261
|
-
})
|
|
298
|
+
const route = self.refresherHeight / self.refresherThreshold
|
|
299
|
+
self.refreshRotate = (route > 1 ? 1 : route) * 360
|
|
262
300
|
}
|
|
263
301
|
}
|
|
264
302
|
|
|
@@ -267,14 +305,10 @@ export default {
|
|
|
267
305
|
disableScrollBounce({
|
|
268
306
|
disable: true
|
|
269
307
|
})
|
|
270
|
-
needStop = null
|
|
271
308
|
touchStart = {
|
|
272
309
|
x: event.touches[0].pageX,
|
|
273
310
|
y: event.touches[0].pageY
|
|
274
311
|
}
|
|
275
|
-
if (self.refresherEnabled && self.refreshState !== 'refreshing' && self.$refs.main.scrollTop === 0) {
|
|
276
|
-
self.refreshState = 'pulling'
|
|
277
|
-
}
|
|
278
312
|
}
|
|
279
313
|
}
|
|
280
314
|
this.__handleTouchEnd = function (event) {
|
|
@@ -285,16 +319,29 @@ export default {
|
|
|
285
319
|
if (self.refresherHeight >= self.refresherThreshold) {
|
|
286
320
|
self._setRefreshState('refreshing')
|
|
287
321
|
} else {
|
|
288
|
-
self.
|
|
289
|
-
self.$trigger('refresherabort', event, {})
|
|
322
|
+
self._setRefreshState('refresherabort')
|
|
290
323
|
}
|
|
291
324
|
}
|
|
292
|
-
this.$refs.main.addEventListener(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
this.$refs.main.addEventListener('
|
|
325
|
+
this.$refs.main.addEventListener(
|
|
326
|
+
'touchstart',
|
|
327
|
+
this.__handleTouchStart,
|
|
328
|
+
passiveOptions
|
|
329
|
+
)
|
|
330
|
+
this.$refs.main.addEventListener('touchmove', this.__handleTouchMove)
|
|
331
|
+
this.$refs.main.addEventListener(
|
|
332
|
+
'scroll',
|
|
333
|
+
this.__handleScroll,
|
|
334
|
+
supportsPassive
|
|
335
|
+
? {
|
|
336
|
+
passive: false
|
|
337
|
+
}
|
|
338
|
+
: false
|
|
339
|
+
)
|
|
340
|
+
this.$refs.main.addEventListener(
|
|
341
|
+
'touchend',
|
|
342
|
+
this.__handleTouchEnd,
|
|
343
|
+
passiveOptions
|
|
344
|
+
)
|
|
298
345
|
initScrollBounce()
|
|
299
346
|
},
|
|
300
347
|
activated () {
|
|
@@ -303,34 +350,70 @@ export default {
|
|
|
303
350
|
this.scrollX && (this.$refs.main.scrollLeft = this.lastScrollLeft)
|
|
304
351
|
},
|
|
305
352
|
beforeDestroy () {
|
|
306
|
-
this.$refs.main.removeEventListener(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
this.$refs.main.removeEventListener(
|
|
353
|
+
this.$refs.main.removeEventListener(
|
|
354
|
+
'touchstart',
|
|
355
|
+
this.__handleTouchStart,
|
|
356
|
+
passiveOptions
|
|
357
|
+
)
|
|
358
|
+
this.$refs.main.removeEventListener(
|
|
359
|
+
'touchmove',
|
|
360
|
+
this.__handleTouchMove,
|
|
361
|
+
passiveOptions
|
|
362
|
+
)
|
|
363
|
+
this.$refs.main.removeEventListener(
|
|
364
|
+
'scroll',
|
|
365
|
+
this.__handleScroll,
|
|
366
|
+
supportsPassive
|
|
367
|
+
? {
|
|
368
|
+
passive: false
|
|
369
|
+
}
|
|
370
|
+
: false
|
|
371
|
+
)
|
|
372
|
+
this.$refs.main.removeEventListener(
|
|
373
|
+
'touchend',
|
|
374
|
+
this.__handleTouchEnd,
|
|
375
|
+
passiveOptions
|
|
376
|
+
)
|
|
312
377
|
},
|
|
313
378
|
methods: {
|
|
314
379
|
scrollTo: function (t, n) {
|
|
315
380
|
var i = this.$refs.main
|
|
316
|
-
t < 0
|
|
317
|
-
|
|
381
|
+
t < 0
|
|
382
|
+
? (t = 0)
|
|
383
|
+
: n === 'x' && t > i.scrollWidth - i.offsetWidth
|
|
384
|
+
? (t = i.scrollWidth - i.offsetWidth)
|
|
385
|
+
: n === 'y' &&
|
|
386
|
+
t > i.scrollHeight - i.offsetHeight &&
|
|
387
|
+
(t = i.scrollHeight - i.offsetHeight)
|
|
318
388
|
var r = 0
|
|
319
389
|
var o = ''
|
|
320
|
-
n === 'x' ? r = i.scrollLeft - t : n === 'y' && (r = i.scrollTop - t)
|
|
390
|
+
n === 'x' ? (r = i.scrollLeft - t) : n === 'y' && (r = i.scrollTop - t)
|
|
321
391
|
if (r !== 0) {
|
|
322
392
|
this.$refs.content.style.transition = 'transform .3s ease-out'
|
|
323
|
-
this.$refs.content.style.webkitTransition =
|
|
393
|
+
this.$refs.content.style.webkitTransition =
|
|
394
|
+
'-webkit-transform .3s ease-out'
|
|
324
395
|
if (n === 'x') {
|
|
325
396
|
o = 'translateX(' + r + 'px) translateZ(0)'
|
|
326
397
|
} else {
|
|
327
398
|
n === 'y' && (o = 'translateY(' + r + 'px) translateZ(0)')
|
|
328
399
|
}
|
|
329
|
-
this.$refs.content.removeEventListener(
|
|
330
|
-
|
|
400
|
+
this.$refs.content.removeEventListener(
|
|
401
|
+
'transitionend',
|
|
402
|
+
this.__transitionEnd
|
|
403
|
+
)
|
|
404
|
+
this.$refs.content.removeEventListener(
|
|
405
|
+
'webkitTransitionEnd',
|
|
406
|
+
this.__transitionEnd
|
|
407
|
+
)
|
|
331
408
|
this.__transitionEnd = this._transitionEnd.bind(this, t, n)
|
|
332
|
-
this.$refs.content.addEventListener(
|
|
333
|
-
|
|
409
|
+
this.$refs.content.addEventListener(
|
|
410
|
+
'transitionend',
|
|
411
|
+
this.__transitionEnd
|
|
412
|
+
)
|
|
413
|
+
this.$refs.content.addEventListener(
|
|
414
|
+
'webkitTransitionEnd',
|
|
415
|
+
this.__transitionEnd
|
|
416
|
+
)
|
|
334
417
|
if (n === 'x') {
|
|
335
418
|
// if (e !== 'ios') {
|
|
336
419
|
i.style.overflowX = 'hidden'
|
|
@@ -354,14 +437,22 @@ export default {
|
|
|
354
437
|
this._noBubble = false
|
|
355
438
|
}
|
|
356
439
|
if (this._noBubble === null && this.scrollY) {
|
|
357
|
-
if (
|
|
440
|
+
if (
|
|
441
|
+
Math.abs(this._y - $event.detail.y) /
|
|
442
|
+
Math.abs(this._x - $event.detail.x) >
|
|
443
|
+
1
|
|
444
|
+
) {
|
|
358
445
|
this._noBubble = true
|
|
359
446
|
} else {
|
|
360
447
|
this._noBubble = false
|
|
361
448
|
}
|
|
362
449
|
}
|
|
363
450
|
if (this._noBubble === null && this.scrollX) {
|
|
364
|
-
if (
|
|
451
|
+
if (
|
|
452
|
+
Math.abs(this._x - $event.detail.x) /
|
|
453
|
+
Math.abs(this._y - $event.detail.y) >
|
|
454
|
+
1
|
|
455
|
+
) {
|
|
365
456
|
this._noBubble = true
|
|
366
457
|
} else {
|
|
367
458
|
this._noBubble = false
|
|
@@ -374,48 +465,67 @@ export default {
|
|
|
374
465
|
}
|
|
375
466
|
},
|
|
376
467
|
_handleScroll: function ($event) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
this.$trigger('scrolltolower', $event, {
|
|
397
|
-
direction: 'bottom'
|
|
398
|
-
})
|
|
399
|
-
this.lastScrollToLowerTime = $event.timeStamp
|
|
400
|
-
}
|
|
468
|
+
const target = $event.target
|
|
469
|
+
this.$trigger('scroll', $event, {
|
|
470
|
+
scrollLeft: target.scrollLeft,
|
|
471
|
+
scrollTop: target.scrollTop,
|
|
472
|
+
scrollHeight: target.scrollHeight,
|
|
473
|
+
scrollWidth: target.scrollWidth,
|
|
474
|
+
deltaX: this.lastScrollLeft - target.scrollLeft,
|
|
475
|
+
deltaY: this.lastScrollTop - target.scrollTop
|
|
476
|
+
})
|
|
477
|
+
if (this.scrollY) {
|
|
478
|
+
if (
|
|
479
|
+
target.scrollTop <= this.upperThresholdNumber &&
|
|
480
|
+
this.lastScrollTop - target.scrollTop > 0 &&
|
|
481
|
+
$event.timeStamp - this.lastScrollToUpperTime > 200
|
|
482
|
+
) {
|
|
483
|
+
this.$trigger('scrolltoupper', $event, {
|
|
484
|
+
direction: 'top'
|
|
485
|
+
})
|
|
486
|
+
this.lastScrollToUpperTime = $event.timeStamp
|
|
401
487
|
}
|
|
402
|
-
if (
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
488
|
+
if (
|
|
489
|
+
target.scrollTop +
|
|
490
|
+
target.offsetHeight +
|
|
491
|
+
this.lowerThresholdNumber >=
|
|
492
|
+
target.scrollHeight &&
|
|
493
|
+
this.lastScrollTop - target.scrollTop < 0 &&
|
|
494
|
+
$event.timeStamp - this.lastScrollToLowerTime > 200
|
|
495
|
+
) {
|
|
496
|
+
this.$trigger('scrolltolower', $event, {
|
|
497
|
+
direction: 'bottom'
|
|
498
|
+
})
|
|
499
|
+
this.lastScrollToLowerTime = $event.timeStamp
|
|
415
500
|
}
|
|
416
|
-
this.lastScrollTop = target.scrollTop
|
|
417
|
-
this.lastScrollLeft = target.scrollLeft
|
|
418
501
|
}
|
|
502
|
+
if (this.scrollX) {
|
|
503
|
+
if (
|
|
504
|
+
target.scrollLeft <= this.upperThresholdNumber &&
|
|
505
|
+
this.lastScrollLeft - target.scrollLeft > 0 &&
|
|
506
|
+
$event.timeStamp - this.lastScrollToUpperTime > 200
|
|
507
|
+
) {
|
|
508
|
+
this.$trigger('scrolltoupper', $event, {
|
|
509
|
+
direction: 'left'
|
|
510
|
+
})
|
|
511
|
+
this.lastScrollToUpperTime = $event.timeStamp
|
|
512
|
+
}
|
|
513
|
+
if (
|
|
514
|
+
target.scrollLeft +
|
|
515
|
+
target.offsetWidth +
|
|
516
|
+
this.lowerThresholdNumber >=
|
|
517
|
+
target.scrollWidth &&
|
|
518
|
+
this.lastScrollLeft - target.scrollLeft < 0 &&
|
|
519
|
+
$event.timeStamp - this.lastScrollToLowerTime > 200
|
|
520
|
+
) {
|
|
521
|
+
this.$trigger('scrolltolower', $event, {
|
|
522
|
+
direction: 'right'
|
|
523
|
+
})
|
|
524
|
+
this.lastScrollToLowerTime = $event.timeStamp
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
this.lastScrollTop = target.scrollTop
|
|
528
|
+
this.lastScrollLeft = target.scrollLeft
|
|
419
529
|
},
|
|
420
530
|
_scrollTopChanged: function (val) {
|
|
421
531
|
if (this.scrollY) {
|
|
@@ -489,18 +599,38 @@ export default {
|
|
|
489
599
|
main.style.overflowY = this.scrollY ? 'auto' : 'hidden'
|
|
490
600
|
main.scrollTop = val
|
|
491
601
|
}
|
|
492
|
-
this.$refs.content.removeEventListener(
|
|
493
|
-
|
|
602
|
+
this.$refs.content.removeEventListener(
|
|
603
|
+
'transitionend',
|
|
604
|
+
this.__transitionEnd
|
|
605
|
+
)
|
|
606
|
+
this.$refs.content.removeEventListener(
|
|
607
|
+
'webkitTransitionEnd',
|
|
608
|
+
this.__transitionEnd
|
|
609
|
+
)
|
|
494
610
|
},
|
|
495
611
|
_setRefreshState (state) {
|
|
496
612
|
switch (state) {
|
|
497
613
|
case 'refreshing':
|
|
498
614
|
this.refresherHeight = this.refresherThreshold
|
|
499
|
-
|
|
615
|
+
// 之前是刷新状态则不再触发刷新
|
|
616
|
+
if (!this.beforeRefreshing) {
|
|
617
|
+
this.beforeRefreshing = true
|
|
618
|
+
this.$trigger('refresherrefresh', {}, {})
|
|
619
|
+
// this.$emit('update:refresherTriggered', true)
|
|
620
|
+
}
|
|
500
621
|
break
|
|
501
622
|
case 'restore':
|
|
502
|
-
|
|
503
|
-
this
|
|
623
|
+
case 'refresherabort':
|
|
624
|
+
this.beforeRefreshing = false
|
|
625
|
+
this.refresherHeight = this.toUpperNumber = 0
|
|
626
|
+
if (state === 'restore') {
|
|
627
|
+
this.triggerAbort = false
|
|
628
|
+
this.$trigger('refresherrestore', {}, {})
|
|
629
|
+
}
|
|
630
|
+
if (state === 'refresherabort' && this.triggerAbort) {
|
|
631
|
+
this.triggerAbort = false
|
|
632
|
+
this.$trigger('refresherabort', {}, {})
|
|
633
|
+
}
|
|
504
634
|
break
|
|
505
635
|
}
|
|
506
636
|
this.refreshState = state
|
|
@@ -567,7 +697,8 @@ uni-scroll-view[hidden] {
|
|
|
567
697
|
height: 40px;
|
|
568
698
|
border-radius: 50%;
|
|
569
699
|
background-color: #fff;
|
|
570
|
-
box-shadow: 0 1px 6px rgba(0, 0, 0, .117647),
|
|
700
|
+
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.117647),
|
|
701
|
+
0 1px 4px rgba(0, 0, 0, 0.117647);
|
|
571
702
|
}
|
|
572
703
|
|
|
573
704
|
.uni-scroll-view-refresh__spinner {
|
|
@@ -253,7 +253,7 @@ export default {
|
|
|
253
253
|
_onTrack: function (e) {
|
|
254
254
|
if (!this.disabled) {
|
|
255
255
|
return e.detail.state === 'move' ? (this._onUserChangedValue({
|
|
256
|
-
x: e.detail.
|
|
256
|
+
x: e.detail.x
|
|
257
257
|
}), this.$trigger('changing', e, {
|
|
258
258
|
value: this.sliderValue
|
|
259
259
|
}), !1) : (e.detail.state === 'end' && this.$trigger('change', e, {
|
|
@@ -487,6 +487,7 @@ export default {
|
|
|
487
487
|
}
|
|
488
488
|
},
|
|
489
489
|
_handleTrackStart () {
|
|
490
|
+
if (!this.items.length) return
|
|
490
491
|
this._cancelSchedule()
|
|
491
492
|
this._contentTrackViewport = this._viewportPosition
|
|
492
493
|
this._contentTrackSpeed = 0
|
|
@@ -494,6 +495,7 @@ export default {
|
|
|
494
495
|
this._cancelViewportAnimation()
|
|
495
496
|
},
|
|
496
497
|
_handleTrackMove (data) {
|
|
498
|
+
if (!this.items.length) return
|
|
497
499
|
var self = this
|
|
498
500
|
var contentTrackT = this._contentTrackT
|
|
499
501
|
this._contentTrackT = Date.now()
|
|
@@ -528,6 +530,7 @@ export default {
|
|
|
528
530
|
}
|
|
529
531
|
},
|
|
530
532
|
_handleTrackEnd (isCancel) {
|
|
533
|
+
if (!this.items.length) return
|
|
531
534
|
this.userTracking = false
|
|
532
535
|
var t = this._contentTrackSpeed / Math.abs(this._contentTrackSpeed)
|
|
533
536
|
var n = 0
|