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