Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: sky/examples/touch-demo.sky

Issue 803283006: Add a fps-counter widget to some Sky demos (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/examples/spinning-square.sky ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/touch-demo.sky
diff --git a/sky/examples/touch-demo.sky b/sky/examples/touch-demo.sky
index 26c659bc2a5ddd9401ac116d76efbbb2c440668c..dd1d16e0e2624980394eb0dcec15c8d9dfcfddec 100644
--- a/sky/examples/touch-demo.sky
+++ b/sky/examples/touch-demo.sky
@@ -1,11 +1,31 @@
<sky>
-<div id="log">Ready</div>
+<import src="fps-counter.sky" />
+<style>
+dot {
+ position: absolute;
+ height: 100px;
+ width: 100px;
+ background-color: #00FF00;
+}
+</style>
+<dot />
+<log>Ready</log>
+<x-fps-counter />
ojan 2015/01/15 18:54:57 Does this work? Shouldn't this just be fps-counter
abarth-chromium 2015/01/15 19:09:38 Oops. We did this to comment it out. I'll add it
<script>
+var dot = document.querySelector("dot");
+var log = document.querySelector("log");
+
function logTouchEvent(evt) {
var message = "type=" + event.type;
- if (evt.touches && evt.touches.length > 0)
- message += " x=" + evt.touches[0].clientX + " y=" + evt.touches[0].clientY;
- document.getElementById("log").textContent = message;
+ if (evt.touches && evt.touches.length > 0) {
+ var x = evt.touches[0].clientX.toFixed(2);
+ var y = evt.touches[0].clientY.toFixed(2);
+ message += " x=" + x + " y=" + y;
+
+ var transform = "translate(" + (x - 50) + "px," + (y - 50) + "px)";
+ dot.style.transform = transform;
+ }
+ log.textContent = message;
}
document.documentElement.addEventListener("touchstart", logTouchEvent);
@@ -14,3 +34,4 @@ document.documentElement.addEventListener("touchend", logTouchEvent);
document.documentElement.addEventListener("touchcancel", logTouchEvent);
</script>
</sky>
+s
esprehn 2015/01/14 23:48:54 typo
« no previous file with comments | « sky/examples/spinning-square.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698