UNPKG

dile-smooth-scroll

Version:

Webcomponent dile-smooth-scroll smooth scroll component

23 lines (18 loc) 547 B
export const DileSmoothScrollElementMixin = (Superclass) => class extends Superclass { smoothElementScrollTop(element) { this.smoothElementScroll(element, 0, 0); } smoothElementScrollBottom(element) { this.smoothElementScroll(element, element.scrollHeight, 0); } smoothElementScroll(element, top, left) { if(element) { element.scroll({ top, left, behavior: 'smooth' }); } } smoothElementScrollBy(element, top, left) { if(element) { element.scrollBy({ top, left, behavior: 'smooth' }); } } }