This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-demo/src/DraggableDemo.ts

44 lines
1.4 KiB
TypeScript
Raw Normal View History

import { Panel, Group, vlayout, layoutConfig, draggable, Color, Text, modal, Gravity, stack, text } from "doric";
2020-01-02 20:02:21 +08:00
import { title } from "./utils";
@Entry
class DraggableDemo extends Panel {
build(root: Group) {
2020-01-04 19:13:15 +08:00
let textView: Text
let drag = draggable(
textView = text({
layoutConfig: layoutConfig().just().configAlignment(Gravity.Center),
width: 100,
height: 30,
textColor: Color.RED,
onClick: () => {
modal(context).toast('Clicked')
}
}),
{
onDrag: (x: number, y: number) => {
textView.text = "x: " + x.toFixed(0) + " y: " + y.toFixed(0)
},
layoutConfig: layoutConfig().just(),
width: 100,
height: 100,
backgroundColor: Color.WHITE
2020-01-04 14:43:28 +08:00
})
2020-01-04 19:13:15 +08:00
vlayout(
[
title("Draggable Demo"),
stack(
[
drag,
],
{
layoutConfig: layoutConfig().most()
})
],
{
2020-01-02 20:02:21 +08:00
layoutConfig: layoutConfig().most(),
backgroundColor: Color.BLACK
})
.in(root)
}
}