xgplayer 3.0.0-alpha.166 → 3.0.0-alpha.167
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/browser/index.min.js +1 -1
- package/dist/index.min.js +1 -1
- package/es/plugins/progressPreview/dotsApi.js +41 -7
- package/es/plugins/progressPreview/index.js +16 -9
- package/es/version.js +1 -1
- package/lib/plugins/progressPreview/dotsApi.js +41 -7
- package/lib/plugins/progressPreview/index.js +16 -9
- package/lib/version.js +1 -1
- package/package.json +1 -1
|
@@ -24,29 +24,63 @@ function mergeISPOT(iSpot) {
|
|
|
24
24
|
}
|
|
25
25
|
var APIS = {
|
|
26
26
|
initDots: function initDots() {
|
|
27
|
+
this.createDots(this._ispots, false);
|
|
28
|
+
this._ispotsInit = true;
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* 批量创建故事点DOM元素
|
|
32
|
+
* @param {Array} iSpots
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
createDots: function createDots() {
|
|
27
36
|
var _this = this;
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
var iSpots = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
38
|
+
var isNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
39
|
+
if (!Array.isArray(iSpots) || !iSpots.length) return;
|
|
40
|
+
var progress = this.player.plugins.progress;
|
|
41
|
+
if (!progress || !progress.outer) return;
|
|
42
|
+
var fragment = document.createDocumentFragment();
|
|
43
|
+
iSpots.forEach(function (item) {
|
|
44
|
+
var dotDom = _this._createDotElement(item, isNew);
|
|
45
|
+
if (dotDom) {
|
|
46
|
+
fragment.appendChild(dotDom);
|
|
47
|
+
}
|
|
30
48
|
});
|
|
31
|
-
|
|
49
|
+
progress.outer.appendChild(fragment);
|
|
32
50
|
},
|
|
33
51
|
/**
|
|
34
52
|
* 创建一个故事点
|
|
35
53
|
* @param { object } iSpot
|
|
36
54
|
* @param { boolean } isNew
|
|
55
|
+
* @public
|
|
37
56
|
*/
|
|
38
57
|
createDot: function createDot(iSpot) {
|
|
58
|
+
var isNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
59
|
+
var dotDom = this._createDotElement(iSpot, isNew);
|
|
60
|
+
if (dotDom) {
|
|
61
|
+
var progress = this.player.plugins.progress;
|
|
62
|
+
progress.outer && progress.outer.appendChild(dotDom);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* 创建故事点DOM元素(内部方法,不直接添加到DOM)
|
|
67
|
+
* @param { object } iSpot
|
|
68
|
+
* @param { boolean } isNew
|
|
69
|
+
* @returns { HTMLElement | null }
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
_createDotElement: function _createDotElement(iSpot) {
|
|
39
73
|
var isNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
40
74
|
var progress = this.player.plugins.progress;
|
|
41
75
|
if (!progress) {
|
|
42
|
-
return;
|
|
76
|
+
return null;
|
|
43
77
|
}
|
|
44
78
|
if (isNew) {
|
|
45
79
|
mergeISPOT(iSpot);
|
|
46
80
|
this._ispots.push(iSpot);
|
|
47
81
|
}
|
|
48
82
|
if (!this._ispotsInit && isNew) {
|
|
49
|
-
return;
|
|
83
|
+
return null;
|
|
50
84
|
}
|
|
51
85
|
var ret = this.calcuPosition(iSpot.time, iSpot.duration);
|
|
52
86
|
var style = iSpot.style || {};
|
|
@@ -60,10 +94,10 @@ var APIS = {
|
|
|
60
94
|
'data-time': iSpot.time,
|
|
61
95
|
'data-id': iSpot.id
|
|
62
96
|
}, className);
|
|
63
|
-
Object.keys(style).
|
|
97
|
+
Object.keys(style).forEach(function (key) {
|
|
64
98
|
dotDom.style[key] = style[key];
|
|
65
99
|
});
|
|
66
|
-
|
|
100
|
+
return dotDom;
|
|
67
101
|
},
|
|
68
102
|
/**
|
|
69
103
|
* 根据id查找节点
|
|
@@ -382,20 +382,25 @@ var ProgressPreview = /*#__PURE__*/function (_Plugin) {
|
|
|
382
382
|
value: function calcuPosition(time, duration) {
|
|
383
383
|
var progress = this.player.plugins.progress;
|
|
384
384
|
var player = this.player;
|
|
385
|
-
var totalWidth = progress.root.getBoundingClientRect().width;
|
|
386
|
-
var widthPerSeconds = player.duration / totalWidth * 6;
|
|
387
|
-
var ret = {};
|
|
388
385
|
if (time + duration > player.duration) {
|
|
389
386
|
duration = player.duration - time;
|
|
390
387
|
}
|
|
391
|
-
ret
|
|
392
|
-
ret.width = duration / player.duration;
|
|
393
|
-
ret.isMini = widthPerSeconds > duration;
|
|
394
|
-
return {
|
|
388
|
+
var ret = {
|
|
395
389
|
left: time / player.duration * 100,
|
|
396
390
|
width: duration / player.duration * 100,
|
|
397
|
-
isMini:
|
|
391
|
+
isMini: false
|
|
398
392
|
};
|
|
393
|
+
if (this.config.isDotAdaptWidth) {
|
|
394
|
+
var widthPerSeconds = 0;
|
|
395
|
+
if (player.duration > 0) {
|
|
396
|
+
var totalWidth = progress.root.getBoundingClientRect().width;
|
|
397
|
+
widthPerSeconds = player.duration / totalWidth * 6;
|
|
398
|
+
}
|
|
399
|
+
ret.isMini = widthPerSeconds > duration;
|
|
400
|
+
} else {
|
|
401
|
+
ret.isMini = true;
|
|
402
|
+
}
|
|
403
|
+
return ret;
|
|
399
404
|
}
|
|
400
405
|
}, {
|
|
401
406
|
key: "showDot",
|
|
@@ -542,7 +547,9 @@ var ProgressPreview = /*#__PURE__*/function (_Plugin) {
|
|
|
542
547
|
disable: false,
|
|
543
548
|
width: 160,
|
|
544
549
|
// 显示宽度
|
|
545
|
-
height: 90
|
|
550
|
+
height: 90,
|
|
551
|
+
// 显示高度
|
|
552
|
+
isDotAdaptWidth: true // 故事点是否动态宽度
|
|
546
553
|
};
|
|
547
554
|
}
|
|
548
555
|
}]);
|
package/es/version.js
CHANGED
|
@@ -30,29 +30,63 @@ function mergeISPOT(iSpot) {
|
|
|
30
30
|
}
|
|
31
31
|
var APIS = {
|
|
32
32
|
initDots: function initDots() {
|
|
33
|
+
this.createDots(this._ispots, false);
|
|
34
|
+
this._ispotsInit = true;
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* 批量创建故事点DOM元素
|
|
38
|
+
* @param {Array} iSpots
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
createDots: function createDots() {
|
|
33
42
|
var _this = this;
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
var iSpots = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
44
|
+
var isNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
45
|
+
if (!Array.isArray(iSpots) || !iSpots.length) return;
|
|
46
|
+
var progress = this.player.plugins.progress;
|
|
47
|
+
if (!progress || !progress.outer) return;
|
|
48
|
+
var fragment = document.createDocumentFragment();
|
|
49
|
+
iSpots.forEach(function (item) {
|
|
50
|
+
var dotDom = _this._createDotElement(item, isNew);
|
|
51
|
+
if (dotDom) {
|
|
52
|
+
fragment.appendChild(dotDom);
|
|
53
|
+
}
|
|
36
54
|
});
|
|
37
|
-
|
|
55
|
+
progress.outer.appendChild(fragment);
|
|
38
56
|
},
|
|
39
57
|
/**
|
|
40
58
|
* 创建一个故事点
|
|
41
59
|
* @param { object } iSpot
|
|
42
60
|
* @param { boolean } isNew
|
|
61
|
+
* @public
|
|
43
62
|
*/
|
|
44
63
|
createDot: function createDot(iSpot) {
|
|
64
|
+
var isNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
65
|
+
var dotDom = this._createDotElement(iSpot, isNew);
|
|
66
|
+
if (dotDom) {
|
|
67
|
+
var progress = this.player.plugins.progress;
|
|
68
|
+
progress.outer && progress.outer.appendChild(dotDom);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* 创建故事点DOM元素(内部方法,不直接添加到DOM)
|
|
73
|
+
* @param { object } iSpot
|
|
74
|
+
* @param { boolean } isNew
|
|
75
|
+
* @returns { HTMLElement | null }
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
_createDotElement: function _createDotElement(iSpot) {
|
|
45
79
|
var isNew = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
46
80
|
var progress = this.player.plugins.progress;
|
|
47
81
|
if (!progress) {
|
|
48
|
-
return;
|
|
82
|
+
return null;
|
|
49
83
|
}
|
|
50
84
|
if (isNew) {
|
|
51
85
|
mergeISPOT(iSpot);
|
|
52
86
|
this._ispots.push(iSpot);
|
|
53
87
|
}
|
|
54
88
|
if (!this._ispotsInit && isNew) {
|
|
55
|
-
return;
|
|
89
|
+
return null;
|
|
56
90
|
}
|
|
57
91
|
var ret = this.calcuPosition(iSpot.time, iSpot.duration);
|
|
58
92
|
var style = iSpot.style || {};
|
|
@@ -66,10 +100,10 @@ var APIS = {
|
|
|
66
100
|
'data-time': iSpot.time,
|
|
67
101
|
'data-id': iSpot.id
|
|
68
102
|
}, className);
|
|
69
|
-
Object.keys(style).
|
|
103
|
+
Object.keys(style).forEach(function (key) {
|
|
70
104
|
dotDom.style[key] = style[key];
|
|
71
105
|
});
|
|
72
|
-
|
|
106
|
+
return dotDom;
|
|
73
107
|
},
|
|
74
108
|
/**
|
|
75
109
|
* 根据id查找节点
|
|
@@ -391,20 +391,25 @@ var ProgressPreview = /*#__PURE__*/function (_Plugin) {
|
|
|
391
391
|
value: function calcuPosition(time, duration) {
|
|
392
392
|
var progress = this.player.plugins.progress;
|
|
393
393
|
var player = this.player;
|
|
394
|
-
var totalWidth = progress.root.getBoundingClientRect().width;
|
|
395
|
-
var widthPerSeconds = player.duration / totalWidth * 6;
|
|
396
|
-
var ret = {};
|
|
397
394
|
if (time + duration > player.duration) {
|
|
398
395
|
duration = player.duration - time;
|
|
399
396
|
}
|
|
400
|
-
ret
|
|
401
|
-
ret.width = duration / player.duration;
|
|
402
|
-
ret.isMini = widthPerSeconds > duration;
|
|
403
|
-
return {
|
|
397
|
+
var ret = {
|
|
404
398
|
left: time / player.duration * 100,
|
|
405
399
|
width: duration / player.duration * 100,
|
|
406
|
-
isMini:
|
|
400
|
+
isMini: false
|
|
407
401
|
};
|
|
402
|
+
if (this.config.isDotAdaptWidth) {
|
|
403
|
+
var widthPerSeconds = 0;
|
|
404
|
+
if (player.duration > 0) {
|
|
405
|
+
var totalWidth = progress.root.getBoundingClientRect().width;
|
|
406
|
+
widthPerSeconds = player.duration / totalWidth * 6;
|
|
407
|
+
}
|
|
408
|
+
ret.isMini = widthPerSeconds > duration;
|
|
409
|
+
} else {
|
|
410
|
+
ret.isMini = true;
|
|
411
|
+
}
|
|
412
|
+
return ret;
|
|
408
413
|
}
|
|
409
414
|
}, {
|
|
410
415
|
key: "showDot",
|
|
@@ -551,7 +556,9 @@ var ProgressPreview = /*#__PURE__*/function (_Plugin) {
|
|
|
551
556
|
disable: false,
|
|
552
557
|
width: 160,
|
|
553
558
|
// 显示宽度
|
|
554
|
-
height: 90
|
|
559
|
+
height: 90,
|
|
560
|
+
// 显示高度
|
|
561
|
+
isDotAdaptWidth: true // 故事点是否动态宽度
|
|
555
562
|
};
|
|
556
563
|
}
|
|
557
564
|
}]);
|
package/lib/version.js
CHANGED