fix(gesture): destroy gesture handler when it's done (#17184)

fixes #16433
fixes #16974
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
Manu MA
2019-01-21 02:01:44 +01:00
committed by GitHub
gitea-unlock(16/)
parent 766c79d2a1
commit 59bd823d05
octicon-diff(16/tw-mr-1) 9 changed files with 37 additions and 7 deletions

1
core/src/components/item-sliding/item-sliding.tsx
View File

@@ -86,6 +86,7 @@ export class ItemSliding implements ComponentInterface {
componentDidUnload() {
if (this.gesture) {
this.gesture.destroy();
this.gesture = undefined;
}
this.item = null;

1
core/src/components/menu/menu.tsx
View File

@@ -201,6 +201,7 @@ export class Menu implements ComponentInterface, MenuI {
}
if (this.gesture) {
this.gesture.destroy();
this.gesture = undefined;
}
this.animation = undefined;

1
core/src/components/nav/nav.tsx
View File

@@ -130,6 +130,7 @@ export class Nav implements NavOutlet {
if (this.gesture) {
this.gesture.destroy();
this.gesture = undefined;
}
// release swipe back gesture and transition

4
core/src/components/picker-column/picker-column.tsx
View File

@@ -82,6 +82,10 @@ export class PickerColumnCmp implements ComponentInterface {
componentDidUnload() {
cancelAnimationFrame(this.rafId);
clearTimeout(this.tmrId);
if (this.gesture) {
this.gesture.destroy();
this.gesture = undefined;
}
}
private setSelected(selectedIndex: number, duration: number) {

7
core/src/components/range/range.tsx
View File

@@ -183,6 +183,13 @@ export class Range implements ComponentInterface {
this.gesture.setDisabled(this.disabled);
}
componentDidUnload() {
if (this.gesture) {
this.gesture.destroy();
this.gesture = undefined;
}
}
private handleKeyboard = (knob: KnobName, isIncrease: boolean) => {
let step = this.step;
step = step > 0 ? step : 1;

4
core/src/components/refresher/refresher.tsx
View File

@@ -120,6 +120,10 @@ export class Refresher implements ComponentInterface {
componentDidUnload() {
this.scrollEl = undefined;
if (this.gesture) {
this.gesture.destroy();
this.gesture = undefined;
}
}
/**

15
core/src/components/reorder-group/reorder-group.tsx
View File

@@ -84,6 +84,10 @@ export class ReorderGroup implements ComponentInterface {
componentDidUnload() {
this.onEnd();
if (this.gesture) {
this.gesture.destroy();
this.gesture = undefined;
}
}
/**
@@ -106,7 +110,6 @@ export class ReorderGroup implements ComponentInterface {
}
const item = findReorderItem(reorderEl, this.el);
if (!item) {
console.error('reorder node not found');
return false;
}
ev.data = item;
@@ -303,16 +306,14 @@ function indexForItem(element: any): number {
return element['$ionIndex'];
}
function findReorderItem(node: HTMLElement, container: HTMLElement): HTMLElement | undefined {
let nested = 0;
let parent;
while (node && nested < 6) {
parent = node.parentNode as HTMLElement;
function findReorderItem(node: HTMLElement | null, container: HTMLElement): HTMLElement | undefined {
let parent: HTMLElement | null;
while (node) {
parent = node.parentElement;
if (parent === container) {
return node;
}
node = parent;
nested++;
}
return undefined;
}

4
core/src/components/router-outlet/route-outlet.tsx
View File

@@ -83,6 +83,10 @@ export class RouterOutlet implements ComponentInterface, NavOutlet {
componentDidUnload() {
this.activeEl = this.activeComponent = undefined;
if (this.gesture) {
this.gesture.destroy();
this.gesture = undefined;
}
}
/** @internal */

7
core/src/components/toggle/toggle.tsx
View File

@@ -118,6 +118,13 @@ export class Toggle implements ComponentInterface {
this.disabledChanged();
}
componentDidUnload() {
if (this.gesture) {
this.gesture.destroy();
this.gesture = undefined;
}
}
@Listen('click')
onClick() {
if (this.lastDrag + 300 < Date.now()) {