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

30 lines
923 B
TypeScript
Raw Normal View History

2020-01-02 20:02:21 +08:00
import { Panel, Group, vlayout, layoutConfig, draggable, Color, Text} from "doric";
import { title } from "./utils";
@Entry
class DraggableDemo extends Panel {
build(root: Group) {
let text = (new Text).also(it => {
it.layoutConfig = layoutConfig().most()
it.textColor = Color.parse('#ff0000')
})
vlayout([
title("Draggable Demo"),
draggable({
onDrag: (x: number, y: number) => {
text.text = "x: " + x + " y: " + y
}
}, [ text ]).apply({
layoutConfig: layoutConfig().just(),
width: 100,
height: 100,
backgroundColor: Color.WHITE
})
])
.apply({
layoutConfig: layoutConfig().most(),
backgroundColor: Color.BLACK
})
.in(root)
}
}