Commit a128b096 authored by Eric Seidel's avatar Eric Seidel

Fix multi-touch to work in SkyShell.

Before this patch it crashed.

Also updated the touch-demo to support multi-touch.

R=abarth@chromium.org
BUG=

Review URL: https://codereview.chromium.org/961483004
parent 1a9b6b68
...@@ -6,27 +6,54 @@ dot { ...@@ -6,27 +6,54 @@ dot {
height: 100px; height: 100px;
width: 100px; width: 100px;
background-color: #00FF00; background-color: #00FF00;
border-radius: 50px;
} }
</style> </style>
<dot />
<log>Ready</log> <log>Ready</log>
<script> <script>
import "dart:sky"; import "dart:sky";
final Element dot = document.querySelector("dot"); // Material design colors. :p
List<String> colors = [
"#009688",
"#FFC107",
"#9C27B0",
"#03A9F4",
"#673AB7",
"#CDDC39",
];
void moveDot(event) { Element whichDot(event) {
double x = event.x; return document.querySelector('dot[id="${event.pointer}"]');
double y = event.y; }
void moreDots(event) {
Element dot = document.createElement('dot');
dot.setAttribute('id', "${event.pointer}");
dot.style['background-color'] = colors[event.pointer.remainder(colors.length)];
document.querySelector('sky').appendChild(dot);
runToTheCenter(event);
}
void goAway(event) {
whichDot(event).remove();
}
void stopDots(event) {
for (Element e in document.querySelectorAll('dot'))
e.remove();
}
dot.style["transform"] = "translate(${x-50}px,${y-50}px)"; void runToTheCenter(event) {
whichDot(event).style["transform"] =
"translate(${event.x-50}px,${event.y-50}px)";
} }
void main() { void main() {
document.addEventListener("pointerdown", moveDot); document.addEventListener("pointerdown", moreDots);
document.addEventListener("pointermove", moveDot); document.addEventListener("pointermove", runToTheCenter);
document.addEventListener("pointerup", moveDot); document.addEventListener("pointerup", goAway);
document.addEventListener("pointercancel", moveDot); document.addEventListener("pointercancel", stopDots);
} }
</script> </script>
</sky> </sky>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment