@tarojs/components 3.4.7 → 3.5.0-alpha.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/dist/cjs/index-47a1959e.js +34 -0
- package/dist/cjs/taro-picker-view-column-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-scroll-view-core.cjs.entry.js +1 -1
- package/dist/cjs/taro-swiper-core_2.cjs.entry.js +1 -1
- package/dist/cjs/taro-tabbar.cjs.entry.js +11 -12
- package/dist/cjs/taro-video-control_3.cjs.entry.js +101 -114
- package/dist/collection/components/tabbar/tabbar.js +11 -12
- package/dist/collection/components/video/utils.js +95 -109
- package/dist/collection/components/video/video.js +2 -1
- package/dist/collection/utils/index.js +16 -16
- package/dist/esm/index-cad8203e.js +31 -0
- package/dist/esm/taro-picker-view-column-core.entry.js +1 -1
- package/dist/esm/taro-scroll-view-core.entry.js +1 -1
- package/dist/esm/taro-swiper-core_2.entry.js +1 -1
- package/dist/esm/taro-tabbar.entry.js +11 -12
- package/dist/esm/taro-video-control_3.entry.js +95 -108
- package/dist/esm-es5/index-cad8203e.js +1 -0
- package/dist/esm-es5/taro-picker-view-column-core.entry.js +1 -1
- package/dist/esm-es5/taro-scroll-view-core.entry.js +1 -1
- package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -1
- package/dist/esm-es5/taro-tabbar.entry.js +1 -1
- package/dist/esm-es5/taro-video-control_3.entry.js +1 -1
- package/dist/taro-components/p-078230a0.system.entry.js +1 -0
- package/dist/taro-components/{p-93fe9ea6.system.entry.js → p-08aba8db.system.entry.js} +1 -1
- package/dist/taro-components/{p-9086b901.system.entry.js → p-08ea5931.system.entry.js} +1 -1
- package/dist/taro-components/p-33ee636a.system.js +1 -1
- package/dist/taro-components/p-44b60b72.entry.js +1 -0
- package/dist/taro-components/p-5746d7ce.js +1 -0
- package/dist/taro-components/p-663d1bb9.system.js +1 -0
- package/dist/taro-components/p-786653af.system.entry.js +1 -0
- package/dist/taro-components/p-a1863c96.entry.js +1 -0
- package/dist/taro-components/{p-d2be4eb3.entry.js → p-aae3e479.entry.js} +1 -1
- package/dist/taro-components/{p-e12cb218.entry.js → p-cc36cee7.entry.js} +1 -1
- package/dist/taro-components/{p-d8862a47.entry.js → p-e0ad978e.entry.js} +1 -1
- package/dist/taro-components/{p-092d81b8.system.entry.js → p-e61d2113.system.entry.js} +1 -1
- package/dist/taro-components/taro-components.esm.js +1 -1
- package/dist/types/components/picker-view/picker-view-column.d.ts +1 -1
- package/dist/types/components/scroll-view/scroll-view.d.ts +1 -1
- package/dist/types/components/swiper/swiper.d.ts +2 -2
- package/dist/types/components/tabbar/tabbar.d.ts +3 -2
- package/dist/types/components/video/utils.d.ts +7 -0
- package/dist/types/utils/index.d.ts +2 -2
- package/package.json +3 -3
- package/dist/cjs/index-bf151ad6.js +0 -13
- package/dist/esm/index-c58e5e14.js +0 -11
- package/dist/esm-es5/index-c58e5e14.js +0 -1
- package/dist/taro-components/p-15b51e54.system.entry.js +0 -1
- package/dist/taro-components/p-2c05106f.system.entry.js +0 -1
- package/dist/taro-components/p-724abeb7.js +0 -1
- package/dist/taro-components/p-b246a0d1.entry.js +0 -1
- package/dist/taro-components/p-f05cac3f.entry.js +0 -1
- package/dist/taro-components/p-f885783f.system.js +0 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export function throttle(fn,
|
|
2
|
-
let
|
|
3
|
-
|
|
1
|
+
export function throttle(fn, threshold = 250, scope) {
|
|
2
|
+
let lastTime = 0;
|
|
3
|
+
let deferTimer;
|
|
4
|
+
return function (...args) {
|
|
4
5
|
const context = scope || this;
|
|
5
|
-
const now =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const now = Date.now();
|
|
7
|
+
if (now - lastTime > threshold) {
|
|
8
|
+
fn.apply(this, args);
|
|
9
|
+
lastTime = now;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
9
12
|
clearTimeout(deferTimer);
|
|
10
13
|
deferTimer = setTimeout(() => {
|
|
11
|
-
|
|
14
|
+
lastTime = now;
|
|
12
15
|
fn.apply(context, args);
|
|
13
|
-
},
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
last = now;
|
|
17
|
-
fn.apply(context, args);
|
|
16
|
+
}, threshold);
|
|
18
17
|
}
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
|
-
export function debounce(fn, ms = 250) {
|
|
20
|
+
export function debounce(fn, ms = 250, scope) {
|
|
22
21
|
let timer;
|
|
23
|
-
return function (...
|
|
22
|
+
return function (...args) {
|
|
23
|
+
const context = scope || this;
|
|
24
24
|
clearTimeout(timer);
|
|
25
25
|
timer = setTimeout(function () {
|
|
26
|
-
fn(
|
|
26
|
+
fn.apply(context, args);
|
|
27
27
|
}, ms);
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function throttle(fn, threshold = 250, scope) {
|
|
2
|
+
let lastTime = 0;
|
|
3
|
+
let deferTimer;
|
|
4
|
+
return function (...args) {
|
|
5
|
+
const context = scope || this;
|
|
6
|
+
const now = Date.now();
|
|
7
|
+
if (now - lastTime > threshold) {
|
|
8
|
+
fn.apply(this, args);
|
|
9
|
+
lastTime = now;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
clearTimeout(deferTimer);
|
|
13
|
+
deferTimer = setTimeout(() => {
|
|
14
|
+
lastTime = now;
|
|
15
|
+
fn.apply(context, args);
|
|
16
|
+
}, threshold);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function debounce(fn, ms = 250, scope) {
|
|
21
|
+
let timer;
|
|
22
|
+
return function (...args) {
|
|
23
|
+
const context = scope || this;
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
timer = setTimeout(function () {
|
|
26
|
+
fn.apply(context, args);
|
|
27
|
+
}, ms);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { debounce as d, throttle as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-5bd7cbab.js';
|
|
2
|
-
import { d as debounce } from './index-
|
|
2
|
+
import { d as debounce } from './index-cad8203e.js';
|
|
3
3
|
|
|
4
4
|
const columnCss = ".taro-picker-view-column-container{display:-ms-flexbox;display:flex;overflow:scroll;overflow-x:hidden;position:relative;-ms-flex-direction:column;flex-direction:column;-ms-flex:1;flex:1;text-align:center}.taro-picker-view-column-container::-webkit-scrollbar{display:none}";
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-5bd7cbab.js';
|
|
2
2
|
import { c as classnames } from './index-3c78bcaf.js';
|
|
3
|
-
import { d as debounce } from './index-
|
|
3
|
+
import { d as debounce } from './index-cad8203e.js';
|
|
4
4
|
|
|
5
5
|
const indexCss = "taro-scroll-view-core{display:block;width:100%;-webkit-overflow-scrolling:auto}taro-scroll-view-core::-webkit-scrollbar{display:none}.taro-scroll-view__scroll-x{overflow-x:scroll;overflow-y:hidden}.taro-scroll-view__scroll-y{overflow-x:hidden;overflow-y:scroll}";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-5bd7cbab.js';
|
|
2
2
|
import { c as classnames } from './index-3c78bcaf.js';
|
|
3
|
-
import { d as debounce } from './index-
|
|
3
|
+
import { d as debounce } from './index-cad8203e.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* SSR Window 3.0.0
|
|
@@ -127,9 +127,10 @@ const indexCss = "html,body{height:100%}#app{height:100%}.taro-tabbar__border-wh
|
|
|
127
127
|
|
|
128
128
|
// const removeLeadingSlash = str => str.replace(/^\.?\//, '')
|
|
129
129
|
// const removeTrailingSearch = str => str.replace(/\?[\s\S]*$/, '')
|
|
130
|
-
const addLeadingSlash = str => str[0] === '/' ? str : `/${str}`;
|
|
131
|
-
const hasBasename = (path, prefix) => new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
|
|
132
|
-
const stripBasename = (path, prefix) => hasBasename(path, prefix) ? path.substr(prefix.length) : path;
|
|
130
|
+
const addLeadingSlash = (str = '') => str[0] === '/' ? str : `/${str}`;
|
|
131
|
+
const hasBasename = (path = '', prefix = '') => new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
|
|
132
|
+
const stripBasename = (path = '', prefix = '') => hasBasename(path, prefix) ? path.substr(prefix.length) : path;
|
|
133
|
+
const stripSuffix = (path = '', suffix = '') => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
|
|
133
134
|
const STATUS_SHOW = 0;
|
|
134
135
|
const STATUS_HIDE = 1;
|
|
135
136
|
const STATUS_SLIDEOUT = 2;
|
|
@@ -151,7 +152,7 @@ let Tabbar = class {
|
|
|
151
152
|
const pathB = splitUrl(url).path;
|
|
152
153
|
return pathA === pathB;
|
|
153
154
|
});
|
|
154
|
-
return customRoute.length ? customRoute[0][0] : url;
|
|
155
|
+
return stripSuffix(customRoute.length ? customRoute[0][0] : url, '.html');
|
|
155
156
|
};
|
|
156
157
|
this.getSelectedIndex = (url) => {
|
|
157
158
|
let foundIndex = -1;
|
|
@@ -187,14 +188,12 @@ let Tabbar = class {
|
|
|
187
188
|
}
|
|
188
189
|
};
|
|
189
190
|
this.routerChangeHandler = (options) => {
|
|
190
|
-
|
|
191
|
+
var _a;
|
|
192
|
+
const to = (_a = options === null || options === void 0 ? void 0 : options.toLocation) === null || _a === void 0 ? void 0 : _a.path;
|
|
191
193
|
let currentPage;
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (toLocation && toLocation.path) {
|
|
196
|
-
const tmpPath = addLeadingSlash(toLocation.path);
|
|
197
|
-
currentPage = stripBasename(tmpPath === '/' ? this.homePage : tmpPath, this.conf.basename || '/');
|
|
194
|
+
if (typeof to === 'string') {
|
|
195
|
+
const routerBasename = this.conf.basename || '/';
|
|
196
|
+
currentPage = stripBasename(addLeadingSlash(to || this.homePage), routerBasename);
|
|
198
197
|
}
|
|
199
198
|
else {
|
|
200
199
|
currentPage = this.getCurrentUrl();
|
|
@@ -353,7 +352,7 @@ let Tabbar = class {
|
|
|
353
352
|
url = location.pathname;
|
|
354
353
|
}
|
|
355
354
|
const processedUrl = addLeadingSlash(stripBasename(url, routerBasename));
|
|
356
|
-
return processedUrl === '/' ? this.homePage : processedUrl;
|
|
355
|
+
return decodeURI(processedUrl === '/' ? this.homePage : processedUrl);
|
|
357
356
|
}
|
|
358
357
|
bindEvent() {
|
|
359
358
|
Taro.eventCenter.on('__taroRouterChange', this.routerChangeHandler);
|
|
@@ -1,114 +1,101 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-5bd7cbab.js';
|
|
2
2
|
import { c as classnames } from './index-3c78bcaf.js';
|
|
3
|
+
import { t as throttle } from './index-cad8203e.js';
|
|
3
4
|
|
|
4
|
-
const formatTime = time => {
|
|
5
|
-
if (time
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const calcDist = (x, y) => {
|
|
12
|
-
return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
'
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
'
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (!ret[fnMap[0][0]]) {
|
|
101
|
-
// when there is no any APIs be set.
|
|
102
|
-
|
|
103
|
-
// In IOS, there is no 'webkitEnterFullscreen' property `in document` but video can use it for fullscreen.
|
|
104
|
-
// ref: https://developer.apple.com/documentation/webkitjs/htmlvideoelement/1633500-webkitenterfullscreen
|
|
105
|
-
for (i = 0; i < defaultIOSMap.length; i++) {
|
|
106
|
-
ret[fnMap[0][i]] = defaultIOSMap[i];
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// If it doesn't find any of them, this whole function returns {}
|
|
110
|
-
// and the fn variable is set to this returned value.
|
|
111
|
-
return ret
|
|
5
|
+
const formatTime = (time) => {
|
|
6
|
+
if (time === null)
|
|
7
|
+
return '';
|
|
8
|
+
const sec = Math.round(time / 1000 % 60);
|
|
9
|
+
const min = Math.floor((time - sec) / 1000 / 60);
|
|
10
|
+
return `${min < 10 ? `0${min}` : min}:${sec < 10 ? `0${sec}` : sec}`;
|
|
11
|
+
};
|
|
12
|
+
const calcDist = (x, y) => {
|
|
13
|
+
return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
|
|
14
|
+
};
|
|
15
|
+
const normalizeNumber = (number) => {
|
|
16
|
+
return Math.max(-1, Math.min(number, 1));
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @returns: {requestFullscreen: 'requestFullscreen', exitFullscreen: 'exitFullscreen', ...}
|
|
20
|
+
*/
|
|
21
|
+
const screenFn = (function () {
|
|
22
|
+
let val;
|
|
23
|
+
const fnMap = [
|
|
24
|
+
[
|
|
25
|
+
'requestFullscreen',
|
|
26
|
+
'exitFullscreen',
|
|
27
|
+
'fullscreenElement',
|
|
28
|
+
'fullscreenEnabled',
|
|
29
|
+
'fullscreenchange',
|
|
30
|
+
'fullscreenerror'
|
|
31
|
+
],
|
|
32
|
+
// New WebKit
|
|
33
|
+
[
|
|
34
|
+
'webkitRequestFullscreen',
|
|
35
|
+
'webkitExitFullscreen',
|
|
36
|
+
'webkitFullscreenElement',
|
|
37
|
+
'webkitFullscreenEnabled',
|
|
38
|
+
'webkitfullscreenchange',
|
|
39
|
+
'webkitfullscreenerror'
|
|
40
|
+
],
|
|
41
|
+
// Old WebKit
|
|
42
|
+
[
|
|
43
|
+
'webkitRequestFullScreen',
|
|
44
|
+
'webkitCancelFullScreen',
|
|
45
|
+
'webkitCurrentFullScreenElement',
|
|
46
|
+
'webkitCancelFullScreen',
|
|
47
|
+
'webkitfullscreenchange',
|
|
48
|
+
'webkitfullscreenerror'
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
'mozRequestFullScreen',
|
|
52
|
+
'mozCancelFullScreen',
|
|
53
|
+
'mozFullScreenElement',
|
|
54
|
+
'mozFullScreenEnabled',
|
|
55
|
+
'mozfullscreenchange',
|
|
56
|
+
'mozfullscreenerror'
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
'msRequestFullscreen',
|
|
60
|
+
'msExitFullscreen',
|
|
61
|
+
'msFullscreenElement',
|
|
62
|
+
'msFullscreenEnabled',
|
|
63
|
+
'MSFullscreenChange',
|
|
64
|
+
'MSFullscreenError'
|
|
65
|
+
]
|
|
66
|
+
];
|
|
67
|
+
var defaultIOSMap = [
|
|
68
|
+
'webkitEnterFullscreen',
|
|
69
|
+
'webkitExitFullscreen',
|
|
70
|
+
'webkitFullscreenElement',
|
|
71
|
+
'webkitFullscreenEnabled',
|
|
72
|
+
'webkitfullscreenchange',
|
|
73
|
+
'webkitfullscreenerror'
|
|
74
|
+
];
|
|
75
|
+
let i = 0;
|
|
76
|
+
const l = fnMap.length;
|
|
77
|
+
const ret = {};
|
|
78
|
+
// This for loop essentially checks the current document object for the property/methods above.
|
|
79
|
+
for (; i < l; i++) {
|
|
80
|
+
val = fnMap[i];
|
|
81
|
+
if (val && val[1] in document) {
|
|
82
|
+
for (i = 0; i < val.length; i++) {
|
|
83
|
+
ret[fnMap[0][i]] = val[i];
|
|
84
|
+
}
|
|
85
|
+
return ret;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!ret[fnMap[0][0]]) {
|
|
89
|
+
// when there is no any APIs be set.
|
|
90
|
+
// In IOS, there is no 'webkitEnterFullscreen' property `in document` but video can use it for fullscreen.
|
|
91
|
+
// ref: https://developer.apple.com/documentation/webkitjs/htmlvideoelement/1633500-webkitenterfullscreen
|
|
92
|
+
for (i = 0; i < defaultIOSMap.length; i++) {
|
|
93
|
+
ret[fnMap[0][i]] = defaultIOSMap[i];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// If it doesn't find any of them, this whole function returns {}
|
|
97
|
+
// and the fn variable is set to this returned value.
|
|
98
|
+
return ret;
|
|
112
99
|
})();
|
|
113
100
|
|
|
114
101
|
var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function throttle(t,e,r){if(e===void 0){e=250}var o=0;var n;return function(){var a=[];for(var i=0;i<arguments.length;i++){a[i]=arguments[i]}var u=r||this;var v=Date.now();if(v-o>e){t.apply(this,a);o=v}else{clearTimeout(n);n=setTimeout((function(){o=v;t.apply(u,a)}),e)}}}function debounce(t,e,r){if(e===void 0){e=250}var o;return function(){var n=[];for(var a=0;a<arguments.length;a++){n[a]=arguments[a]}var i=r||this;clearTimeout(o);o=setTimeout((function(){t.apply(i,n)}),e)}}export{debounce as d,throttle as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as registerInstance,c as createEvent,h,g as getElement,H as Host}from"./index-5bd7cbab.js";import{d as debounce}from"./index-
|
|
1
|
+
import{r as registerInstance,c as createEvent,h,g as getElement,H as Host}from"./index-5bd7cbab.js";import{d as debounce}from"./index-cad8203e.js";var columnCss=".taro-picker-view-column-container{display:-ms-flexbox;display:flex;overflow:scroll;overflow-x:hidden;position:relative;-ms-flex-direction:column;flex-direction:column;-ms-flex:1;flex:1;text-align:center}.taro-picker-view-column-container::-webkit-scrollbar{display:none}";var PickerViewColumn=function(){function e(e){var t=this;registerInstance(this,e);this.onChange=createEvent(this,"onselect",7);this.onSelectStart=createEvent(this,"onselectstart",7);this.onSelectEnd=createEvent(this,"onselectend",7);this.initialPosition="0";this.paddingVertical=0;this.isInit=false;this.isMove=false;this.handleSelected=debounce((function(){var e=t.el.childNodes;var i=0;var o="0";for(var n in e){var s=e[n];var r=s.offsetHeight;if(i+r/2>t.el.scrollTop){o=n;break}i+=r}t.el.scrollTo({top:i,behavior:"smooth"});t.onChange.emit({curIndex:t.col,selectedIndex:o});t.onSelectEnd.emit()}),500)}e.prototype.onScroll=function(e){if(!this.isMove){this.isMove=true;this.onSelectStart.emit()}this.handleSelected()};e.prototype.onMouseEnd=function(){if(!this.isMove)return;this.isMove=false;this.handleSelected()};e.prototype.onTouchEnd=function(){this.isMove=false;this.handleSelected()};e.prototype.componentDidUpdate=function(){if(!this.isInit){this.isInit=true;var e=this.el.childNodes;var t=0;var i=0;for(var o in e){var n=e[o];if(this.initialPosition===o||!n||typeof n.offsetHeight!=="number"){break}i+=n.offsetHeight;t++}this.el.scrollTo({top:i});if(t>=e.length){this.onChange.emit({curIndex:this.col,selectedIndex:t-1})}}};e.prototype.render=function(){var e=this.paddingVertical,t=e===void 0?0:e;return h(Host,{class:"taro-picker-view-column-container",style:{"padding-top":t+"px","padding-bottom":t+"px"}})};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();PickerViewColumn.style=columnCss;export{PickerViewColumn as taro_picker_view_column_core};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-5bd7cbab.js";import{c as classnames}from"./index-3c78bcaf.js";import{d as debounce}from"./index-
|
|
1
|
+
import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-5bd7cbab.js";import{c as classnames}from"./index-3c78bcaf.js";import{d as debounce}from"./index-cad8203e.js";var indexCss="taro-scroll-view-core{display:block;width:100%;-webkit-overflow-scrolling:auto}taro-scroll-view-core::-webkit-scrollbar{display:none}.taro-scroll-view__scroll-x{overflow-x:scroll;overflow-y:hidden}.taro-scroll-view__scroll-y{overflow-x:hidden;overflow-y:scroll}";function easeOutScroll(l,o,r){if(l===o||typeof l!=="number"){return}var e=o-l;var t=500;var s=Date.now();var c=o>=l;function i(l,o,r,e){return r*l/e+o}function n(){l=i(Date.now()-s,l,e,t);if(c&&l>=o||!c&&o>=l){r(o);return}r(l);requestAnimationFrame(n)}n()}var ScrollView=function(){function l(l){var o=this;registerInstance(this,l);this.onScroll=createEvent(this,"scroll",3);this.onScrollToUpper=createEvent(this,"scrolltoupper",3);this.onScrollToLower=createEvent(this,"scrolltolower",3);this.scrollX=false;this.scrollY=false;this.upperThreshold=50;this.lowerThreshold=50;this.scrollWithAnimation=false;this.handleScroll=function(l){if(l instanceof CustomEvent)return;var r=o.el,e=r.scrollLeft,t=r.scrollTop,s=r.scrollHeight,c=r.scrollWidth;o._scrollLeft=e;o._scrollTop=t;o.upperAndLower();o.onScroll.emit({scrollLeft:e,scrollTop:t,scrollHeight:s,scrollWidth:c})};this.upperAndLower=debounce((function(){var l=o.el,r=l.offsetWidth,e=l.offsetHeight,t=l.scrollLeft,s=l.scrollTop,c=l.scrollHeight,i=l.scrollWidth;var n=Number(o.lowerThreshold);var a=Number(o.upperThreshold);if(!isNaN(n)&&(o.scrollY&&e+s+n>=c||o.scrollX&&r+t+n>=i)){o.onScrollToLower.emit({direction:o.scrollX?"right":o.scrollY?"bottom":""})}if(!isNaN(a)&&(o.scrollY&&s<=a||o.scrollX&&t<=a)){o.onScrollToUpper.emit({direction:o.scrollX?"left":o.scrollY?"top":""})}}),200)}l.prototype.watchScrollLeft=function(l){var o=this;var r=Number(l);if(this.scrollX&&!isNaN(r)&&r!==this._scrollLeft){if(this.scrollWithAnimation){easeOutScroll(this._scrollLeft,r,(function(l){return o.el.scrollLeft=l}))}else{this.el.scrollLeft=r}this._scrollLeft=r}};l.prototype.watchScrollTop=function(l){var o=this;var r=Number(l);if(this.scrollY&&!isNaN(r)&&r!==this._scrollTop){if(this.scrollWithAnimation){easeOutScroll(this._scrollTop,r,(function(l){return o.el.scrollTop=l}))}else{this.el.scrollTop=r}this._scrollTop=r}};l.prototype.watchScrollIntoView=function(l){var o;if(typeof l==="string"&&l){(o=document.querySelector("#"+l))===null||o===void 0?void 0:o.scrollIntoView({behavior:"smooth",block:"center",inline:"start"})}};l.prototype.componentDidLoad=function(){var l=this;var o=this,r=o.scrollY,e=o.scrollX,t=o.scrollWithAnimation;var s=Number(this.mpScrollTop);var c=Number(this.mpScrollLeft);if(r&&!isNaN(s)){if(t){easeOutScroll(0,s,(function(o){return l.el.scrollTop=o}))}else{this.el.scrollTop=s}this._scrollTop=s}if(e&&!isNaN(c)){if(t){easeOutScroll(0,c,(function(o){return l.el.scrollLeft=o}))}else{this.el.scrollLeft=c}this._scrollLeft=c}};l.prototype.render=function(){var l=this,o=l.scrollX,r=l.scrollY;var e=classnames({"taro-scroll-view__scroll-x":o,"taro-scroll-view__scroll-y":r});return h(Host,{class:e,onScroll:this.handleScroll},h("slot",null))};Object.defineProperty(l.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(l,"watchers",{get:function(){return{mpScrollLeft:["watchScrollLeft"],mpScrollTop:["watchScrollTop"],mpScrollIntoView:["watchScrollIntoView"]}},enumerable:false,configurable:true});return l}();ScrollView.style=indexCss;export{ScrollView as taro_scroll_view_core};
|