mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge branch 'master' into ios-safe-area
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user