@rixl/media-core 1.0.1 → 1.0.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/progressbar.js +6 -4
- package/package.json +1 -1
package/dist/progressbar.js
CHANGED
|
@@ -9,7 +9,7 @@ const getClientX = (event) => {
|
|
|
9
9
|
};
|
|
10
10
|
const createProgressBarState = (video) => ({
|
|
11
11
|
isDragging: false,
|
|
12
|
-
progress: video.currentTime /
|
|
12
|
+
progress: Number.isFinite(video.duration) && video.duration > 0 ? video.currentTime / video.duration : 0,
|
|
13
13
|
initialRect: null,
|
|
14
14
|
initialClientX: null,
|
|
15
15
|
initialProgress: 0,
|
|
@@ -54,7 +54,8 @@ const resetDragState = (state, onDraggingChange) => {
|
|
|
54
54
|
};
|
|
55
55
|
const createTimeUpdateHandler = (state, video, onProgressChange) => () => {
|
|
56
56
|
if (state.isDragging) return;
|
|
57
|
-
|
|
57
|
+
const progress = Number.isFinite(video.duration) && video.duration > 0 ? video.currentTime / video.duration : 0;
|
|
58
|
+
setProgress(state, progress, onProgressChange);
|
|
58
59
|
};
|
|
59
60
|
const createMoveHandler = (state, onDraggingChange, onProgressChange) => (event) => {
|
|
60
61
|
const clientX = getClientX(event);
|
|
@@ -68,10 +69,11 @@ const createMoveHandler = (state, onDraggingChange, onProgressChange) => (event)
|
|
|
68
69
|
};
|
|
69
70
|
const createEndHandler = ({ state, video, onDraggingChange, onProgressChange, removeListeners }) => () => {
|
|
70
71
|
const clickProgress = !state.hasMoved ? getClickProgress(state) : null;
|
|
72
|
+
const hasValidDuration = Number.isFinite(video.duration) && video.duration > 0;
|
|
71
73
|
if (clickProgress !== null) {
|
|
72
74
|
setProgress(state, clickProgress, onProgressChange);
|
|
73
|
-
video.currentTime = clickProgress * video.duration;
|
|
74
|
-
} else if (state.isDragging &&
|
|
75
|
+
if (hasValidDuration) video.currentTime = clickProgress * video.duration;
|
|
76
|
+
} else if (state.isDragging && hasValidDuration) video.currentTime = state.progress * video.duration;
|
|
75
77
|
resetDragState(state, onDraggingChange);
|
|
76
78
|
removeListeners();
|
|
77
79
|
};
|
package/package.json
CHANGED