30 lines
3.8 KiB
JavaScript
30 lines
3.8 KiB
JavaScript
import { DomHandler } from './domhandler';
|
|
export class ConnectedOverlayScrollHandler {
|
|
element;
|
|
listener;
|
|
scrollableParents;
|
|
constructor(element, listener = () => { }) {
|
|
this.element = element;
|
|
this.listener = listener;
|
|
}
|
|
bindScrollListener() {
|
|
this.scrollableParents = DomHandler.getScrollableParents(this.element);
|
|
for (let i = 0; i < this.scrollableParents.length; i++) {
|
|
this.scrollableParents[i].addEventListener('scroll', this.listener);
|
|
}
|
|
}
|
|
unbindScrollListener() {
|
|
if (this.scrollableParents) {
|
|
for (let i = 0; i < this.scrollableParents.length; i++) {
|
|
this.scrollableParents[i].removeEventListener('scroll', this.listener);
|
|
}
|
|
}
|
|
}
|
|
destroy() {
|
|
this.unbindScrollListener();
|
|
this.element = null;
|
|
this.listener = null;
|
|
this.scrollableParents = null;
|
|
}
|
|
}
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29ubmVjdGVkb3ZlcmxheXNjcm9sbGhhbmRsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBwL2NvbXBvbmVudHMvZG9tL2Nvbm5lY3RlZG92ZXJsYXlzY3JvbGxoYW5kbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFFMUMsTUFBTSxPQUFPLDZCQUE2QjtJQUN0QyxPQUFPLENBQU07SUFFYixRQUFRLENBQU07SUFFZCxpQkFBaUIsQ0FBTTtJQUV2QixZQUFZLE9BQVksRUFBRSxXQUFnQixHQUFHLEVBQUUsR0FBRSxDQUFDO1FBQzlDLElBQUksQ0FBQyxPQUFPLEdBQUcsT0FBTyxDQUFDO1FBQ3ZCLElBQUksQ0FBQyxRQUFRLEdBQUcsUUFBUSxDQUFDO0lBQzdCLENBQUM7SU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