UNPKG

jjb-lc-designable

Version:

基于alibaba-designable源码二次封装的表单设计器。

27 lines 942 B
import { EventDriver, globalThisPolyfill } from 'jjb-lc-designable/shared'; import { ViewportScrollEvent } from '../events'; export class ViewportScrollDriver extends EventDriver { request = null; onScroll = e => { e.preventDefault(); this.request = globalThisPolyfill.requestAnimationFrame(() => { this.dispatch(new ViewportScrollEvent({ scrollX: this.contentWindow.scrollX, scrollY: this.contentWindow.scrollY, width: this.contentWindow.document.body.clientWidth, height: this.contentWindow.document.body.clientHeight, innerHeight: this.contentWindow.innerHeight, innerWidth: this.contentWindow.innerWidth, view: this.contentWindow, target: e.target })); cancelAnimationFrame(this.request); }); }; attach() { this.addEventListener('scroll', this.onScroll); } detach() { this.removeEventListener('scroll', this.onScroll); } }