Skip to content

Commit

Permalink
fix(scroll-view): android 'isScrollEnabled' will apply if changed whi…
Browse files Browse the repository at this point in the history
…le gesture is underway (#8695)
  • Loading branch information
CatchABus authored Jul 7, 2020
1 parent 635f31f commit 02ec7f1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions e2e/ui-tests-app/app/scroll-view/main-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
25 changes: 25 additions & 0 deletions e2e/ui-tests-app/app/scroll-view/scroll-enabled-page.ts
Original file line number Diff line number Diff line change
@@ -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 = <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;
}
}
7 changes: 7 additions & 0 deletions e2e/ui-tests-app/app/scroll-view/scroll-enabled-page.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" class="page">
<ScrollView id="scroll-view" height="300">
<StackLayout height="500" backgroundColor="red" pan="panLayout">
<Label text="Move Me" color="#fff" fontSize="22"/>
</StackLayout>
</ScrollView>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 02ec7f1

Please sign in to comment.