Skip to content

Commit

Permalink
fix: rewrote the scrollBehavior method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandrshy committed Jun 22, 2020
1 parent a113019 commit 23f98ef
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Keukenhof = ((): KeukenhofType => {
this.scrollBehavior = {
isDisabled: true,
container: 'body',
defaultValue: 'visible',
defaultValue: '',
...scrollBehavior,
};

Expand Down Expand Up @@ -116,18 +116,11 @@ export const Keukenhof = ((): KeukenhofType => {
*/
changeScrollBehavior(value: 'disable' | 'enable') {
if (!this.scrollBehavior.isDisabled) return;
const element = document.querySelector(this.scrollBehavior.container);
const element = document.querySelector<HTMLElement>(this.scrollBehavior.container);
if (!element) return;
switch (value) {
case SCROLL_STATE.DISABLE:
element.setAttribute('style', 'overflow: hidden;');
break;
case SCROLL_STATE.ENABLE:
element.setAttribute('style', `overflow: ${this.scrollBehavior.defaultValue};`);
break;
default:
break;
}
if (value === SCROLL_STATE.ENABLE)
element.style.overflow = this.scrollBehavior.defaultValue;
else if (value === SCROLL_STATE.DISABLE) element.style.overflow = 'hidden';
}
}

Expand Down

0 comments on commit 23f98ef

Please sign in to comment.