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

Side by Side Diff: sky/framework/sky-ink-splash.sky

Issue 999873002: Move sky-*.sky into framework/elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: One missing Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « sky/framework/sky-icon.sky ('k') | sky/framework/sky-input.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!--
2 // Copyright 2015 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 -->
6 <import src="sky-element.sky" />
7
8 <sky-element>
9 <template>
10 <style>
11 :host {
12 position: absolute;
13 pointer-events: none;
14 overflow: hidden;
15 top: 0;
16 left: 0;
17 bottom: 0;
18 right: 0;
19 }
20
21 #splash {
22 position: absolute;
23 background-color: rgba(0, 0, 0, 0.4);
24 border-radius: 0;
25 top: 0;
26 left: 0;
27 height: 0;
28 width: 0;
29 }
30 </style>
31 <div id="splash" />
32 </template>
33 <script>
34 import "animation/controller.dart";
35 import "animation/curves.dart";
36 import "animation/timer.dart";
37 import "dart:math" as math;
38 import "dart:sky";
39 import "dart:async";
40
41 const double _kSplashSize = 400.0;
42 const double _kSplashDuration = 500.0;
43
44 @Tagname('sky-ink-splash')
45 class SkyInkSplash extends SkyElement implements AnimationDelegate {
46 AnimationController _animation;
47 Element _splash;
48 double _offsetX;
49 double _offsetY;
50 Completer<SkyInkSplash> _completer = new Completer();
51
52 SkyInkSplash() {
53 _animation = new AnimationController(this);
54 }
55
56 void shadowRootReady() {
57 _splash = shadowRoot.getElementById('splash');
58 }
59
60 Future start(double x, double y, ClientRect rect) {
61 _offsetX = x - rect.left;
62 _offsetY = y - rect.top;
63 _animation.start(
64 begin: 0.0,
65 end: _kSplashSize,
66 duration: _kSplashDuration,
67 curve: easeOut);
68 return _completer.future;
69 }
70
71 void _done() {
72 remove();
73 _completer.complete(this);
74 }
75
76 void cancel() {
77 // TODO(eseidel): Should fade away instead of stopping immediately.
78 _animation.stop();
79 _done();
80 }
81
82 void updateAnimation(double p) {
83 if (p == _kSplashSize) {
84 _done();
85 return;
86 }
87 _splash.style['top'] = '${_offsetY - p/2}px';
88 _splash.style['left'] = '${_offsetX - p/2}px';
89 _splash.style['width'] = '${p}px';
90 _splash.style['height'] = '${p}px';
91 _splash.style['border-radius'] = '${p}px';
92 _splash.style['opacity'] = '${1.0 - (p / _kSplashSize)}';
93 }
94 }
95
96 _init(script) => register(script, SkyInkSplash);
97 </script>
98 </sky-element>
OLDNEW
« no previous file with comments | « sky/framework/sky-icon.sky ('k') | sky/framework/sky-input.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698