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

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

Issue 1218593002: Move sky/examples to sky/sdk/lib/example, and code changes to support that change. Fixes T277. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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
Index: sky/examples/raw/touch-demo.sky
diff --git a/sky/examples/raw/touch-demo.sky b/sky/examples/raw/touch-demo.sky
deleted file mode 100644
index 16f3de0ecef3cbf6226524e09324ec8282f12bd2..0000000000000000000000000000000000000000
--- a/sky/examples/raw/touch-demo.sky
+++ /dev/null
@@ -1,70 +0,0 @@
-#!mojo mojo:sky_viewer
-<sky>
-<import src="/packages/sky/framework/debug/shake-to-reload.sky" />
-<style>
-dot {
- position: absolute;
- height: 10px;
- width: 10px;
- background-color: #00FF00;
- border-radius: 5px;
- opacity: .75;
-}
-
-log {
- display: paragraph;
- margin-top: 50px;
-}
-</style>
-<log>Touch the screen!</log>
-<script>
-import "dart:sky";
-
-// Material design colors. :p
-List<String> colors = [
- "#009688",
- "#FFC107",
- "#9C27B0",
- "#03A9F4",
- "#673AB7",
- "#CDDC39",
-];
-
-Element whichDot(event) {
- return document.querySelector('dot[id="${event.pointer}"]');
-}
-
-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();
-}
-
-void runToTheCenter(event) {
- double radius = (5 + (95 * event.pressure));
- Element dot = whichDot(event);
- dot.style["transform"] = "translate(${event.x-radius}px,${event.y-radius}px)";
- dot.style["width"] = "${2 * radius}px";
- dot.style["height"] = "${2 * radius}px";
- dot.style["border-radius"] = "${radius}px";
-}
-
-void main() {
- document.addEventListener("pointerdown", moreDots);
- document.addEventListener("pointermove", runToTheCenter);
- document.addEventListener("pointerup", goAway);
- document.addEventListener("pointercancel", stopDots);
-}
-</script>
-</sky>

Powered by Google App Engine
This is Rietveld 408576698