Skip to content

Commit

Permalink
fix: remove ScrollLocker touchmove (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaodahong committed Dec 25, 2020
1 parent d2fc8eb commit 4013b7d
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions src/Dom/scrollLocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,6 @@ export interface scrollLockOptions {
container: HTMLElement;
}

let passiveSupported = false;
if (typeof window !== 'undefined') {
const passiveTestOption = {
get passive() {
passiveSupported = true;
return null;
},
};

window.addEventListener('testPassive', null, passiveTestOption);
// @ts-ignore compatible passive
window.removeEventListener('testPassive', null, passiveTestOption);
}

const preventDefault = (event: React.TouchEvent | TouchEvent): boolean => {
const e = event || window.event;

// If more than one touch we don't prevent
if ((e as TouchEvent).touches.length > 1) return true;

if (e.preventDefault) e.preventDefault();

return false;
};

interface Ilocks {
target: typeof uuid;
options: scrollLockOptions;
Expand Down Expand Up @@ -109,12 +84,6 @@ export default class ScrollLocker {
if (!scrollingEffectClassNameReg.test(containerClassName)) {
const addClassName = `${containerClassName} ${scrollingEffectClassName}`;
container.className = addClassName.trim();

document.addEventListener(
'touchmove',
preventDefault,
passiveSupported ? { passive: false } : undefined,
);
}

locks = [...locks, { target: this.lockTarget, options: this.options }];
Expand Down Expand Up @@ -145,12 +114,5 @@ export default class ScrollLocker {
container.className = container.className
.replace(scrollingEffectClassNameReg, '')
.trim();

// @ts-ignore compatible passive
document.removeEventListener(
'touchmove',
preventDefault,
passiveSupported ? { passive: false } : undefined,
);
};
}

0 comments on commit 4013b7d

Please sign in to comment.