fix(content): fix scroll events

fixes #15244
This commit is contained in:
Manu Mtz.-Almeida
2018-08-20 19:34:12 +02:00
parent 359c47f7b8
commit 962578e17f

View File

@ -142,17 +142,18 @@ export class Content {
private onScroll(ev: UIEvent) { private onScroll(ev: UIEvent) {
const timeStamp = Date.now(); const timeStamp = Date.now();
const didStart = !this.isScrolling; const shouldStart = !this.isScrolling;
this.lastScroll = timeStamp; this.lastScroll = timeStamp;
if (didStart) { if (shouldStart) {
this.onScrollStart(); this.onScrollStart();
} }
if (!this.queued && this.scrollEvents) { if (!this.queued && this.scrollEvents) {
this.queued = true; this.queued = true;
this.queue.read(ts => { this.queue.read(ts => {
this.queued = false; this.queued = false;
this.detail.event = ev; this.detail.event = ev;
updateScrollDetail(this.detail, this.el, ts, didStart); updateScrollDetail(this.detail, this.scrollEl, ts, shouldStart);
this.ionScroll.emit(this.detail); this.ionScroll.emit(this.detail);
}); });
} }
@ -337,21 +338,22 @@ function getPageElement(el: HTMLElement) {
// ******** DOM READ **************** // ******** DOM READ ****************
function updateScrollDetail( function updateScrollDetail(
detail: ScrollDetail, detail: ScrollDetail,
el: HTMLElement, el: Element,
timestamp: number, timestamp: number,
didStart: boolean shouldStart: boolean
) { ) {
const prevX = detail.currentX; const prevX = detail.currentX;
const prevY = detail.currentY; const prevY = detail.currentY;
const prevT = detail.timeStamp; const prevT = detail.timeStamp;
const currentX = el.scrollLeft; const currentX = el.scrollLeft;
const currentY = el.scrollTop; const currentY = el.scrollTop;
if (didStart) { if (shouldStart) {
// remember the start positions // remember the start positions
detail.startTimeStamp = timestamp; detail.startTimeStamp = timestamp;
detail.startX = currentX; detail.startX = currentX;
detail.startY = currentY; detail.startY = currentY;
detail.velocityX = detail.velocityY = 0; detail.velocityX = detail.velocityY = 0;
console.log('hhhhhh');
} }
detail.timeStamp = timestamp; detail.timeStamp = timestamp;
detail.currentX = detail.scrollLeft = currentX; detail.currentX = detail.scrollLeft = currentX;