Merge branch 'master' into ios-safe-area

This commit is contained in:
Martin Yankov
2018-09-26 18:39:42 +03:00
committed by GitHub
48 changed files with 632 additions and 521 deletions

View File

@@ -38,10 +38,15 @@ export class ScrollView extends ScrollViewBase {
private _contentMeasuredWidth: number = 0;
private _contentMeasuredHeight: number = 0;
private _delegate: UIScrollViewDelegateImpl;
public createNativeView() {
const view = UIScrollView.new();
return view;
}
constructor() {
super();
this.nativeViewProtected = UIScrollView.new();
initNativeView() {
super.initNativeView();
this.updateScrollBarVisibility(this.scrollBarIndicatorVisible);
this._setNativeClipToBounds();
}
@@ -60,6 +65,9 @@ export class ScrollView extends ScrollViewBase {
}
protected updateScrollBarVisibility(value) {
if (!this.nativeViewProtected) {
return;
}
if (this.orientation === "horizontal") {
this.nativeViewProtected.showsHorizontalScrollIndicator = value;
} else {
@@ -68,15 +76,15 @@ export class ScrollView extends ScrollViewBase {
}
get horizontalOffset(): number {
return this.nativeViewProtected.contentOffset.x;
return this.nativeViewProtected ? this.nativeViewProtected.contentOffset.x : 0;
}
get verticalOffset(): number {
return this.nativeViewProtected.contentOffset.y;
return this.nativeViewProtected ? this.nativeViewProtected.contentOffset.y : 0;
}
get scrollableWidth(): number {
if (this.orientation !== "horizontal") {
if (!this.nativeViewProtected || this.orientation !== "horizontal") {
return 0;
}
@@ -84,7 +92,7 @@ export class ScrollView extends ScrollViewBase {
}
get scrollableHeight(): number {
if (this.orientation !== "vertical") {
if (!this.nativeViewProtected || this.orientation !== "vertical") {
return 0;
}
@@ -99,14 +107,14 @@ export class ScrollView extends ScrollViewBase {
}
public scrollToVerticalOffset(value: number, animated: boolean) {
if (this.orientation === "vertical") {
if (this.nativeViewProtected && this.orientation === "vertical") {
const bounds = this.nativeViewProtected.bounds.size;
this.nativeViewProtected.scrollRectToVisibleAnimated(CGRectMake(0, value, bounds.width, bounds.height), animated);
}
}
public scrollToHorizontalOffset(value: number, animated: boolean) {
if (this.orientation === "horizontal") {
if (this.nativeViewProtected && this.orientation === "horizontal") {
const bounds = this.nativeViewProtected.bounds.size;
this.nativeViewProtected.scrollRectToVisibleAnimated(CGRectMake(value, 0, bounds.width, bounds.height), animated);
}
@@ -192,4 +200,4 @@ function getTabBarHeight(scrollView: ScrollView): number {
return 0;
}
ScrollView.prototype.recycleNativeView = "auto";
ScrollView.prototype.recycleNativeView = "auto";