mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
22 lines
514 B
JavaScript
22 lines
514 B
JavaScript
import { throttle, isInViewport } from '../utils';
|
|
|
|
export default function viewInit(art, events) {
|
|
const {
|
|
option,
|
|
constructor,
|
|
template: { $container },
|
|
} = art;
|
|
|
|
const scrollFn = throttle(() => {
|
|
art.emit('view', isInViewport($container, constructor.SCROLL_GAP));
|
|
}, constructor.SCROLL_TIME);
|
|
|
|
events.proxy(window, 'scroll', () => scrollFn());
|
|
|
|
art.on('view', (state) => {
|
|
if (option.autoMini) {
|
|
art.mini = !state;
|
|
}
|
|
});
|
|
}
|