mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Add pan event test page
This commit is contained in:
@ -86,6 +86,7 @@ examples.set("padding", "padding/padding");
|
||||
examples.set("timePicker", "time-picker/time-picker");
|
||||
examples.set("gestures", "pages/gestures");
|
||||
examples.set("touch", "pages/touch-event");
|
||||
examples.set("pan", "pages/pan-event");
|
||||
examples.set("handlers", "pages/handlers");
|
||||
|
||||
examples.set("animeBG", "animations/background");
|
||||
|
23
apps/ui-tests-app/pages/pan-event.ts
Normal file
23
apps/ui-tests-app/pages/pan-event.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { EventData } from "data/observable";
|
||||
import { Page } from "ui/page";
|
||||
import { PanGestureEventData } from "ui/gestures";
|
||||
import { View } from "ui/core/view";
|
||||
import { TextView } from "ui/text-view";
|
||||
|
||||
var view: View;
|
||||
export function navigatingTo(args: EventData) {
|
||||
var page = <Page>args.object;
|
||||
view = page.getViewById("target");
|
||||
}
|
||||
|
||||
export function onPan(data: PanGestureEventData) {
|
||||
console.log(`data state:${data.state} [${data.deltaX}, ${data.deltaY}]`);
|
||||
var msg = `data state:${data.state} [${data.deltaX}, ${data.deltaY}]`;
|
||||
(<TextView>view.page.getViewById("output")).text += msg + "\n";
|
||||
view.translateX = data.deltaX;
|
||||
view.translateY = data.deltaY;
|
||||
}
|
||||
|
||||
export function clear(args) {
|
||||
args.object.page.getViewById("output").text = "";
|
||||
}
|
7
apps/ui-tests-app/pages/pan-event.xml
Normal file
7
apps/ui-tests-app/pages/pan-event.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<Page navigatingTo="navigatingTo">
|
||||
<GridLayout rows="*, auto, *" >
|
||||
<GridLayout backgroundColor="lightgreen" id="target" automationText="target" width="100" height="100" pan="onPan"/>
|
||||
<Button row="1" text="clear" tap="clear"/>
|
||||
<TextView row="2" text="here" id="output" automationText="output" style="font-size: 10, font-family: monospace;"/>
|
||||
</GridLayout>
|
||||
</Page>
|
Reference in New Issue
Block a user