-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtouches-color.js
45 lines (38 loc) · 1.08 KB
/
touches-color.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const { TextView, ui } = require('tabris')
let textView = new TextView({
left: 20,
top: 20,
right: 20,
text: 'Touch anywhere...'
}).appendTo(ui.contentView)
ui.contentView.on({
touchStart: ({ touches }) => {
printXY('touchStart', touches)
ui.contentView.background = 'yellow'
},
touchMove: ({ touches }) => {
printXY('touchMove', touches)
var blue = Math.round(touches[0].x) - 100
console.log(blue)
ui.contentView.background = 'rgb(255, 0, ' + blue + ')'
},
touchEnd: ({ touches }) => {
printXY('touchEnd', touches)
var blue = Math.round(touches[0].x) - 100
console.log(blue)
ui.contentView.background = 'rgb(255, 0, ' + blue + ')'
},
touchCancel: ({ touches }) => {
printXY('touchCancel', touches)
ui.contentView.background = 'red'
},
longpress: ({ touches }) => {
ui.contentView.background = 'blue'
printXY('longpress', touches)
}
})
function printXY (prefix, touches) {
textView.text =
prefix + ': ' + Math.round(touches[0].x) + ' X ' + Math.round(touches[0].y)
// console.log(Math.round(touches[0].x))
}