@@ -19,75 +19,143 @@ var FloatingActionButton = (function (_super) {
19
19
20
20
function FloatingActionButton ( ) {
21
21
_super . call ( this ) ;
22
-
22
+
23
23
this . swipeEventAttached = false ;
24
-
25
- this . getDurationDefault = function ( animationType ) {
26
- switch ( animationType ) {
24
+
25
+ this . getDurationDefault = function ( animationType ) {
26
+ switch ( animationType ) {
27
27
case "scale" :
28
28
return 100 ;
29
29
default :
30
30
return 300 ;
31
31
}
32
32
} ;
33
33
}
34
-
34
+
35
35
36
36
FloatingActionButton . prototype . onLoaded = function ( ) {
37
37
_super . prototype . onLoaded . call ( this ) ;
38
38
39
- if ( this . swipeEventAttached === false ) {
39
+ if ( this . swipeEventAttached === false ) {
40
40
var fab = this ;
41
41
var viewToAttachTo = this . hideOnSwipeOfView ;
42
- if ( viewToAttachTo !== undefined ) {
43
- var swipeItem = this . page . getViewById ( viewToAttachTo ) ;
42
+ if ( viewToAttachTo !== undefined ) {
43
+ var swipeItem = frameModule . topmost ( ) . getViewById ( viewToAttachTo ) ;
44
44
var animationType = ( this . swipeAnimation ) ? this . swipeAnimation : "slideDown"
45
-
46
- if ( swipeItem !== undefined ) {
45
+
46
+ if ( swipeItem !== undefined ) {
47
47
var duration = ( this . hideAnimationDuration ) ? this . hideAnimationDuration : this . getDurationDefault ( animationType ) ;
48
-
48
+
49
49
swipeItem . on ( "pan" , function ( args ) {
50
50
//Swipe up
51
51
if ( args . deltaY < - 10 ) {
52
- switch ( animationType ) {
53
- case "slideUp" :
54
- fab . animate ( { translate : { x : 0 , y : - 200 } , opacity : 0 , duration : duration } ) ;
52
+ switch ( animationType ) {
53
+ case "slideUp" :
54
+ fab . animate ( {
55
+ translate : {
56
+ x : 0 ,
57
+ y : - 200
58
+ } ,
59
+ opacity : 0 ,
60
+ duration : duration
61
+ } ) ;
55
62
break ;
56
63
case "slideDown" :
57
- fab . animate ( { translate : { x : 0 , y : 200 } , opacity : 0 , duration : duration } ) ;
64
+ fab . animate ( {
65
+ translate : {
66
+ x : 0 ,
67
+ y : 200
68
+ } ,
69
+ opacity : 0 ,
70
+ duration : duration
71
+ } ) ;
58
72
break ;
59
73
case "slideRight" :
60
- fab . animate ( { translate : { x : 200 , y : 0 } , opacity : 0 , duration : duration } ) ;
74
+ fab . animate ( {
75
+ translate : {
76
+ x : 200 ,
77
+ y : 0
78
+ } ,
79
+ opacity : 0 ,
80
+ duration : duration
81
+ } ) ;
61
82
break ;
62
- case "slideLeft" :
63
- fab . animate ( { translate : { x : - 200 , y : 0 } , opacity : 0 , duration : duration } ) ;
83
+ case "slideLeft" :
84
+ fab . animate ( {
85
+ translate : {
86
+ x : - 200 ,
87
+ y : 0
88
+ } ,
89
+ opacity : 0 ,
90
+ duration : duration
91
+ } ) ;
64
92
break ;
65
93
case "scale" :
66
- fab . animate ( { scale : { x : 0 , y : 0 } , duration : duration } ) ;
94
+ fab . animate ( {
95
+ scale : {
96
+ x : 0 ,
97
+ y : 0
98
+ } ,
99
+ duration : duration
100
+ } ) ;
67
101
break ;
68
102
}
69
-
70
- }
103
+
104
+ }
71
105
//Swipe Down
72
106
else if ( args . deltaY > 0 ) {
73
- switch ( animationType ) {
107
+ switch ( animationType ) {
74
108
case "slideUp" :
75
- fab . animate ( { translate : { x : 0 , y : 0 } , opacity : 1 , duration : duration } ) ;
109
+ fab . animate ( {
110
+ translate : {
111
+ x : 0 ,
112
+ y : 0
113
+ } ,
114
+ opacity : 1 ,
115
+ duration : duration
116
+ } ) ;
76
117
break ;
77
118
case "slideDown" :
78
- fab . animate ( { translate : { x : 0 , y : 0 } , opacity : 1 , duration : duration } ) ;
119
+ fab . animate ( {
120
+ translate : {
121
+ x : 0 ,
122
+ y : 0
123
+ } ,
124
+ opacity : 1 ,
125
+ duration : duration
126
+ } ) ;
79
127
break ;
80
128
case "slideRight" :
81
- fab . animate ( { translate : { x : 0 , y : 0 } , opacity : 1 , duration : duration } ) ;
129
+ fab . animate ( {
130
+ translate : {
131
+ x : 0 ,
132
+ y : 0
133
+ } ,
134
+ opacity : 1 ,
135
+ duration : duration
136
+ } ) ;
82
137
break ;
83
138
case "slideLeft" :
84
- fab . animate ( { translate : { x : 0 , y : 0 } , opacity : 1 , duration : duration } ) ;
139
+ fab . animate ( {
140
+ translate : {
141
+ x : 0 ,
142
+ y : 0
143
+ } ,
144
+ opacity : 1 ,
145
+ duration : duration
146
+ } ) ;
85
147
break ;
86
148
case "scale" :
87
- fab . animate ( { scale : { x : 1 , y : 1 } , duration : duration } ) ;
149
+ fab . animate ( {
150
+ scale : {
151
+ x : 1 ,
152
+ y : 1
153
+ } ,
154
+ duration : duration
155
+ } ) ;
88
156
break ;
89
157
}
90
- } ;
158
+ } ;
91
159
} ) ;
92
160
93
161
this . swipeEventAttached = true ;
@@ -126,9 +194,9 @@ var FloatingActionButton = (function (_super) {
126
194
FloatingActionButton . backColorProperty = new dObservable . Property ( "backColor" , "FloatingActionButton" , new proxy . PropertyMetadata ( 0 , dObservable . PropertyMetadataSettings . AffectsLayout ) ) ;
127
195
FloatingActionButton . iconProperty = new dObservable . Property ( "icon" , "FloatingActionButton" , new proxy . PropertyMetadata ( 0 , dObservable . PropertyMetadataSettings . AffectsLayout ) ) ;
128
196
FloatingActionButton . rippleColorProperty = new dObservable . Property ( "rippleColor" , "FloatingActionButton" , new proxy . PropertyMetadata ( 0 , dObservable . PropertyMetadataSettings . AffectsLayout ) ) ;
129
-
130
-
197
+
198
+
131
199
return FloatingActionButton ;
132
200
} ) ( view . View ) ;
133
201
134
- exports . Fab = FloatingActionButton ;
202
+ exports . Fab = FloatingActionButton ;
0 commit comments