fix(scroll): scroll issues in UIWebView

fixes #11081
fixes #10976
fixes #10966
fixes #10936
fixes #11051
fixes #10889
This commit is contained in:
Manuel Mtz-Almeida
2017-04-06 15:04:17 +02:00
parent 9316f73b81
commit db37072c40
4 changed files with 25 additions and 24 deletions

View File

@@ -137,7 +137,7 @@ export function setupEvents(plt: Platform, dom: DomController): Events {
let contentEle = <any>el.closest('.scroll-content');
if (contentEle) {
var style = contentEle.style;
var scroll = new ScrollView(null, plt, dom, false);
var scroll = new ScrollView(null, plt, dom);
scroll._el = contentEle;
// We need to stop scrolling if it's happening and scroll up

View File

@@ -14,11 +14,10 @@ export class ScrollView {
onScroll: (ev: ScrollEvent) => void;
onScrollEnd: (ev: ScrollEvent) => void;
initialized: boolean = false;
eventsEnabled: boolean = false;
contentTop: number;
contentBottom: number;
_el: HTMLElement;
private _eventsEnabled = false;
private _js: boolean;
private _t: number = 0;
private _l: number = 0;
@@ -28,10 +27,8 @@ export class ScrollView {
constructor(
private _app: App,
private _plt: Platform,
private _dom: DomController,
virtualScrollEventAssist: boolean
private _dom: DomController
) {
this._js = virtualScrollEventAssist;
this.ev = {
timeStamp: 0,
scrollTop: 0,
@@ -57,19 +54,20 @@ export class ScrollView {
init(ele: HTMLElement, contentTop: number, contentBottom: number) {
assert(ele, 'scroll-view, element can not be null');
this._el = ele;
this.contentTop = contentTop;
this.contentBottom = contentBottom;
if (!this.initialized) {
this.initialized = true;
if (this._js) {
this.enableJsScroll();
this.enableJsScroll(contentTop, contentBottom);
} else {
this.enableNativeScrolling();
}
}
}
enableEvents() {
this._eventsEnabled = true;
}
private enableNativeScrolling() {
assert(this.onScrollStart, 'onScrollStart is not defined');
assert(this.onScroll, 'onScroll is not defined');
@@ -91,7 +89,7 @@ export class ScrollView {
self._app.setScrolling();
// if events are disabled, we do nothing
if (!self.eventsEnabled) {
if (!self._eventsEnabled) {
return;
}
@@ -200,7 +198,7 @@ export class ScrollView {
* inertia then this can be burned to the ground. iOS's more modern
* WKWebView does not have this issue, only UIWebView does.
*/
enableJsScroll() {
enableJsScroll(contentTop: number, contentBottom: number) {
const self = this;
self._js = true;
const ele = self._el;
@@ -219,7 +217,7 @@ export class ScrollView {
function setMax() {
if (!max) {
// ******** DOM READ ****************
max = ele.scrollHeight - ele.parentElement.offsetHeight + self.contentTop + self.contentBottom;
max = ele.scrollHeight - ele.parentElement.offsetHeight + contentTop + contentBottom;
}
};