constrain progress display 0-1
This commit is contained in:
parent
770a7d1c22
commit
86d84173a4
2 changed files with 6 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { UAParser } from 'ua-parser-js';
|
||||
import videoDecoder from './videoDecoder';
|
||||
import { debounce, isScrollPositionAtTarget, map } from './utils';
|
||||
import { debounce, isScrollPositionAtTarget, map, constrain } from './utils';
|
||||
import { createComponentState, type ScrollerVideoState } from './state.svelte';
|
||||
|
||||
interface ScrollerVideoArgs {
|
||||
|
|
@ -954,8 +954,10 @@ class ScrollerVideo {
|
|||
*/
|
||||
updateDebugInfo() {
|
||||
this.componentState.generalData.src = this.src;
|
||||
this.componentState.generalData.videoPercentage = parseFloat(
|
||||
this.videoPercentage.toFixed(4)
|
||||
this.componentState.generalData.videoPercentage = constrain(
|
||||
parseFloat(this.videoPercentage.toFixed(4)),
|
||||
0,
|
||||
1
|
||||
);
|
||||
this.componentState.generalData.frameRate = parseFloat(
|
||||
this.frameRate.toFixed(2)
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ export const isScrollPositionAtTarget = (
|
|||
* @param {number} high - The upper bound.
|
||||
* @returns {number} The constrained value.
|
||||
*/
|
||||
function constrain(n: number, low: number, high: number): number {
|
||||
export function constrain(n: number, low: number, high: number): number {
|
||||
return Math.max(Math.min(n, high), low);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue