mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-15 00:56:16 -08:00
15 lines
480 B
JavaScript
15 lines
480 B
JavaScript
import { debounce } from '../utils';
|
|
|
|
export default function autoPip(art) {
|
|
const { events, player, template } = art;
|
|
const scrollDebounce = debounce(() => {
|
|
const { top, height } = template.$player.getBoundingClientRect();
|
|
if (top + height <= 0 && !player.pip && player.playing) {
|
|
player.pip = true;
|
|
} else if (player.pip) {
|
|
player.pip = false;
|
|
}
|
|
}, 300);
|
|
events.proxy(window, 'scroll', scrollDebounce);
|
|
}
|