This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +43
-6
lines changed
src/components/fabSpeedDial Expand file tree Collapse file tree 3 files changed +43
-6
lines changed Original file line number Diff line number Diff line change 29
29
setupDefaults ( ) ;
30
30
setupListeners ( ) ;
31
31
setupWatchers ( ) ;
32
+
33
+ var initialAnimationAttempts = 0 ;
32
34
fireInitialAnimations ( ) ;
33
35
34
36
function setupDefaults ( ) {
40
42
41
43
// Start the keyboard interaction at the first action
42
44
resetActionIndex ( ) ;
45
+
46
+ // Add an animations waiting class so we know not to run
47
+ $element . addClass ( 'md-animations-waiting' ) ;
43
48
}
44
49
45
50
function setupListeners ( ) {
133
138
} ) ;
134
139
}
135
140
136
- // Fire the animations once in a separate digest loop to initialize them
137
141
function fireInitialAnimations ( ) {
138
- $mdUtil . nextTick ( function ( ) {
139
- $animate . addClass ( $element , 'md-noop' ) ;
140
- } ) ;
142
+ // If the element is actually visible on the screen
143
+ if ( $element [ 0 ] . scrollHeight > 0 ) {
144
+ // Fire our animation
145
+ $animate . addClass ( $element , 'md-animations-ready' ) . then ( function ( ) {
146
+ // Remove the waiting class
147
+ $element . removeClass ( 'md-animations-waiting' ) ;
148
+ } ) ;
149
+ }
150
+
151
+ // Otherwise, try for up to 1 second before giving up
152
+ else if ( initialAnimationAttempts < 10 ) {
153
+ $timeout ( fireInitialAnimations , 100 ) ;
154
+
155
+ // Increment our counter
156
+ initialAnimationAttempts = initialAnimationAttempts + 1 ;
157
+ }
141
158
}
142
159
143
160
function enableKeyboard ( ) {
Original file line number Diff line number Diff line change 114
114
function delayDone ( done ) { $timeout ( done , cssAnimationDuration , false ) ; }
115
115
116
116
function runAnimation ( element ) {
117
+ // Don't run if we are still waiting and we are not ready
118
+ if ( element . hasClass ( 'md-animations-waiting' ) && ! element . hasClass ( 'md-animations-ready' ) ) {
119
+ return ;
120
+ }
121
+
117
122
var el = element [ 0 ] ;
118
123
var ctrl = element . controller ( 'mdFabSpeedDial' ) ;
119
124
var items = el . querySelectorAll ( '.md-fab-action-item' ) ;
184
189
addClass : function ( element , className , done ) {
185
190
if ( element . hasClass ( 'md-fling' ) ) {
186
191
runAnimation ( element ) ;
192
+ delayDone ( done ) ;
193
+ } else {
194
+ done ( ) ;
187
195
}
188
- delayDone ( done ) ;
189
196
} ,
190
197
removeClass : function ( element , className , done ) {
191
198
runAnimation ( element ) ;
Original file line number Diff line number Diff line change @@ -118,9 +118,22 @@ md-fab-speed-dial {
118
118
/*
119
119
* Handle the animations
120
120
*/
121
- & .md-scale {
121
+ & .md-fling {
122
+ .md-fab-action-item {
123
+ opacity : 1 ;
124
+ }
125
+ }
126
+
127
+ // For the initial animation, set the duration to be instant
128
+ & .md-fling.md-animations-waiting {
122
129
.md-fab-action-item {
123
130
opacity : 0 ;
131
+ transition-duration : 0s ;
132
+ }
133
+ }
134
+
135
+ & .md-scale {
136
+ .md-fab-action-item {
124
137
transform : scale (0.1 );
125
138
transition : $swift-ease-in ;
126
139
You can’t perform that action at this time.
0 commit comments