Skip to content

Commit

Permalink
fix(core): events attached before didPresent callback (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-rr committed Feb 20, 2022
1 parent ae71786 commit 5b49dc3
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 49 deletions.
21 changes: 7 additions & 14 deletions dist/cupertino-pane.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1197,12 +1197,6 @@ class Transitions {
this.isPaneHidden = false;
}
// Emit event
if (params.type === CupertinoTransition.Present) {
this.settings.onDidPresent();
}
if (params.type === CupertinoTransition.Destroy) {
this.settings.onDidDismiss({ destroyButton: params.destroyButton });
}
this.settings.onTransitionEnd({ target: document.body.contains(this.instance.paneEl) ? this.instance.paneEl : null });
// Remove listener
this.instance.paneEl.removeEventListener('transitionend', transitionEnd);
Expand Down Expand Up @@ -1673,6 +1667,9 @@ class CupertinoPane {
this.contentEl.style.display = 'block';
this.wrapperEl.classList.add('rendered');
this.rendered = true;
// set overflow element
this.scrollElementInit();
this.checkOverflowAttr(this.breakpoints.currentBreakpoint);
if (this.settings.followerElement) {
if (!document.querySelector(this.settings.followerElement)) {
console.warn('Cupertino Pane: wrong follower element selector specified', this.settings.followerElement);
Expand Down Expand Up @@ -1724,15 +1721,11 @@ class CupertinoPane {
if (this.settings.zStack) {
this.settings.zStack.pushElements.forEach(item => this.zStack.pushTransition(document.querySelector(item), this.breakpoints.breaks[this.settings.initialBreak], 'unset'));
}
// Emit event
this.settings.onDidPresent();
}
// Some timeout to get offsetTop
yield new Promise((resolve) => setTimeout(() => resolve(true), 150));
this.scrollElementInit();
this.checkOverflowAttr(this.breakpoints.currentBreakpoint);
/****** Attach Events *******/
this.events.attachAllEvents();
// Emit event
this.settings.onDidPresent();
return this;
});
}
Expand Down Expand Up @@ -2013,9 +2006,9 @@ class CupertinoPane {
}
else {
this.destroyResets();
// Emit event
this.settings.onDidDismiss({ destroyButton: conf.destroyButton });
}
// Emit event
this.settings.onDidDismiss({ destroyButton: conf.destroyButton });
});
}
destroyResets() {
Expand Down
2 changes: 1 addition & 1 deletion dist/cupertino-pane.esm.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cupertino-pane.esm.min.js.map

Large diffs are not rendered by default.

22 changes: 7 additions & 15 deletions dist/cupertino-pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -1203,12 +1203,6 @@
this.isPaneHidden = false;
}
// Emit event
if (params.type === CupertinoTransition.Present) {
this.settings.onDidPresent();
}
if (params.type === CupertinoTransition.Destroy) {
this.settings.onDidDismiss({ destroyButton: params.destroyButton });
}
this.settings.onTransitionEnd({ target: document.body.contains(this.instance.paneEl) ? this.instance.paneEl : null });
// Remove listener
this.instance.paneEl.removeEventListener('transitionend', transitionEnd);
Expand Down Expand Up @@ -1679,6 +1673,9 @@
this.contentEl.style.display = 'block';
this.wrapperEl.classList.add('rendered');
this.rendered = true;
// set overflow element
this.scrollElementInit();
this.checkOverflowAttr(this.breakpoints.currentBreakpoint);
if (this.settings.followerElement) {
if (!document.querySelector(this.settings.followerElement)) {
console.warn('Cupertino Pane: wrong follower element selector specified', this.settings.followerElement);
Expand Down Expand Up @@ -1730,15 +1727,11 @@
if (this.settings.zStack) {
this.settings.zStack.pushElements.forEach(item => this.zStack.pushTransition(document.querySelector(item), this.breakpoints.breaks[this.settings.initialBreak], 'unset'));
}
// Emit event
this.settings.onDidPresent();
}
// Some timeout to get offsetTop
yield new Promise((resolve) => setTimeout(() => resolve(true), 150));
this.scrollElementInit();
this.checkOverflowAttr(this.breakpoints.currentBreakpoint);
/****** Attach Events *******/
this.events.attachAllEvents();
// Emit event
this.settings.onDidPresent();
return this;
});
}
Expand Down Expand Up @@ -2019,9 +2012,9 @@
}
else {
this.destroyResets();
// Emit event
this.settings.onDidDismiss({ destroyButton: conf.destroyButton });
}
// Emit event
this.settings.onDidDismiss({ destroyButton: conf.destroyButton });
});
}
destroyResets() {
Expand All @@ -2042,4 +2035,3 @@
return CupertinoPane;

}));
//# sourceMappingURL=cupertino-pane.js.map
1 change: 0 additions & 1 deletion dist/cupertino-pane.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion dist/cupertino-pane.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cupertino-pane.min.js.map

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions src/cupertino-pane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ export class CupertinoPane {
this.wrapperEl.classList.add('rendered');
this.rendered = true;

// set overflow element
this.scrollElementInit();
this.checkOverflowAttr(this.breakpoints.currentBreakpoint);

if (this.settings.followerElement) {
if (!<HTMLElement>document.querySelector(this.settings.followerElement)) {
console.warn('Cupertino Pane: wrong follower element selector specified', this.settings.followerElement);
Expand Down Expand Up @@ -344,18 +348,14 @@ export class CupertinoPane {
)
);
}
// Emit event
this.settings.onDidPresent();
}

// Some timeout to get offsetTop
await new Promise((resolve) => setTimeout(() => resolve(true), 150));
this.scrollElementInit();
this.checkOverflowAttr(this.breakpoints.currentBreakpoint);

/****** Attach Events *******/
this.events.attachAllEvents();

// Emit event
this.settings.onDidPresent();

return this;
}

Expand Down Expand Up @@ -715,9 +715,10 @@ export class CupertinoPane {
await this.transitions.doTransition({type: 'destroy', translateY: this.screenHeightOffset, destroyButton: conf.destroyButton});
} else {
this.destroyResets();
// Emit event
this.settings.onDidDismiss({destroyButton: conf.destroyButton} as any);
}

// Emit event
this.settings.onDidDismiss({destroyButton: conf.destroyButton} as any);
}

public destroyResets(): void {
Expand Down
6 changes: 0 additions & 6 deletions src/transitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ export class Transitions {
}

// Emit event
if (params.type === CupertinoTransition.Present) {
this.settings.onDidPresent();
}
if (params.type === CupertinoTransition.Destroy) {
this.settings.onDidDismiss({destroyButton: params.destroyButton} as any);
}
this.settings.onTransitionEnd({target: document.body.contains(this.instance.paneEl) ? this.instance.paneEl : null});

// Remove listener
Expand Down

0 comments on commit 5b49dc3

Please sign in to comment.