OLD | NEW |
1 import 'dart:async'; | 1 import 'dart:async'; |
2 import 'dart:html'; | 2 import 'dart:html'; |
3 import 'package:widget/effects.dart'; | 3 import 'package:widget/effects.dart'; |
4 | 4 |
5 void main() { | 5 void main() { |
6 | 6 |
7 _initialize(); | 7 _initialize(); |
8 query('#do-swap').onClick.listen(_doSwap); | 8 query('#do-swap').onClick.listen(_doSwap); |
9 | 9 |
10 } | 10 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 final newActive = _contentElementField.children[index]; | 61 final newActive = _contentElementField.children[index]; |
62 return showItem(newActive, effect: effect, duration: duration, effectTiming: e
ffectTiming, hideEffect: hideEffect); | 62 return showItem(newActive, effect: effect, duration: duration, effectTiming: e
ffectTiming, hideEffect: hideEffect); |
63 } | 63 } |
64 | 64 |
65 Future<bool> showItem(Element item, {ShowHideEffect effect, int duration, Effect
Timing effectTiming, ShowHideEffect hideEffect}) { | 65 Future<bool> showItem(Element item, {ShowHideEffect effect, int duration, Effect
Timing effectTiming, ShowHideEffect hideEffect}) { |
66 assert(_contentElementField.children.contains(item)); | 66 assert(_contentElementField.children.contains(item)); |
67 | 67 |
68 final oldActiveChild = _activeItem; | 68 final oldActiveChild = _activeItem; |
69 if(oldActiveChild == item) { | 69 if(oldActiveChild == item) { |
70 return new Future<bool>.immediate(true); | 70 return new Future<bool>.value(true); |
71 } | 71 } |
72 | 72 |
73 [oldActiveChild, item].forEach((e) => e.classes.remove(_dirClassPrev)); | 73 [oldActiveChild, item].forEach((e) => e.classes.remove(_dirClassPrev)); |
74 | 74 |
75 oldActiveChild.classes.remove(_activeClass); | 75 oldActiveChild.classes.remove(_activeClass); |
76 oldActiveChild.classes.add(_dirClassPrev); | 76 oldActiveChild.classes.add(_dirClassPrev); |
77 | 77 |
78 item.classes.add(_activeClass); | 78 item.classes.add(_activeClass); |
79 | 79 |
80 return Swapper.swap(_contentElementField, item, effect: effect, duration: dura
tion, effectTiming: effectTiming, hideEffect: hideEffect) | 80 return Swapper.swap(_contentElementField, item, effect: effect, duration: dura
tion, effectTiming: effectTiming, hideEffect: hideEffect) |
(...skipping 26 matching lines...) Expand all Loading... |
107 | 107 |
108 // A bit of a hack. Because we call Swap w/ two displayed items: | 108 // A bit of a hack. Because we call Swap w/ two displayed items: |
109 // one marked 'prev' and one marked 'next', Swap tries to hide one of them | 109 // one marked 'prev' and one marked 'next', Swap tries to hide one of them |
110 // this only causes a problem when clicking right the first time, since all | 110 // this only causes a problem when clicking right the first time, since all |
111 // times after, the cached ShowHideState of the item is set | 111 // times after, the cached ShowHideState of the item is set |
112 // So...we're going to walk the showHide states of all children now | 112 // So...we're going to walk the showHide states of all children now |
113 // ...and ignore the result...but just to populate the values | 113 // ...and ignore the result...but just to populate the values |
114 theItems.forEach((f) => ShowHide.getState(f)); | 114 theItems.forEach((f) => ShowHide.getState(f)); |
115 } | 115 } |
116 } | 116 } |
OLD | NEW |