octicon-rss(16/)
You've already forked ionic-framework
mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
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/)
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
@@ -86,6 +86,7 @@ export class ItemSliding implements ComponentInterface {
|
||||
componentDidUnload() {
|
||||
if (this.gesture) {
|
||||
this.gesture.destroy();
|
||||
this.gesture = undefined;
|
||||
}
|
||||
|
||||
this.item = null;
|
||||
|
||||
@@ -201,6 +201,7 @@ export class Menu implements ComponentInterface, MenuI {
|
||||
}
|
||||
if (this.gesture) {
|
||||
this.gesture.destroy();
|
||||
this.gesture = undefined;
|
||||
}
|
||||
|
||||
this.animation = undefined;
|
||||
|
||||
@@ -130,6 +130,7 @@ export class Nav implements NavOutlet {
|
||||
|
||||
if (this.gesture) {
|
||||
this.gesture.destroy();
|
||||
this.gesture = undefined;
|
||||
}
|
||||
|
||||
// release swipe back gesture and transition
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -120,6 +120,10 @@ export class Refresher implements ComponentInterface {
|
||||
|
||||
componentDidUnload() {
|
||||
this.scrollEl = undefined;
|
||||
if (this.gesture) {
|
||||
this.gesture.destroy();
|
||||
this.gesture = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user