| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e1eea8e commit b8e0bec
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,5 +12,7 @@ export function pageLoaded(args: EventData) { | |||
| 12 | 12 | export function loadExamples() { | |
| 13 | 13 | const examples = new Map<string, string>(); | |
| 14 | 14 | examples.set("scrolling-and-sizing", "scroll-view/scrolling-and-sizing"); | |
| 15 | + examples.set("safe-area-root-element", "scroll-view/safe-area-root-element"); | ||
| 16 | + examples.set("safe-area-sub-element", "scroll-view/safe-area-sub-element"); | ||
| 15 | 17 | return examples; | |
| 16 | 18 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,15 @@ | |||
| 1 | + <Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo" class="page"> | ||
| 2 | + | ||
| 3 | + <Page.actionBar> | ||
| 4 | + <ActionBar title="My App" icon="" class="action-bar"> | ||
| 5 | + </ActionBar> | ||
| 6 | + </Page.actionBar> | ||
| 7 | + | ||
| 8 | + <ScrollView> | ||
| 9 | + <StackLayout> | ||
| 10 | + <GridLayout height="30" backgroundColor="red" /> | ||
| 11 | + <GridLayout height="30" backgroundColor="yellow" /> | ||
| 12 | + <GridLayout height="30" backgroundColor="green" /> | ||
| 13 | + </StackLayout> | ||
| 14 | + </ScrollView> | ||
| 15 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + <Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo" class="page"> | ||
| 2 | + | ||
| 3 | + <Page.actionBar> | ||
| 4 | + <ActionBar title="My App" icon="" class="action-bar"> | ||
| 5 | + </ActionBar> | ||
| 6 | + </Page.actionBar> | ||
| 7 | + | ||
| 8 | + <GridLayout> | ||
| 9 | + <ScrollView height="50" verticalAlignment="top"> | ||
| 10 | + <StackLayout> | ||
| 11 | + <GridLayout height="30" backgroundColor="red" /> | ||
| 12 | + <GridLayout height="30" backgroundColor="yellow" /> | ||
| 13 | + <GridLayout height="30" backgroundColor="green" /> | ||
| 14 | + </StackLayout> | ||
| 15 | + </ScrollView> | ||
| 16 | + </GridLayout> | ||
| 17 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -372,6 +372,10 @@ export abstract class ViewBase extends Observable { | |||
| 372 | 372 | public _isPaddingRelative: boolean; | |
| 373 | 373 | public _styleScope: any; | |
| 374 | 374 | ||
| 375 | + /** | ||
| 376 | + * @private | ||
| 377 | + */ | ||
| 378 | + public _automaticallyAdjustsScrollViewInsets: boolean; | ||
| 375 | 379 | /** | |
| 376 | 380 | * @private | |
| 377 | 381 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -178,7 +178,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition | |||
| 178 | 178 | private _templateParent: ViewBase; | |
| 179 | 179 | private __nativeView: any; | |
| 180 | 180 | // private _disableNativeViewRecycling: boolean; | |
| 181 | - | ||
| 181 | + | ||
| 182 | 182 | public domNode: dnm.DOMNode; | |
| 183 | 183 | ||
| 184 | 184 | public recycleNativeView: "always" | "never" | "auto"; | |
@@ -199,6 +199,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition | |||
| 199 | 199 | public _suspendedUpdates: { [propertyName: string]: Property<ViewBase, any> | CssProperty<Style, any> | CssAnimationProperty<Style, any> }; | |
| 200 | 200 | public _suspendNativeUpdatesCount: SuspendType; | |
| 201 | 201 | public _isStyleScopeHost: boolean; | |
| 202 | + public _automaticallyAdjustsScrollViewInsets: boolean; | ||
| 202 | 203 | ||
| 203 | 204 | // Dynamic properties. | |
| 204 | 205 | left: Length; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -592,6 +592,8 @@ export namespace ios { | |||
| 592 | 592 | ||
| 593 | 593 | export function updateAutoAdjustScrollInsets(controller: UIViewController, owner: View): void { | |
| 594 | 594 | const scrollable = isContentScrollable(controller, owner); | |
| 595 | + | ||
| 596 | + owner._automaticallyAdjustsScrollViewInsets = scrollable; | ||
| 595 | 597 | controller.automaticallyAdjustsScrollViewInsets = scrollable; | |
| 596 | 598 | } | |
| 597 | 599 | ||
@@ -733,7 +735,7 @@ export namespace ios { | |||
| 733 | 735 | if(!owner){ | |
| 734 | 736 | return; | |
| 735 | 737 | } | |
| 736 | - | ||
| 738 | + | ||
| 737 | 739 | updateAutoAdjustScrollInsets(this, owner); | |
| 738 | 740 | ||
| 739 | 741 | if (!owner.parent) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,14 @@ | |||
| 1 | 1 | import { ScrollEventData } from "."; | |
| 2 | 2 | import { View, layout, ScrollViewBase, scrollBarIndicatorVisibleProperty } from "./scroll-view-common"; | |
| 3 | + import { ios as iosUtils } from "../../utils/utils"; | ||
| 3 | 4 | // HACK: Webpack. Use a fully-qualified import to allow resolve.extensions(.ios.js) to | |
| 4 | 5 | // kick in. `../utils` doesn't seem to trigger the webpack extensions mechanism. | |
| 5 | 6 | import * as uiUtils from "tns-core-modules/ui/utils"; | |
| 6 | 7 | ||
| 7 | 8 | export * from "./scroll-view-common"; | |
| 8 | 9 | ||
| 10 | + const majorVersion = iosUtils.MajorVersion; | ||
| 11 | + | ||
| 9 | 12 | class UIScrollViewDelegateImpl extends NSObject implements UIScrollViewDelegate { | |
| 10 | 13 | private _owner: WeakRef<ScrollView>; | |
| 11 | 14 | ||
@@ -61,7 +64,7 @@ export class ScrollView extends ScrollViewBase { | |||
| 61 | 64 | this.nativeViewProtected.showsHorizontalScrollIndicator = value; | |
| 62 | 65 | } else { | |
| 63 | 66 | this.nativeViewProtected.showsVerticalScrollIndicator = value; | |
| 64 | - } | ||
| 67 | + } | ||
| 65 | 68 | } | |
| 66 | 69 | ||
| 67 | 70 | get horizontalOffset(): number { | |
@@ -92,7 +95,7 @@ export class ScrollView extends ScrollViewBase { | |||
| 92 | 95 | return true; | |
| 93 | 96 | } | |
| 94 | 97 | [scrollBarIndicatorVisibleProperty.setNative](value: boolean) { | |
| 95 | - this.updateScrollBarVisibility(value); | ||
| 98 | + this.updateScrollBarVisibility(value); | ||
| 96 | 99 | } | |
| 97 | 100 | ||
| 98 | 101 | public scrollToVerticalOffset(value: number, animated: boolean) { | |
@@ -120,6 +123,16 @@ export class ScrollView extends ScrollViewBase { | |||
| 120 | 123 | const child = this.layoutView; | |
| 121 | 124 | this._contentMeasuredWidth = this.effectiveMinWidth; | |
| 122 | 125 | this._contentMeasuredHeight = this.effectiveMinHeight; | |
| 126 | + | ||
| 127 | + // `_automaticallyAdjustsScrollViewInsets` is set to true only if the first child | ||
| 128 | + // of UIViewController (Page, TabView e.g) is UIScrollView (ScrollView, ListView e.g). | ||
| 129 | + // On iOS 11 by default UIScrollView automatically adjusts the scroll view insets, but they s | ||
| 130 | + if (majorVersion > 10 && !this.parent._automaticallyAdjustsScrollViewInsets) { | ||
| 131 | + // Disable automatic adjustment of scroll view insets when ScrollView | ||
| 132 | + // is not the first child of UIViewController. | ||
| 133 | + this.nativeViewProtected.contentInsetAdjustmentBehavior = 2; | ||
| 134 | + } | ||
| 135 | + | ||
| 123 | 136 | if (child) { | |
| 124 | 137 | let childSize: { measuredWidth: number; measuredHeight: number }; | |
| 125 | 138 | if (this.orientation === "vertical") { | |
@@ -165,7 +178,7 @@ export class ScrollView extends ScrollViewBase { | |||
| 165 | 178 | } | |
| 166 | 179 | ||
| 167 | 180 | public _onOrientationChanged() { | |
| 168 | - this.updateScrollBarVisibility(this.scrollBarIndicatorVisible); | ||
| 181 | + this.updateScrollBarVisibility(this.scrollBarIndicatorVisible); | ||
| 169 | 182 | } | |
| 170 | 183 | } | |
| 171 | 184 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments