| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,6 @@ const androidBackPressedEvent = "androidBackPressed"; | |||
| 31 | 31 | const modalMap = new Map<number, DialogOptions>(); | |
| 32 | 32 | ||
| 33 | 33 | let TouchListener: TouchListener; | |
| 34 | - let disableUserInteractionListener: org.nativescript.widgets.DisableUserInteractionListener; | ||
| 35 | 34 | let DialogFragment: DialogFragment; | |
| 36 | 35 | ||
| 37 | 36 | interface DialogOptions { | |
@@ -50,14 +49,6 @@ interface DialogFragment { | |||
| 50 | 49 | new(): android.support.v4.app.DialogFragment; | |
| 51 | 50 | } | |
| 52 | 51 | ||
| 53 | - function initializeDisabledListener(): void { | ||
| 54 | - if (disableUserInteractionListener) { | ||
| 55 | - return; | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - disableUserInteractionListener = new org.nativescript.widgets.DisableUserInteractionListener(); | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | 52 | function initializeTouchListener(): void { | |
| 62 | 53 | if (TouchListener) { | |
| 63 | 54 | return; | |
@@ -649,9 +640,8 @@ export class View extends ViewCommon { | |||
| 649 | 640 | } | |
| 650 | 641 | ||
| 651 | 642 | [isUserInteractionEnabledProperty.setNative](value: boolean) { | |
| 652 | - if (this.nativeViewProtected.setClickable) { | ||
| 653 | - this.nativeViewProtected.setClickable(value); | ||
| 654 | - } | ||
| 643 | + this.nativeViewProtected.setClickable(value); | ||
| 644 | + this.nativeViewProtected.setFocusable(value); | ||
| 655 | 645 | } | |
| 656 | 646 | ||
| 657 | 647 | [visibilityProperty.getDefault](): Visibility { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ export abstract class ScrollViewBase extends ContentView implements ScrollViewDe | |||
| 11 | 11 | ||
| 12 | 12 | public orientation: Orientation; | |
| 13 | 13 | public scrollBarIndicatorVisible: boolean; | |
| 14 | + public isScrollEnabled: boolean; | ||
| 14 | 15 | ||
| 15 | 16 | public addEventListener(arg: string, callback: any, thisArg?: any) { | |
| 16 | 17 | super.addEventListener(arg, callback, thisArg); | |
@@ -102,4 +103,10 @@ export const scrollBarIndicatorVisibleProperty = new Property<ScrollViewBase, bo | |||
| 102 | 103 | name: "scrollBarIndicatorVisible", defaultValue: true, | |
| 103 | 104 | valueConverter: booleanConverter | |
| 104 | 105 | }); | |
| 105 | - scrollBarIndicatorVisibleProperty.register(ScrollViewBase); | ||
| 106 | + scrollBarIndicatorVisibleProperty.register(ScrollViewBase); | ||
| 107 | + | ||
| 108 | + export const isScrollEnabledProperty = new Property<ScrollViewBase, boolean>({ | ||
| 109 | + name: "isScrollEnabled", defaultValue: true, | ||
| 110 | + valueConverter: booleanConverter | ||
| 111 | + }); | ||
| 112 | + isScrollEnabledProperty.register(ScrollViewBase); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,8 @@ | |||
| 1 | 1 | import { ScrollEventData } from "."; | |
| 2 | - import { ScrollViewBase, layout, scrollBarIndicatorVisibleProperty } from "./scroll-view-common"; | ||
| 2 | + import { | ||
| 3 | + ScrollViewBase, layout, scrollBarIndicatorVisibleProperty, | ||
| 4 | + isUserInteractionEnabledProperty, isScrollEnabledProperty | ||
| 5 | + } from "./scroll-view-common"; | ||
| 3 | 6 | ||
| 4 | 7 | export * from "./scroll-view-common"; | |
| 5 | 8 | ||
@@ -44,6 +47,21 @@ export class ScrollView extends ScrollViewBase { | |||
| 44 | 47 | return nativeView.getScrollableLength() / layout.getDisplayDensity(); | |
| 45 | 48 | } | |
| 46 | 49 | ||
| 50 | + [isUserInteractionEnabledProperty.setNative](value: boolean) { | ||
| 51 | + // NOTE: different behavior on iOS & Android: | ||
| 52 | + // iOS disables user interaction recursively for all subviews as well | ||
| 53 | + this.nativeViewProtected.setClickable(value); | ||
| 54 | + this.nativeViewProtected.setFocusable(value); | ||
| 55 | + this.nativeViewProtected.setScrollEnabled(value); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + [isScrollEnabledProperty.getDefault](): boolean { | ||
| 59 | + return this.nativeViewProtected.getScrollEnabled(); | ||
| 60 | + } | ||
| 61 | + [isScrollEnabledProperty.setNative](value: boolean) { | ||
| 62 | + this.nativeViewProtected.setScrollEnabled(value); | ||
| 63 | + } | ||
| 64 | + | ||
| 47 | 65 | [scrollBarIndicatorVisibleProperty.getDefault](): boolean { | |
| 48 | 66 | return true; | |
| 49 | 67 | } | |
@@ -57,7 +75,7 @@ export class ScrollView extends ScrollViewBase { | |||
| 57 | 75 | ||
| 58 | 76 | public scrollToVerticalOffset(value: number, animated: boolean) { | |
| 59 | 77 | const nativeView = this.nativeViewProtected; | |
| 60 | - if (nativeView && this.orientation === "vertical") { | ||
| 78 | + if (nativeView && this.orientation === "vertical" && this.isScrollEnabled) { | ||
| 61 | 79 | value *= layout.getDisplayDensity(); | |
| 62 | 80 | ||
| 63 | 81 | if (animated) { | |
@@ -70,7 +88,7 @@ export class ScrollView extends ScrollViewBase { | |||
| 70 | 88 | ||
| 71 | 89 | public scrollToHorizontalOffset(value: number, animated: boolean) { | |
| 72 | 90 | const nativeView = this.nativeViewProtected; | |
| 73 | - if (nativeView && this.orientation === "horizontal") { | ||
| 91 | + if (nativeView && this.orientation === "horizontal" && this.isScrollEnabled) { | ||
| 74 | 92 | value *= layout.getDisplayDensity(); | |
| 75 | 93 | ||
| 76 | 94 | if (animated) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,11 @@ export class ScrollView extends ContentView { | |||
| 14 | 14 | */ | |
| 15 | 15 | public static scrollEvent: string; | |
| 16 | 16 | ||
| 17 | + /** | ||
| 18 | + * Gets or sets a value indicating whether scroll is enabled. | ||
| 19 | + */ | ||
| 20 | + isScrollEnabled: boolean; | ||
| 21 | + | ||
| 17 | 22 | /** | |
| 18 | 23 | * Gets a value that contains the vertical offset of the scrolled content. | |
| 19 | 24 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,7 @@ | |||
| 1 | 1 | import { ScrollEventData } from "."; | |
| 2 | - import { View, layout, ScrollViewBase, scrollBarIndicatorVisibleProperty } from "./scroll-view-common"; | ||
| 2 | + import { | ||
| 3 | + View, layout, ScrollViewBase, scrollBarIndicatorVisibleProperty, isScrollEnabledProperty | ||
| 4 | + } from "./scroll-view-common"; | ||
| 3 | 5 | import { ios as iosUtils } from "../../utils/utils"; | |
| 4 | 6 | // HACK: Webpack. Use a fully-qualified import to allow resolve.extensions(.ios.js) to | |
| 5 | 7 | // kick in. `../utils` doesn't seem to trigger the webpack extensions mechanism. | |
@@ -99,6 +101,13 @@ export class ScrollView extends ScrollViewBase { | |||
| 99 | 101 | return Math.max(0, this.nativeViewProtected.contentSize.height - this.nativeViewProtected.bounds.size.height); | |
| 100 | 102 | } | |
| 101 | 103 | ||
| 104 | + [isScrollEnabledProperty.getDefault](): boolean { | ||
| 105 | + return this.nativeViewProtected.scrollEnabled; | ||
| 106 | + } | ||
| 107 | + [isScrollEnabledProperty.setNative](value: boolean) { | ||
| 108 | + this.nativeViewProtected.scrollEnabled = value; | ||
| 109 | + } | ||
| 110 | + | ||
| 102 | 111 | [scrollBarIndicatorVisibleProperty.getDefault](): boolean { | |
| 103 | 112 | return true; | |
| 104 | 113 | } | |
@@ -107,14 +116,14 @@ export class ScrollView extends ScrollViewBase { | |||
| 107 | 116 | } | |
| 108 | 117 | ||
| 109 | 118 | public scrollToVerticalOffset(value: number, animated: boolean) { | |
| 110 | - if (this.nativeViewProtected && this.orientation === "vertical") { | ||
| 119 | + if (this.nativeViewProtected && this.orientation === "vertical" && this.isScrollEnabled) { | ||
| 111 | 120 | const bounds = this.nativeViewProtected.bounds.size; | |
| 112 | 121 | this.nativeViewProtected.scrollRectToVisibleAnimated(CGRectMake(0, value, bounds.width, bounds.height), animated); | |
| 113 | 122 | } | |
| 114 | 123 | } | |
| 115 | 124 | ||
| 116 | 125 | public scrollToHorizontalOffset(value: number, animated: boolean) { | |
| 117 | - if (this.nativeViewProtected && this.orientation === "horizontal") { | ||
| 126 | + if (this.nativeViewProtected && this.orientation === "horizontal" && this.isScrollEnabled) { | ||
| 118 | 127 | const bounds = this.nativeViewProtected.bounds.size; | |
| 119 | 128 | this.nativeViewProtected.scrollRectToVisibleAnimated(CGRectMake(value, 0, bounds.width, bounds.height), animated); | |
| 120 | 129 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -342,11 +342,15 @@ | |||
| 342 | 342 | export class VerticalScrollView extends android.widget.ScrollView { | |
| 343 | 343 | constructor(context: android.content.Context); | |
| 344 | 344 | public getScrollableLength(): number; | |
| 345 | + public getScrollEnabled(): boolean; | ||
| 346 | + public setScrollEnabled(value: boolean): void; | ||
| 345 | 347 | } | |
| 346 | 348 | ||
| 347 | 349 | export class HorizontalScrollView extends android.widget.HorizontalScrollView { | |
| 348 | 350 | constructor(context: android.content.Context); | |
| 349 | 351 | public getScrollableLength(): number; | |
| 352 | + public getScrollEnabled(): boolean; | ||
| 353 | + public setScrollEnabled(value: boolean): void; | ||
| 350 | 354 | } | |
| 351 | 355 | ||
| 352 | 356 | export class ImageView extends android.widget.ImageView { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments