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

Side by Side Diff: sky/framework/material-element.sky

Issue 956753002: Make splash animations abort on scroll. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 <!-- 1 <!--
2 // Copyright 2015 The Chromium Authors. All rights reserved. 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 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 --> 5 -->
6 <import src="sky-element.sky" /> 6 <import src="sky-element.sky" />
7 <import src="sky-ink-splash.sky" /> 7 <import src="sky-ink-splash.sky" />
8 <script> 8 <script>
9 import "dart:sky"; 9 import "dart:sky";
10 10
11 HTMLStyleElement _kStyleElement; 11 HTMLStyleElement _kStyleElement;
12 12
13 class MaterialElement extends SkyElement { 13 class MaterialElement extends SkyElement {
14 Set<SkyInkSplash> _activeSplashes = new Set();
15 bool _didAddTransformHack = false;
16
14 MaterialElement() { 17 MaterialElement() {
15 addEventListener('pointerdown', _handlePointerDown); 18 addEventListener('pointerdown', _handlePointerDown);
19 addEventListener('gesturescrollstart', _handleScrollStart);
16 } 20 }
17 21
18 void _handlePointerDown(PointerEvent event) { 22 void addTransformHack() {
23 if (_didAddTransformHack)
24 return;
25 if (style['transform'] != null)
26 return;
27 _didAddTransformHack = true;
19 // We set the transform here to become a container for absolutely positioned 28 // We set the transform here to become a container for absolutely positioned
20 // elements. We should either have a better way of becoming such a container 29 // elements. We should either have a better way of becoming such a container
21 // or we should make every RenderBlock be such a container. 30 // or we should make every RenderBlock be such a container.
22 style['transform'] = 'translateX(0)'; 31 style['transform'] = 'translateX(0)';
32 }
23 33
34 void removeTransformHack() {
35 if (!_didAddTransformHack)
36 return;
37 style.removeProperty('transform');
38 _didAddTransformHack = false;
39 }
40
41 void _handlePointerDown(PointerEvent event) {
42 addTransformHack();
24 ClientRect rect = getBoundingClientRect(); 43 ClientRect rect = getBoundingClientRect();
25 SkyInkSplash splash = new SkyInkSplash(); 44 SkyInkSplash splash = new SkyInkSplash();
26 shadowRoot.prependChild(splash); 45 shadowRoot.prependChild(splash);
27 splash.start(event.x, event.y, rect); 46 splash.start(event.x, event.y, rect).then(_handleSplashComplete);
47 _activeSplashes.add(splash);
48 }
49
50 void _handleSplashComplete(SkyInkSplash splash) {
51 _activeSplashes.remove(splash);
52 if (_activeSplashes.isEmpty)
53 removeTransformHack();
54 }
55
56 void _handleScrollStart(GestureEvent event) {
57 for (SkyInkSplash splash in _activeSplashes) {
abarth-chromium 2015/02/25 02:10:22 It occurs to me that you don't need _activeSplashe
abarth-chromium 2015/02/25 02:10:22 It occurs to me that you don't need _activeSplashe
58 splash.cancel();
59 }
28 } 60 }
29 } 61 }
30 </script> 62 </script>
OLDNEW
« no previous file with comments | « sky/engine/bindings/scripts/templates/interface_cpp.template ('k') | sky/framework/sky-ink-splash.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698