Skip to content

Commit

Permalink
fix(content): tap-click deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Jan 18, 2019
1 parent a6559a4 commit 36eee46
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
23 changes: 15 additions & 8 deletions core/src/components/content/content.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ComponentInterface, Element, Event, EventEmitter, Method, Prop, QueueApi } from '@stencil/core';
import { Component, ComponentInterface, Element, Event, EventEmitter, Method, Prop, QueueApi, Listen } from '@stencil/core';

import { Color, Config, Mode, ScrollBaseDetail, ScrollDetail } from '../../interface';
import { isPlatform } from '../../utils/platform';
Expand Down Expand Up @@ -113,8 +113,14 @@ export class Content implements ComponentInterface {
}

componentDidUnload() {
if (this.watchDog) {
clearInterval(this.watchDog);
this.onScrollEnd();
}

@Listen('click', { capture: true })
onClick(ev: Event) {
if (this.isScrolling) {
ev.preventDefault();
ev.stopPropagation();
}
}

Expand Down Expand Up @@ -269,13 +275,14 @@ export class Content implements ComponentInterface {
}

private onScrollEnd() {

clearInterval(this.watchDog);
this.watchDog = null;
this.isScrolling = false;
this.ionScrollEnd.emit({
isScrolling: false
});
if (this.isScrolling) {
this.isScrolling = false;
this.ionScrollEnd.emit({
isScrolling: false
});
}
}

hostData() {
Expand Down
15 changes: 15 additions & 0 deletions core/src/components/nav/test/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
--ion-background-color-rgb: 0,0,0;
--ion-text-color-rgb: 255,255,255;
}

[f] {
background: green;
width: 100px;
height: 100px;
}
</style>
<script>
class PageOne extends HTMLElement {
Expand Down Expand Up @@ -74,6 +80,15 @@ <h1>Page Two</h1>
<ion-button class="next">Go to Page Three</ion-button>
</ion-nav-push>
</div>
<div f></div>
<div f></div>
<div f></div>
<div f></div>
<div f></div>
<div f></div>
<div f></div>
<div f></div>
</ion-content>
`;
}
Expand Down
9 changes: 0 additions & 9 deletions core/src/utils/tap-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ export function startTapClick(doc: Document, config: Config) {
const useRippleEffect = config.getBoolean('animated', true) && config.getBoolean('rippleEffect', true);
const clearDefers = new WeakMap<HTMLElement, any>();

function onBodyClick(ev: Event) {
if (cancelled || scrolling) {
ev.preventDefault();
ev.stopPropagation();
cancelled = false;
}
}

// Touch Events
function onTouchStart(ev: TouchEvent) {
lastTouch = now(ev);
Expand Down Expand Up @@ -145,7 +137,6 @@ export function startTapClick(doc: Document, config: Config) {
}
}

doc.addEventListener('click', onBodyClick, true);
doc.addEventListener('ionScrollStart', () => {
scrolling = true;
cancelActive();
Expand Down

0 comments on commit 36eee46

Please sign in to comment.