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

Unified Diff: sky/framework/components/drawer.dart

Issue 1126333006: [Effen] Make the drawer not be included in the build output when the drawer is not shown. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: git cl land Created 5 years, 7 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/framework/components/animated_component.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/components/drawer.dart
diff --git a/sky/framework/components/drawer.dart b/sky/framework/components/drawer.dart
index 888ed7dc74cb1ae16a215038afc7d7d271149605..b1e1a1be975b3bd7080600800967203b5973c8f0 100644
--- a/sky/framework/components/drawer.dart
+++ b/sky/framework/components/drawer.dart
@@ -17,17 +17,30 @@ const double _kBaseSettleDurationMS = 246.0;
const double _kMaxSettleDurationMS = 600.0;
const Curve _kAnimationCurve = parabolicRise;
+typedef void DrawerStatusChangeHandler (bool showing);
+
class DrawerController {
- final AnimatedValue position = new AnimatedValue(-_kWidth);
- bool get isClosed => position.value == -_kWidth;
+ DrawerController(this.onStatusChange) {
+ position = new AnimatedValue(-_kWidth, onChange: _checkValue);
+ }
+ final DrawerStatusChangeHandler onStatusChange;
+ AnimatedValue position;
+
+ bool _oldClosedState = true;
+ void _checkValue() {
+ var newClosedState = isClosed;
+ if (onStatusChange != null && _oldClosedState != newClosedState) {
+ onStatusChange(!newClosedState);
+ _oldClosedState = newClosedState;
+ }
+ }
+ bool get isClosed => position.value == -_kWidth;
bool get _isMostlyClosed => position.value <= -_kWidth / 2;
-
void toggle(_) => _isMostlyClosed ? _open() : _close();
void handleMaskTap(_) => _close();
-
void handlePointerDown(_) => position.stop();
void handlePointerMove(sky.PointerEvent event) {
@@ -71,7 +84,8 @@ class DrawerController {
double distance = (targetPosition - position.value).abs();
double duration = distance / velocityX;
- position.animateTo(targetPosition, duration, curve: linear);
+ if (distance > 0)
+ position.animateTo(targetPosition, duration, curve: linear);
}
}
@@ -117,8 +131,6 @@ class Drawer extends AnimatedComponent {
}
UINode build() {
- bool isClosed = _position <= -_kWidth;
- String inlineStyle = 'display: ${isClosed ? 'none' : ''}';
String maskInlineStyle = 'opacity: ${(_position / _kWidth + 1) * 0.5}';
String contentInlineStyle = 'transform: translateX(${_position}px)';
@@ -142,7 +154,6 @@ class Drawer extends AnimatedComponent {
return new EventListenerNode(
new Container(
style: _style,
- inlineStyle: inlineStyle,
children: [ mask, content ]
),
onPointerDown: controller.handlePointerDown,
« no previous file with comments | « sky/framework/components/animated_component.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698