diff --git a/e2e/ui-tests-app/app/scroll-view/main-page.ts b/e2e/ui-tests-app/app/scroll-view/main-page.ts index 6f84bec333..8089762eaf 100644 --- a/e2e/ui-tests-app/app/scroll-view/main-page.ts +++ b/e2e/ui-tests-app/app/scroll-view/main-page.ts @@ -17,6 +17,7 @@ export function loadExamples() { examples.set("safe-area-images", "scroll-view/safe-area-images-page"); examples.set("safe-area-images-overflow", "scroll-view/safe-area-images-overflow-page"); examples.set("layout-outside-scroll", "scroll-view/layout-outside-scroll-page"); + examples.set("scroll-enabled", "scroll-view/scroll-enabled-page"); return examples; } diff --git a/e2e/ui-tests-app/app/scroll-view/scroll-enabled-page.ts b/e2e/ui-tests-app/app/scroll-view/scroll-enabled-page.ts new file mode 100644 index 0000000000..4be65ab521 --- /dev/null +++ b/e2e/ui-tests-app/app/scroll-view/scroll-enabled-page.ts @@ -0,0 +1,25 @@ +import { EventData as ObservableEventData } from "tns-core-modules/data/observable"; +import { GestureStateTypes, PanGestureEventData } from "tns-core-modules/ui/gestures"; +import { Page } from "tns-core-modules/ui/page"; + +export function pageLoaded(args: ObservableEventData) { + var page = args.object; +} + +export function panLayout(args: PanGestureEventData) +{ + const scrollView = args.object.parent; + + if (args.state === GestureStateTypes.began) { + args.object.previousDeltaY = 0; + scrollView.isScrollEnabled = false; + } + else if (args.state === GestureStateTypes.changed) { + const diff = (args.deltaY - args.object.previousDeltaY); + args.object.translateY += diff; + args.object.previousDeltaY = args.deltaY; + } + else if (args.state === GestureStateTypes.ended) { + scrollView.isScrollEnabled = true; + } +} diff --git a/e2e/ui-tests-app/app/scroll-view/scroll-enabled-page.xml b/e2e/ui-tests-app/app/scroll-view/scroll-enabled-page.xml new file mode 100644 index 0000000000..ee85aac1dd --- /dev/null +++ b/e2e/ui-tests-app/app/scroll-view/scroll-enabled-page.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/HorizontalScrollView.java b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/HorizontalScrollView.java index c634897199..af8a051252 100644 --- a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/HorizontalScrollView.java +++ b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/HorizontalScrollView.java @@ -70,7 +70,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) { @Override public boolean onTouchEvent(MotionEvent ev) { - if (!this.scrollEnabled && ev.getAction() == MotionEvent.ACTION_DOWN) { + if (!this.scrollEnabled && (ev.getAction() == MotionEvent.ACTION_DOWN || ev.getAction() == MotionEvent.ACTION_MOVE)) { return false; } diff --git a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/VerticalScrollView.java b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/VerticalScrollView.java index db109467cb..23144c2d92 100644 --- a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/VerticalScrollView.java +++ b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/VerticalScrollView.java @@ -70,7 +70,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) { @Override public boolean onTouchEvent(MotionEvent ev) { - if (!this.scrollEnabled && ev.getAction() == MotionEvent.ACTION_DOWN) { + if (!this.scrollEnabled && (ev.getAction() == MotionEvent.ACTION_DOWN || ev.getAction() == MotionEvent.ACTION_MOVE)) { return false; }