timingsrc 1.2.7 → 1.2.8
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/build/es2019/factories/set-timingsrc-with-custom-update-function.d.ts.map +1 -1
- package/build/es2019/factories/set-timingsrc-with-custom-update-function.js +27 -9
- package/build/es2019/factories/set-timingsrc-with-custom-update-function.js.map +1 -1
- package/build/es5/bundle.js +35 -9
- package/package.json +1 -1
- package/src/factories/set-timingsrc-with-custom-update-function.ts +35 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-timingsrc-with-custom-update-function.d.ts","sourceRoot":"","sources":["../../../src/factories/set-timingsrc-with-custom-update-function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iCAAiC,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,eAAO,MAAM,0CAA0C,mBACnC,uBAAuB,YAC7B,QAAQ,MACd,WAAW,sBACK,WAAW,+BAA+B,CAAC,uEAG7C,gBAAgB,gBAChB,aAAa,2FAED,IAAI,GAAG,iCAAiC,
|
|
1
|
+
{"version":3,"file":"set-timingsrc-with-custom-update-function.d.ts","sourceRoot":"","sources":["../../../src/factories/set-timingsrc-with-custom-update-function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iCAAiC,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,eAAO,MAAM,0CAA0C,mBACnC,uBAAuB,YAC7B,QAAQ,MACd,WAAW,sBACK,WAAW,+BAA+B,CAAC,uEAG7C,gBAAgB,gBAChB,aAAa,2FAED,IAAI,GAAG,iCAAiC,eA8DzE,CAAC"}
|
|
@@ -8,16 +8,34 @@ export const createSetTimingsrcWithCustomUpdateFunction = (animationFrame, docum
|
|
|
8
8
|
const sanitizedDuration = typeof duration === 'number' && !isNaN(duration) ? duration : 0;
|
|
9
9
|
const { position, velocity } = previousUpdateVectorWithCustomState;
|
|
10
10
|
updateMediaElement(currentTime, sanitizedDuration, mediaElement, playbackRate, position, velocity);
|
|
11
|
+
return velocity !== 0;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
let unsubscribe;
|
|
14
|
+
const updateOnce = () => {
|
|
15
|
+
if (!update()) {
|
|
16
|
+
unsubscribe();
|
|
17
|
+
unsubscribe = updateReactively();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const updateConsistently = () => {
|
|
21
|
+
const unsubscribeFunctions = [
|
|
22
|
+
animationFrame()(() => updateOnce()),
|
|
23
|
+
on(timingObject, 'change')(() => {
|
|
24
|
+
if (document.visibilityState === 'hidden') {
|
|
25
|
+
updateOnce();
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
];
|
|
29
|
+
return () => unsubscribeFunctions.forEach((unsubscribeFunction) => unsubscribeFunction());
|
|
30
|
+
};
|
|
31
|
+
const updateReactively = () => on(timingObject, 'change')(() => {
|
|
32
|
+
if (update()) {
|
|
33
|
+
unsubscribe();
|
|
34
|
+
unsubscribe = updateConsistently();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
unsubscribe = update() ? updateConsistently() : updateReactively();
|
|
38
|
+
return () => unsubscribe();
|
|
21
39
|
};
|
|
22
40
|
};
|
|
23
41
|
//# sourceMappingURL=set-timingsrc-with-custom-update-function.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-timingsrc-with-custom-update-function.js","sourceRoot":"","sources":["../../../src/factories/set-timingsrc-with-custom-update-function.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,0CAA0C,GAAG,CACtD,cAAuC,EACvC,QAAkB,EAClB,EAAe,EACf,kBAA+D,EACjE,EAAE;IACA,OAAO,CACH,YAA8B,EAC9B,YAA2B,EAC3B,cAA4D,EAC5D,2BAAqE,IAAI,EAC3E,EAAE;QACA,IAAI,mCAAmC,GAAuC,IAAI,CAAC;QAEnF,MAAM,MAAM,GAAG,GAAG,EAAE;YAChB,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC;YAC7D,MAAM,iBAAiB,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;YAE/C,mCAAmC,GAAG,cAAc,CAChD,wBAAwB,KAAK,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,wBAAwB,CAAC,iBAAiB,CAAC,EACnG,WAAW,EACX,mCAAmC,CACtC,CAAC;YAEF,MAAM,iBAAiB,GAAG,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1F,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,mCAAmC,CAAC;YAEnE,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"set-timingsrc-with-custom-update-function.js","sourceRoot":"","sources":["../../../src/factories/set-timingsrc-with-custom-update-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AAG,EAAE,CAAC,UAAU,EAAE,CAAC;gBACpC,EAAE,CACE,YAAY,EACZ,QAAQ,CACX,CAAC,GAAG,EAAE;oBACH,IAAI,QAAQ,CAAC,eAAe,KAAK,QAAQ,EAAE;wBACvC,UAAU,EAAE,CAAC;qBAChB;gBACL,CAAC,CAAC;aACL,CAAC;YAEF,OAAO,GAAG,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAC9F,CAAC,CAAC;QACF,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAC1B,EAAE,CACE,YAAY,EACZ,QAAQ,CACX,CAAC,GAAG,EAAE;YACH,IAAI,MAAM,EAAE,EAAE;gBACV,WAAW,EAAE,CAAC;gBAEd,WAAW,GAAG,kBAAkB,EAAE,CAAC;aACtC;QACL,CAAC,CAAC,CAAC;QAEP,WAAW,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAEnE,OAAO,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/B,CAAC,CAAC;AACN,CAAC,CAAC"}
|
package/build/es5/bundle.js
CHANGED
|
@@ -69,20 +69,46 @@
|
|
|
69
69
|
position = _previousUpdateVector.position,
|
|
70
70
|
velocity = _previousUpdateVector.velocity;
|
|
71
71
|
updateMediaElement(currentTime, sanitizedDuration, mediaElement, playbackRate, position, velocity);
|
|
72
|
+
return velocity !== 0;
|
|
72
73
|
};
|
|
73
74
|
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
75
|
+
var unsubscribe;
|
|
76
|
+
|
|
77
|
+
var updateOnce = function updateOnce() {
|
|
78
|
+
if (!update()) {
|
|
79
|
+
unsubscribe();
|
|
80
|
+
unsubscribe = updateReactively();
|
|
79
81
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
var updateConsistently = function updateConsistently() {
|
|
85
|
+
var unsubscribeFunctions = [animationFrame()(function () {
|
|
86
|
+
return updateOnce();
|
|
87
|
+
}), on(timingObject, 'change')(function () {
|
|
88
|
+
if (document.visibilityState === 'hidden') {
|
|
89
|
+
updateOnce();
|
|
90
|
+
}
|
|
91
|
+
})];
|
|
92
|
+
return function () {
|
|
93
|
+
return unsubscribeFunctions.forEach(function (unsubscribeFunction) {
|
|
94
|
+
return unsubscribeFunction();
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var updateReactively = function updateReactively() {
|
|
100
|
+
return on(timingObject, 'change')(function () {
|
|
101
|
+
if (update()) {
|
|
102
|
+
unsubscribe();
|
|
103
|
+
unsubscribe = updateConsistently();
|
|
104
|
+
}
|
|
84
105
|
});
|
|
85
106
|
};
|
|
107
|
+
|
|
108
|
+
unsubscribe = update() ? updateConsistently() : updateReactively();
|
|
109
|
+
return function () {
|
|
110
|
+
return unsubscribe();
|
|
111
|
+
};
|
|
86
112
|
};
|
|
87
113
|
};
|
|
88
114
|
|
package/package.json
CHANGED
|
@@ -32,20 +32,48 @@ export const createSetTimingsrcWithCustomUpdateFunction = (
|
|
|
32
32
|
const { position, velocity } = previousUpdateVectorWithCustomState;
|
|
33
33
|
|
|
34
34
|
updateMediaElement(currentTime, sanitizedDuration, mediaElement, playbackRate, position, velocity);
|
|
35
|
+
|
|
36
|
+
return velocity !== 0;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
let unsubscribe: () => void;
|
|
40
|
+
|
|
41
|
+
const updateOnce = () => {
|
|
42
|
+
if (!update()) {
|
|
43
|
+
unsubscribe();
|
|
44
|
+
|
|
45
|
+
unsubscribe = updateReactively();
|
|
46
|
+
}
|
|
35
47
|
};
|
|
48
|
+
const updateConsistently = () => {
|
|
49
|
+
const unsubscribeFunctions = [
|
|
50
|
+
animationFrame()(() => updateOnce()),
|
|
51
|
+
on(
|
|
52
|
+
timingObject,
|
|
53
|
+
'change'
|
|
54
|
+
)(() => {
|
|
55
|
+
if (document.visibilityState === 'hidden') {
|
|
56
|
+
updateOnce();
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
];
|
|
36
60
|
|
|
37
|
-
|
|
38
|
-
|
|
61
|
+
return () => unsubscribeFunctions.forEach((unsubscribeFunction) => unsubscribeFunction());
|
|
62
|
+
};
|
|
63
|
+
const updateReactively = () =>
|
|
39
64
|
on(
|
|
40
65
|
timingObject,
|
|
41
66
|
'change'
|
|
42
67
|
)(() => {
|
|
43
|
-
if (
|
|
44
|
-
|
|
68
|
+
if (update()) {
|
|
69
|
+
unsubscribe();
|
|
70
|
+
|
|
71
|
+
unsubscribe = updateConsistently();
|
|
45
72
|
}
|
|
46
|
-
})
|
|
47
|
-
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
unsubscribe = update() ? updateConsistently() : updateReactively();
|
|
48
76
|
|
|
49
|
-
return () =>
|
|
77
|
+
return () => unsubscribe();
|
|
50
78
|
};
|
|
51
79
|
};
|