@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.
Files changed (52) hide show
  1. package/dist/cjs/index-47a1959e.js +34 -0
  2. package/dist/cjs/taro-picker-view-column-core.cjs.entry.js +1 -1
  3. package/dist/cjs/taro-scroll-view-core.cjs.entry.js +1 -1
  4. package/dist/cjs/taro-swiper-core_2.cjs.entry.js +1 -1
  5. package/dist/cjs/taro-tabbar.cjs.entry.js +11 -12
  6. package/dist/cjs/taro-video-control_3.cjs.entry.js +101 -114
  7. package/dist/collection/components/tabbar/tabbar.js +11 -12
  8. package/dist/collection/components/video/utils.js +95 -109
  9. package/dist/collection/components/video/video.js +2 -1
  10. package/dist/collection/utils/index.js +16 -16
  11. package/dist/esm/index-cad8203e.js +31 -0
  12. package/dist/esm/taro-picker-view-column-core.entry.js +1 -1
  13. package/dist/esm/taro-scroll-view-core.entry.js +1 -1
  14. package/dist/esm/taro-swiper-core_2.entry.js +1 -1
  15. package/dist/esm/taro-tabbar.entry.js +11 -12
  16. package/dist/esm/taro-video-control_3.entry.js +95 -108
  17. package/dist/esm-es5/index-cad8203e.js +1 -0
  18. package/dist/esm-es5/taro-picker-view-column-core.entry.js +1 -1
  19. package/dist/esm-es5/taro-scroll-view-core.entry.js +1 -1
  20. package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -1
  21. package/dist/esm-es5/taro-tabbar.entry.js +1 -1
  22. package/dist/esm-es5/taro-video-control_3.entry.js +1 -1
  23. package/dist/taro-components/p-078230a0.system.entry.js +1 -0
  24. package/dist/taro-components/{p-93fe9ea6.system.entry.js → p-08aba8db.system.entry.js} +1 -1
  25. package/dist/taro-components/{p-9086b901.system.entry.js → p-08ea5931.system.entry.js} +1 -1
  26. package/dist/taro-components/p-33ee636a.system.js +1 -1
  27. package/dist/taro-components/p-44b60b72.entry.js +1 -0
  28. package/dist/taro-components/p-5746d7ce.js +1 -0
  29. package/dist/taro-components/p-663d1bb9.system.js +1 -0
  30. package/dist/taro-components/p-786653af.system.entry.js +1 -0
  31. package/dist/taro-components/p-a1863c96.entry.js +1 -0
  32. package/dist/taro-components/{p-d2be4eb3.entry.js → p-aae3e479.entry.js} +1 -1
  33. package/dist/taro-components/{p-e12cb218.entry.js → p-cc36cee7.entry.js} +1 -1
  34. package/dist/taro-components/{p-d8862a47.entry.js → p-e0ad978e.entry.js} +1 -1
  35. package/dist/taro-components/{p-092d81b8.system.entry.js → p-e61d2113.system.entry.js} +1 -1
  36. package/dist/taro-components/taro-components.esm.js +1 -1
  37. package/dist/types/components/picker-view/picker-view-column.d.ts +1 -1
  38. package/dist/types/components/scroll-view/scroll-view.d.ts +1 -1
  39. package/dist/types/components/swiper/swiper.d.ts +2 -2
  40. package/dist/types/components/tabbar/tabbar.d.ts +3 -2
  41. package/dist/types/components/video/utils.d.ts +7 -0
  42. package/dist/types/utils/index.d.ts +2 -2
  43. package/package.json +3 -3
  44. package/dist/cjs/index-bf151ad6.js +0 -13
  45. package/dist/esm/index-c58e5e14.js +0 -11
  46. package/dist/esm-es5/index-c58e5e14.js +0 -1
  47. package/dist/taro-components/p-15b51e54.system.entry.js +0 -1
  48. package/dist/taro-components/p-2c05106f.system.entry.js +0 -1
  49. package/dist/taro-components/p-724abeb7.js +0 -1
  50. package/dist/taro-components/p-b246a0d1.entry.js +0 -1
  51. package/dist/taro-components/p-f05cac3f.entry.js +0 -1
  52. package/dist/taro-components/p-f885783f.system.js +0 -1
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ function throttle(fn, threshold = 250, scope) {
4
+ let lastTime = 0;
5
+ let deferTimer;
6
+ return function (...args) {
7
+ const context = scope || this;
8
+ const now = Date.now();
9
+ if (now - lastTime > threshold) {
10
+ fn.apply(this, args);
11
+ lastTime = now;
12
+ }
13
+ else {
14
+ clearTimeout(deferTimer);
15
+ deferTimer = setTimeout(() => {
16
+ lastTime = now;
17
+ fn.apply(context, args);
18
+ }, threshold);
19
+ }
20
+ };
21
+ }
22
+ function debounce(fn, ms = 250, scope) {
23
+ let timer;
24
+ return function (...args) {
25
+ const context = scope || this;
26
+ clearTimeout(timer);
27
+ timer = setTimeout(function () {
28
+ fn.apply(context, args);
29
+ }, ms);
30
+ };
31
+ }
32
+
33
+ exports.debounce = debounce;
34
+ exports.throttle = throttle;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-dd4b7ba3.js');
6
- const index$1 = require('./index-bf151ad6.js');
6
+ const index$1 = require('./index-47a1959e.js');
7
7
 
8
8
  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}";
9
9
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-dd4b7ba3.js');
6
6
  const index$2 = require('./index-b9715722.js');
7
- const index$1 = require('./index-bf151ad6.js');
7
+ const index$1 = require('./index-47a1959e.js');
8
8
 
9
9
  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}";
10
10
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index$1 = require('./index-dd4b7ba3.js');
6
6
  const index$3 = require('./index-b9715722.js');
7
- const index$2 = require('./index-bf151ad6.js');
7
+ const index$2 = require('./index-47a1959e.js');
8
8
 
9
9
  /**
10
10
  * SSR Window 3.0.0
@@ -135,9 +135,10 @@ const indexCss = "html,body{height:100%}#app{height:100%}.taro-tabbar__border-wh
135
135
 
136
136
  // const removeLeadingSlash = str => str.replace(/^\.?\//, '')
137
137
  // const removeTrailingSearch = str => str.replace(/\?[\s\S]*$/, '')
138
- const addLeadingSlash = str => str[0] === '/' ? str : `/${str}`;
139
- const hasBasename = (path, prefix) => new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
140
- const stripBasename = (path, prefix) => hasBasename(path, prefix) ? path.substr(prefix.length) : path;
138
+ const addLeadingSlash = (str = '') => str[0] === '/' ? str : `/${str}`;
139
+ const hasBasename = (path = '', prefix = '') => new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
140
+ const stripBasename = (path = '', prefix = '') => hasBasename(path, prefix) ? path.substr(prefix.length) : path;
141
+ const stripSuffix = (path = '', suffix = '') => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
141
142
  const STATUS_SHOW = 0;
142
143
  const STATUS_HIDE = 1;
143
144
  const STATUS_SLIDEOUT = 2;
@@ -159,7 +160,7 @@ let Tabbar = class {
159
160
  const pathB = splitUrl(url).path;
160
161
  return pathA === pathB;
161
162
  });
162
- return customRoute.length ? customRoute[0][0] : url;
163
+ return stripSuffix(customRoute.length ? customRoute[0][0] : url, '.html');
163
164
  };
164
165
  this.getSelectedIndex = (url) => {
165
166
  let foundIndex = -1;
@@ -195,14 +196,12 @@ let Tabbar = class {
195
196
  }
196
197
  };
197
198
  this.routerChangeHandler = (options) => {
198
- let toLocation;
199
+ var _a;
200
+ const to = (_a = options === null || options === void 0 ? void 0 : options.toLocation) === null || _a === void 0 ? void 0 : _a.path;
199
201
  let currentPage;
200
- if (options) {
201
- toLocation = options.toLocation;
202
- }
203
- if (toLocation && toLocation.path) {
204
- const tmpPath = addLeadingSlash(toLocation.path);
205
- currentPage = stripBasename(tmpPath === '/' ? this.homePage : tmpPath, this.conf.basename || '/');
202
+ if (typeof to === 'string') {
203
+ const routerBasename = this.conf.basename || '/';
204
+ currentPage = stripBasename(addLeadingSlash(to || this.homePage), routerBasename);
206
205
  }
207
206
  else {
208
207
  currentPage = this.getCurrentUrl();
@@ -361,7 +360,7 @@ let Tabbar = class {
361
360
  url = location.pathname;
362
361
  }
363
362
  const processedUrl = addLeadingSlash(stripBasename(url, routerBasename));
364
- return processedUrl === '/' ? this.homePage : processedUrl;
363
+ return decodeURI(processedUrl === '/' ? this.homePage : processedUrl);
365
364
  }
366
365
  bindEvent() {
367
366
  Taro__default['default'].eventCenter.on('__taroRouterChange', this.routerChangeHandler);
@@ -3,116 +3,103 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-dd4b7ba3.js');
6
- const index$1 = require('./index-b9715722.js');
6
+ const index$2 = require('./index-b9715722.js');
7
+ const index$1 = require('./index-47a1959e.js');
7
8
 
8
- const formatTime = time => {
9
- if (time == null) return ''
10
- const sec = Math.round(time % 60);
11
- const min = Math.round((time - sec) / 60);
12
- return `${min < 10 ? `0${min}` : min}:${sec < 10 ? `0${sec}` : sec}`
13
- };
14
-
15
- const calcDist = (x, y) => {
16
- return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
17
- };
18
-
19
- const normalizeNumber = number => {
20
- return Math.max(-1, Math.min(number, 1))
21
- };
22
-
23
- const throttle = (fn, threshhold) => {
24
- let lastTime = 0;
25
- return function () {
26
- const now = Date.now();
27
- if (now - lastTime > threshhold) {
28
- fn.apply(this, arguments);
29
- lastTime = now;
30
- }
31
- }
32
- };
33
-
34
- /**
35
- * @returns: {requestFullscreen: 'requestFullscreen', exitFullscreen: 'exitFullscreen', ...}
36
- */
37
- const screenFn = (function () {
38
- let val;
39
- const fnMap = [
40
- [
41
- 'requestFullscreen',
42
- 'exitFullscreen',
43
- 'fullscreenElement',
44
- 'fullscreenEnabled',
45
- 'fullscreenchange',
46
- 'fullscreenerror'
47
- ],
48
- // New WebKit
49
- [
50
- 'webkitRequestFullscreen',
51
- 'webkitExitFullscreen',
52
- 'webkitFullscreenElement',
53
- 'webkitFullscreenEnabled',
54
- 'webkitfullscreenchange',
55
- 'webkitfullscreenerror'
56
- ],
57
- // Old WebKit
58
- [
59
- 'webkitRequestFullScreen',
60
- 'webkitCancelFullScreen',
61
- 'webkitCurrentFullScreenElement',
62
- 'webkitCancelFullScreen',
63
- 'webkitfullscreenchange',
64
- 'webkitfullscreenerror'
65
- ],
66
- [
67
- 'mozRequestFullScreen',
68
- 'mozCancelFullScreen',
69
- 'mozFullScreenElement',
70
- 'mozFullScreenEnabled',
71
- 'mozfullscreenchange',
72
- 'mozfullscreenerror'
73
- ],
74
- [
75
- 'msRequestFullscreen',
76
- 'msExitFullscreen',
77
- 'msFullscreenElement',
78
- 'msFullscreenEnabled',
79
- 'MSFullscreenChange',
80
- 'MSFullscreenError'
81
- ]
82
- ];
83
- var defaultIOSMap = [
84
- 'webkitEnterFullscreen',
85
- 'webkitExitFullscreen',
86
- 'webkitFullscreenElement',
87
- 'webkitFullscreenEnabled',
88
- 'webkitfullscreenchange',
89
- 'webkitfullscreenerror'
90
- ];
91
- let i = 0;
92
- const l = fnMap.length;
93
- const ret = {};
94
- // This for loop essentially checks the current document object for the property/methods above.
95
- for (; i < l; i++) {
96
- val = fnMap[i];
97
- if (val && val[1] in document) {
98
- for (i = 0; i < val.length; i++) {
99
- ret[fnMap[0][i]] = val[i];
100
- }
101
- return ret
102
- }
103
- }
104
- if (!ret[fnMap[0][0]]) {
105
- // when there is no any APIs be set.
106
-
107
- // In IOS, there is no 'webkitEnterFullscreen' property `in document` but video can use it for fullscreen.
108
- // ref: https://developer.apple.com/documentation/webkitjs/htmlvideoelement/1633500-webkitenterfullscreen
109
- for (i = 0; i < defaultIOSMap.length; i++) {
110
- ret[fnMap[0][i]] = defaultIOSMap[i];
111
- }
112
- }
113
- // If it doesn't find any of them, this whole function returns {}
114
- // and the fn variable is set to this returned value.
115
- return ret
9
+ const formatTime = (time) => {
10
+ if (time === null)
11
+ return '';
12
+ const sec = Math.round(time / 1000 % 60);
13
+ const min = Math.floor((time - sec) / 1000 / 60);
14
+ return `${min < 10 ? `0${min}` : min}:${sec < 10 ? `0${sec}` : sec}`;
15
+ };
16
+ const calcDist = (x, y) => {
17
+ return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
18
+ };
19
+ const normalizeNumber = (number) => {
20
+ return Math.max(-1, Math.min(number, 1));
21
+ };
22
+ /**
23
+ * @returns: {requestFullscreen: 'requestFullscreen', exitFullscreen: 'exitFullscreen', ...}
24
+ */
25
+ const screenFn = (function () {
26
+ let val;
27
+ const fnMap = [
28
+ [
29
+ 'requestFullscreen',
30
+ 'exitFullscreen',
31
+ 'fullscreenElement',
32
+ 'fullscreenEnabled',
33
+ 'fullscreenchange',
34
+ 'fullscreenerror'
35
+ ],
36
+ // New WebKit
37
+ [
38
+ 'webkitRequestFullscreen',
39
+ 'webkitExitFullscreen',
40
+ 'webkitFullscreenElement',
41
+ 'webkitFullscreenEnabled',
42
+ 'webkitfullscreenchange',
43
+ 'webkitfullscreenerror'
44
+ ],
45
+ // Old WebKit
46
+ [
47
+ 'webkitRequestFullScreen',
48
+ 'webkitCancelFullScreen',
49
+ 'webkitCurrentFullScreenElement',
50
+ 'webkitCancelFullScreen',
51
+ 'webkitfullscreenchange',
52
+ 'webkitfullscreenerror'
53
+ ],
54
+ [
55
+ 'mozRequestFullScreen',
56
+ 'mozCancelFullScreen',
57
+ 'mozFullScreenElement',
58
+ 'mozFullScreenEnabled',
59
+ 'mozfullscreenchange',
60
+ 'mozfullscreenerror'
61
+ ],
62
+ [
63
+ 'msRequestFullscreen',
64
+ 'msExitFullscreen',
65
+ 'msFullscreenElement',
66
+ 'msFullscreenEnabled',
67
+ 'MSFullscreenChange',
68
+ 'MSFullscreenError'
69
+ ]
70
+ ];
71
+ var defaultIOSMap = [
72
+ 'webkitEnterFullscreen',
73
+ 'webkitExitFullscreen',
74
+ 'webkitFullscreenElement',
75
+ 'webkitFullscreenEnabled',
76
+ 'webkitfullscreenchange',
77
+ 'webkitfullscreenerror'
78
+ ];
79
+ let i = 0;
80
+ const l = fnMap.length;
81
+ const ret = {};
82
+ // This for loop essentially checks the current document object for the property/methods above.
83
+ for (; i < l; i++) {
84
+ val = fnMap[i];
85
+ if (val && val[1] in document) {
86
+ for (i = 0; i < val.length; i++) {
87
+ ret[fnMap[0][i]] = val[i];
88
+ }
89
+ return ret;
90
+ }
91
+ }
92
+ if (!ret[fnMap[0][0]]) {
93
+ // when there is no any APIs be set.
94
+ // In IOS, there is no 'webkitEnterFullscreen' property `in document` but video can use it for fullscreen.
95
+ // ref: https://developer.apple.com/documentation/webkitjs/htmlvideoelement/1633500-webkitenterfullscreen
96
+ for (i = 0; i < defaultIOSMap.length; i++) {
97
+ ret[fnMap[0][i]] = defaultIOSMap[i];
98
+ }
99
+ }
100
+ // If it doesn't find any of them, this whole function returns {}
101
+ // and the fn variable is set to this returned value.
102
+ return ret;
116
103
  })();
117
104
 
118
105
  var __awaiter$2 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -406,7 +393,7 @@ let Video = class {
406
393
  this.controlsRef.toggleVisibility();
407
394
  this.onEnded.emit();
408
395
  };
409
- this.handleTimeUpdate = throttle((e) => __awaiter$1(this, void 0, void 0, function* () {
396
+ this.handleTimeUpdate = index$1.throttle((e) => __awaiter$1(this, void 0, void 0, function* () {
410
397
  var _a, _b;
411
398
  this.currentTime = this.videoRef.currentTime;
412
399
  const duration = this.duration || this._duration;
@@ -614,7 +601,7 @@ let Video = class {
614
601
  render() {
615
602
  const { src, controls, autoplay, loop, muted, poster, objectFit, isFirst, isMute, isFullScreen, duration, _duration, showCenterPlayBtn, isPlaying, _enableDanmu, showMuteBtn, danmuBtn, showFullscreenBtn, nativeProps } = this;
616
603
  const durationTime = formatTime(duration || _duration || null);
617
- return (index.h(index.Host, { class: index$1.classnames('taro-video-container', {
604
+ return (index.h(index.Host, { class: index$2.classnames('taro-video-container', {
618
605
  'taro-video-type-fullscreen': isFullScreen
619
606
  }), onTouchStart: this.onTouchStartContainer, onClick: this.onClickContainer }, index.h("video", Object.assign({ class: 'taro-video-video', style: {
620
607
  'object-fit': objectFit
@@ -630,11 +617,11 @@ let Video = class {
630
617
  if (dom) {
631
618
  this.controlsRef = dom;
632
619
  }
633
- }, controls: controls, currentTime: this.currentTime, duration: this.duration || this._duration || undefined, isPlaying: this.isPlaying, pauseFunc: this._pause, playFunc: this._play, seekFunc: this._seek, showPlayBtn: this.showPlayBtn, showProgress: this.showProgress }, showMuteBtn && (index.h("div", { class: index$1.classnames('taro-video-mute', {
620
+ }, controls: controls, currentTime: this.currentTime, duration: this.duration || this._duration || undefined, isPlaying: this.isPlaying, pauseFunc: this._pause, playFunc: this._play, seekFunc: this._seek, showPlayBtn: this.showPlayBtn, showProgress: this.showProgress }, showMuteBtn && (index.h("div", { class: index$2.classnames('taro-video-mute', {
634
621
  'taro-video-type-mute': isMute
635
- }), onClick: this.toggleMute })), danmuBtn && (index.h("div", { class: index$1.classnames('taro-video-danmu-button', {
622
+ }), onClick: this.toggleMute })), danmuBtn && (index.h("div", { class: index$2.classnames('taro-video-danmu-button', {
636
623
  'taro-video-danmu-button-active': _enableDanmu
637
- }), onClick: this.toggleDanmu }, "\u5F39\u5E55")), showFullscreenBtn && (index.h("div", { class: index$1.classnames('taro-video-fullscreen', {
624
+ }), onClick: this.toggleDanmu }, "\u5F39\u5E55")), showFullscreenBtn && (index.h("div", { class: index$2.classnames('taro-video-fullscreen', {
638
625
  'taro-video-type-fullscreen': isFullScreen
639
626
  }), onClick: this.onClickFullScreenBtn }))), index.h("div", { class: 'taro-video-toast taro-video-toast-volume', ref: dom => {
640
627
  if (dom) {
@@ -6,9 +6,10 @@ import { splitUrl } from '../../utils';
6
6
  import { TabbarItem } from './tabbar-item';
7
7
  // const removeLeadingSlash = str => str.replace(/^\.?\//, '')
8
8
  // const removeTrailingSearch = str => str.replace(/\?[\s\S]*$/, '')
9
- const addLeadingSlash = str => str[0] === '/' ? str : `/${str}`;
10
- const hasBasename = (path, prefix) => new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
11
- const stripBasename = (path, prefix) => hasBasename(path, prefix) ? path.substr(prefix.length) : path;
9
+ const addLeadingSlash = (str = '') => str[0] === '/' ? str : `/${str}`;
10
+ const hasBasename = (path = '', prefix = '') => new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
11
+ const stripBasename = (path = '', prefix = '') => hasBasename(path, prefix) ? path.substr(prefix.length) : path;
12
+ const stripSuffix = (path = '', suffix = '') => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
12
13
  const STATUS_SHOW = 0;
13
14
  const STATUS_HIDE = 1;
14
15
  const STATUS_SLIDEOUT = 2;
@@ -28,7 +29,7 @@ export class Tabbar {
28
29
  const pathB = splitUrl(url).path;
29
30
  return pathA === pathB;
30
31
  });
31
- return customRoute.length ? customRoute[0][0] : url;
32
+ return stripSuffix(customRoute.length ? customRoute[0][0] : url, '.html');
32
33
  };
33
34
  this.getSelectedIndex = (url) => {
34
35
  let foundIndex = -1;
@@ -64,14 +65,12 @@ export class Tabbar {
64
65
  }
65
66
  };
66
67
  this.routerChangeHandler = (options) => {
67
- let toLocation;
68
+ var _a;
69
+ const to = (_a = options === null || options === void 0 ? void 0 : options.toLocation) === null || _a === void 0 ? void 0 : _a.path;
68
70
  let currentPage;
69
- if (options) {
70
- toLocation = options.toLocation;
71
- }
72
- if (toLocation && toLocation.path) {
73
- const tmpPath = addLeadingSlash(toLocation.path);
74
- currentPage = stripBasename(tmpPath === '/' ? this.homePage : tmpPath, this.conf.basename || '/');
71
+ if (typeof to === 'string') {
72
+ const routerBasename = this.conf.basename || '/';
73
+ currentPage = stripBasename(addLeadingSlash(to || this.homePage), routerBasename);
75
74
  }
76
75
  else {
77
76
  currentPage = this.getCurrentUrl();
@@ -230,7 +229,7 @@ export class Tabbar {
230
229
  url = location.pathname;
231
230
  }
232
231
  const processedUrl = addLeadingSlash(stripBasename(url, routerBasename));
233
- return processedUrl === '/' ? this.homePage : processedUrl;
232
+ return decodeURI(processedUrl === '/' ? this.homePage : processedUrl);
234
233
  }
235
234
  bindEvent() {
236
235
  Taro.eventCenter.on('__taroRouterChange', this.routerChangeHandler);
@@ -1,109 +1,95 @@
1
- export const formatTime = time => {
2
- if (time == null) return ''
3
- const sec = Math.round(time % 60)
4
- const min = Math.round((time - sec) / 60)
5
- return `${min < 10 ? `0${min}` : min}:${sec < 10 ? `0${sec}` : sec}`
6
- }
7
-
8
- export const calcDist = (x, y) => {
9
- return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
10
- }
11
-
12
- export const normalizeNumber = number => {
13
- return Math.max(-1, Math.min(number, 1))
14
- }
15
-
16
- export const throttle = (fn, threshhold) => {
17
- let lastTime = 0
18
- return function () {
19
- const now = Date.now()
20
- if (now - lastTime > threshhold) {
21
- fn.apply(this, arguments)
22
- lastTime = now
23
- }
24
- }
25
- }
26
-
27
- /**
28
- * @returns: {requestFullscreen: 'requestFullscreen', exitFullscreen: 'exitFullscreen', ...}
29
- */
30
- export const screenFn = (function () {
31
- let val
32
- const fnMap = [
33
- [
34
- 'requestFullscreen',
35
- 'exitFullscreen',
36
- 'fullscreenElement',
37
- 'fullscreenEnabled',
38
- 'fullscreenchange',
39
- 'fullscreenerror'
40
- ],
41
- // New WebKit
42
- [
43
- 'webkitRequestFullscreen',
44
- 'webkitExitFullscreen',
45
- 'webkitFullscreenElement',
46
- 'webkitFullscreenEnabled',
47
- 'webkitfullscreenchange',
48
- 'webkitfullscreenerror'
49
- ],
50
- // Old WebKit
51
- [
52
- 'webkitRequestFullScreen',
53
- 'webkitCancelFullScreen',
54
- 'webkitCurrentFullScreenElement',
55
- 'webkitCancelFullScreen',
56
- 'webkitfullscreenchange',
57
- 'webkitfullscreenerror'
58
- ],
59
- [
60
- 'mozRequestFullScreen',
61
- 'mozCancelFullScreen',
62
- 'mozFullScreenElement',
63
- 'mozFullScreenEnabled',
64
- 'mozfullscreenchange',
65
- 'mozfullscreenerror'
66
- ],
67
- [
68
- 'msRequestFullscreen',
69
- 'msExitFullscreen',
70
- 'msFullscreenElement',
71
- 'msFullscreenEnabled',
72
- 'MSFullscreenChange',
73
- 'MSFullscreenError'
74
- ]
75
- ]
76
- var defaultIOSMap = [
77
- 'webkitEnterFullscreen',
78
- 'webkitExitFullscreen',
79
- 'webkitFullscreenElement',
80
- 'webkitFullscreenEnabled',
81
- 'webkitfullscreenchange',
82
- 'webkitfullscreenerror'
83
- ]
84
- let i = 0
85
- const l = fnMap.length
86
- const ret = {}
87
- // This for loop essentially checks the current document object for the property/methods above.
88
- for (; i < l; i++) {
89
- val = fnMap[i]
90
- if (val && val[1] in document) {
91
- for (i = 0; i < val.length; i++) {
92
- ret[fnMap[0][i]] = val[i]
93
- }
94
- return ret
95
- }
96
- }
97
- if (!ret[fnMap[0][0]]) {
98
- // when there is no any APIs be set.
99
-
100
- // In IOS, there is no 'webkitEnterFullscreen' property `in document` but video can use it for fullscreen.
101
- // ref: https://developer.apple.com/documentation/webkitjs/htmlvideoelement/1633500-webkitenterfullscreen
102
- for (i = 0; i < defaultIOSMap.length; i++) {
103
- ret[fnMap[0][i]] = defaultIOSMap[i]
104
- }
105
- }
106
- // If it doesn't find any of them, this whole function returns {}
107
- // and the fn variable is set to this returned value.
108
- return ret
109
- })()
1
+ export const formatTime = (time) => {
2
+ if (time === null)
3
+ return '';
4
+ const sec = Math.round(time / 1000 % 60);
5
+ const min = Math.floor((time - sec) / 1000 / 60);
6
+ return `${min < 10 ? `0${min}` : min}:${sec < 10 ? `0${sec}` : sec}`;
7
+ };
8
+ export const calcDist = (x, y) => {
9
+ return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
10
+ };
11
+ export const normalizeNumber = (number) => {
12
+ return Math.max(-1, Math.min(number, 1));
13
+ };
14
+ /**
15
+ * @returns: {requestFullscreen: 'requestFullscreen', exitFullscreen: 'exitFullscreen', ...}
16
+ */
17
+ export const screenFn = (function () {
18
+ let val;
19
+ const fnMap = [
20
+ [
21
+ 'requestFullscreen',
22
+ 'exitFullscreen',
23
+ 'fullscreenElement',
24
+ 'fullscreenEnabled',
25
+ 'fullscreenchange',
26
+ 'fullscreenerror'
27
+ ],
28
+ // New WebKit
29
+ [
30
+ 'webkitRequestFullscreen',
31
+ 'webkitExitFullscreen',
32
+ 'webkitFullscreenElement',
33
+ 'webkitFullscreenEnabled',
34
+ 'webkitfullscreenchange',
35
+ 'webkitfullscreenerror'
36
+ ],
37
+ // Old WebKit
38
+ [
39
+ 'webkitRequestFullScreen',
40
+ 'webkitCancelFullScreen',
41
+ 'webkitCurrentFullScreenElement',
42
+ 'webkitCancelFullScreen',
43
+ 'webkitfullscreenchange',
44
+ 'webkitfullscreenerror'
45
+ ],
46
+ [
47
+ 'mozRequestFullScreen',
48
+ 'mozCancelFullScreen',
49
+ 'mozFullScreenElement',
50
+ 'mozFullScreenEnabled',
51
+ 'mozfullscreenchange',
52
+ 'mozfullscreenerror'
53
+ ],
54
+ [
55
+ 'msRequestFullscreen',
56
+ 'msExitFullscreen',
57
+ 'msFullscreenElement',
58
+ 'msFullscreenEnabled',
59
+ 'MSFullscreenChange',
60
+ 'MSFullscreenError'
61
+ ]
62
+ ];
63
+ var defaultIOSMap = [
64
+ 'webkitEnterFullscreen',
65
+ 'webkitExitFullscreen',
66
+ 'webkitFullscreenElement',
67
+ 'webkitFullscreenEnabled',
68
+ 'webkitfullscreenchange',
69
+ 'webkitfullscreenerror'
70
+ ];
71
+ let i = 0;
72
+ const l = fnMap.length;
73
+ const ret = {};
74
+ // This for loop essentially checks the current document object for the property/methods above.
75
+ for (; i < l; i++) {
76
+ val = fnMap[i];
77
+ if (val && val[1] in document) {
78
+ for (i = 0; i < val.length; i++) {
79
+ ret[fnMap[0][i]] = val[i];
80
+ }
81
+ return ret;
82
+ }
83
+ }
84
+ if (!ret[fnMap[0][0]]) {
85
+ // when there is no any APIs be set.
86
+ // In IOS, there is no 'webkitEnterFullscreen' property `in document` but video can use it for fullscreen.
87
+ // ref: https://developer.apple.com/documentation/webkitjs/htmlvideoelement/1633500-webkitenterfullscreen
88
+ for (i = 0; i < defaultIOSMap.length; i++) {
89
+ ret[fnMap[0][i]] = defaultIOSMap[i];
90
+ }
91
+ }
92
+ // If it doesn't find any of them, this whole function returns {}
93
+ // and the fn variable is set to this returned value.
94
+ return ret;
95
+ })();
@@ -10,7 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
11
  import { Component, h, Prop, State, Event, Host, Watch, Listen, Element, Method } from '@stencil/core';
12
12
  import classNames from 'classnames';
13
- import { formatTime, calcDist, normalizeNumber, throttle, screenFn } from './utils';
13
+ import { throttle } from '../../utils';
14
+ import { formatTime, calcDist, normalizeNumber, screenFn } from './utils';
14
15
  export class Video {
15
16
  constructor() {
16
17
  this.currentTime = 0;