Skip to content

Commit

Permalink
fix: fix addEventListener (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Dec 2, 2022
1 parent 4806cfa commit 5805c9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/axes/src/inputType/InputType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,9 @@ export const convertInputType = (inputType: string[] = []): ActiveEvent => {
}
return null;
};

export function getAddEventOptions(eventName: string) {
// The passive default value of the touch event is true.
// If not a touch event, return false to support ie11
return eventName.indexOf("touch") > -1 ? { passive: false } : false;
}
5 changes: 3 additions & 2 deletions packages/axes/src/inputType/PanInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ActiveEvent, ElementType, InputEventType } from "../types";

import {
convertInputType,
getAddEventOptions,
InputType,
InputTypeObserver,
toAxis,
Expand Down Expand Up @@ -373,10 +374,10 @@ export class PanInput implements InputType {

protected _attachWindowEvent(activeEvent: ActiveEvent) {
activeEvent?.move.forEach((event) => {
window.addEventListener(event, this._onPanmove, { passive: false });
window.addEventListener(event, this._onPanmove, getAddEventOptions(event));
});
activeEvent?.end.forEach((event) => {
window.addEventListener(event, this._onPanend, { passive: false });
window.addEventListener(event, this._onPanend, getAddEventOptions(event));
});
}

Expand Down

0 comments on commit 5805c9d

Please sign in to comment.