Skip to content

Commit

Permalink
fix(scroll): fix scroll to top on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed Oct 27, 2016
1 parent c1ba120 commit 2d165e1
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/util/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { nativeTimeout } from '../util/dom';
import { nativeTimeout, nativeRaf } from '../util/dom';
import { Platform } from '../platform/platform';
import { ScrollView } from '../util/scroll-view';

Expand Down Expand Up @@ -135,7 +135,29 @@ export function setupEvents(platform: Platform): Events {
let content = <HTMLElement>el.closest('.scroll-content');
if (content) {
var scroll = new ScrollView(content);
scroll.scrollTo(0, 0, 300);
// We need to stop scrolling if it's happening and scroll up

content.style['WebkitBackfaceVisibility'] = 'hidden';
content.style['WebkitTransform'] = 'translate3d(0,0,0)';

nativeRaf(function() {
content.style.overflow = 'hidden';

function finish() {
content.style.overflow = '';
content.style['WebkitBackfaceVisibility'] = '';
content.style['WebkitTransform'] = '';
}

let didScrollTimeout = setTimeout(() => {
finish();
}, 400);

scroll.scrollTo(0, 0, 300).then(() => {
clearTimeout(didScrollTimeout);
finish();
});
});
}
});

Expand Down

0 comments on commit 2d165e1

Please sign in to comment.