decord/source/10069_useAutoPlay.js

70 lines
1.8 KiB
JavaScript
Raw Normal View History

2026-08-08 06:10:11 +00:00
// Module ID: 10069
// Function ID: 10070
2026-07-20 16:05:17 +00:00
// Name: useAutoPlay
2026-07-29 08:29:29 +00:00
// Dependencies: [19]
2026-07-20 16:05:17 +00:00
// Exports: useAutoPlay
2026-08-08 06:10:11 +00:00
// Module 10069 (useAutoPlay)
2026-07-29 08:29:29 +00:00
import noop from "noop";
2026-07-23 10:11:24 +00:00
2026-07-20 16:05:17 +00:00
export const useAutoPlay = function useAutoPlay(autoPlay) {
autoPlay = autoPlay.autoPlay;
const React = tmp;
const autoPlayReverse = autoPlay.autoPlayReverse;
2026-07-23 10:11:24 +00:00
let closure_1 = tmp2;
2026-07-20 16:05:17 +00:00
const autoPlayInterval = autoPlay.autoPlayInterval;
const prev = iter.prev;
const next = iter.next;
let closure_5 = React.useRef();
let closure_6 = React.useRef(!tmp);
2026-07-23 10:11:24 +00:00
const items = [undefined !== autoPlayReverse && autoPlayReverse, autoPlayInterval, prev, next];
2026-07-20 16:05:17 +00:00
const callback = React.useCallback(() => {
2026-07-29 08:29:29 +00:00
if (!ref2.current) {
if (ref.current) {
2026-07-20 16:05:17 +00:00
const _clearTimeout = clearTimeout;
2026-07-29 08:29:29 +00:00
clearTimeout(tmp.current);
2026-07-20 16:05:17 +00:00
}
const _setTimeout = setTimeout;
2026-07-29 08:29:29 +00:00
ref.current = setTimeout(() => {
if (closure_1) {
let obj = { onFinished: null };
obj[0] = closure_7;
callback(obj);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
obj = { onFinished: null };
obj[0] = closure_7;
callback2(obj);
2026-07-20 16:05:17 +00:00
}
}, autoPlayInterval);
}
}, items);
const items1 = [undefined !== autoPlay && autoPlay];
const pause = React.useCallback(() => {
2026-07-29 08:29:29 +00:00
if (noop) {
if (ref.current) {
2026-07-20 16:05:17 +00:00
const _clearTimeout = clearTimeout;
2026-07-29 08:29:29 +00:00
clearTimeout(tmp.current);
2026-07-20 16:05:17 +00:00
}
closure_6.current = true;
}
}, items1);
const items2 = [callback, undefined !== autoPlay && autoPlay];
const start = React.useCallback(() => {
2026-07-29 08:29:29 +00:00
if (noop) {
2026-07-20 16:05:17 +00:00
closure_6.current = false;
callback();
}
}, items2);
const items3 = [pause, start, undefined !== autoPlay && autoPlay];
const effect = React.useEffect(() => {
2026-07-29 08:29:29 +00:00
if (noop) {
2026-07-20 16:05:17 +00:00
start();
} else {
pause();
}
return pause;
}, items3);
return { pause, start };
};