| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import '../animation/curves.dart'; | 5 import '../animation/curves.dart'; |
| 6 import '../animation/generator.dart'; | 6 import '../animation/generator.dart'; |
| 7 import '../fn.dart'; | 7 import '../fn.dart'; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:sky' as sky; | 9 import 'dart:sky' as sky; |
| 10 | 10 |
| 11 const double _kSplashSize = 400.0; | 11 const double _kSplashSize = 400.0; |
| 12 const double _kSplashDuration = 500.0; | 12 const double _kSplashDuration = 500.0; |
| 13 | 13 |
| 14 class SplashAnimation { | 14 class SplashAnimation { |
| 15 AnimationGenerator _animation; | 15 AnimationGenerator _animation; |
| 16 double _offsetX; | 16 double _offsetX; |
| 17 double _offsetY; | 17 double _offsetY; |
| 18 | 18 |
| 19 Stream<String> _styleChanged; | 19 Stream<String> _styleChanged; |
| 20 | 20 |
| 21 Stream<String> get onStyleChanged => _styleChanged; | 21 Stream<String> get onStyleChanged => _styleChanged; |
| 22 | 22 |
| 23 void cancel() => _animation.cancel(); | 23 void cancel() => _animation.cancel(); |
| 24 | 24 |
| 25 SplashAnimation(sky.ClientRect rect, double x, double y, | 25 SplashAnimation(sky.ClientRect rect, double x, double y, |
| 26 { Function onDone }) | 26 { Function onDone }) |
| 27 : _offsetX = x - rect.left, | 27 : _offsetX = x - rect.left, |
| 28 _offsetY = y - rect.top { | 28 _offsetY = y - rect.top { |
| 29 | 29 |
| 30 _animation = new AnimationGenerator(_kSplashDuration, | 30 _animation = new AnimationGenerator( |
| 31 end: _kSplashSize, curve: easeOut, onDone: onDone); | 31 duration:_kSplashDuration, |
| 32 end: _kSplashSize, |
| 33 curve: easeOut, |
| 34 onDone: onDone); |
| 32 | 35 |
| 33 _styleChanged = _animation.onTick.map((p) => ''' | 36 _styleChanged = _animation.onTick.map((p) => ''' |
| 34 top: ${_offsetY - p/2}px; | 37 top: ${_offsetY - p/2}px; |
| 35 left: ${_offsetX - p/2}px; | 38 left: ${_offsetX - p/2}px; |
| 36 width: ${p}px; | 39 width: ${p}px; |
| 37 height: ${p}px; | 40 height: ${p}px; |
| 38 border-radius: ${p}px; | 41 border-radius: ${p}px; |
| 39 opacity: ${1.0 - (p / _kSplashSize)}; | 42 opacity: ${1.0 - (p / _kSplashSize)}; |
| 40 '''); | 43 '''); |
| 41 } | 44 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 styles: [_style], | 97 styles: [_style], |
| 95 children: [ | 98 children: [ |
| 96 new Container( | 99 new Container( |
| 97 inlineStyle: _inlineStyle, | 100 inlineStyle: _inlineStyle, |
| 98 styles: [_splashStyle] | 101 styles: [_splashStyle] |
| 99 ) | 102 ) |
| 100 ] | 103 ] |
| 101 ); | 104 ); |
| 102 } | 105 } |
| 103 } | 106 } |
| OLD | NEW |