primevue-mirror/components/utils/ConnectedOverlayScrollHandl...

32 lines
901 B
JavaScript
Raw Normal View History

import DomHandler from './DomHandler';
export default class ConnectedOverlayScrollHandler {
2020-09-28 10:24:10 +00:00
constructor(element, listener = () => {}) {
this.element = element;
this.listener = listener;
}
bindScrollListener() {
this.scrollableParents = DomHandler.getScrollableParents(this.element);
2022-09-14 11:26:01 +00:00
for (let i = 0; i < this.scrollableParents.length; i++) {
2020-09-28 10:24:10 +00:00
this.scrollableParents[i].addEventListener('scroll', this.listener);
}
}
unbindScrollListener() {
if (this.scrollableParents) {
for (let i = 0; i < this.scrollableParents.length; i++) {
2020-09-28 10:24:10 +00:00
this.scrollableParents[i].removeEventListener('scroll', this.listener);
}
}
}
2020-09-28 10:24:10 +00:00
destroy() {
this.unbindScrollListener();
this.element = null;
this.listener = null;
this.scrollableParents = null;
}
}