@@ -19,75 +19,143 @@ var FloatingActionButton = (function (_super) {
1919
2020 function FloatingActionButton ( ) {
2121 _super . call ( this ) ;
22-
22+
2323 this . swipeEventAttached = false ;
24-
25- this . getDurationDefault = function ( animationType ) {
26- switch ( animationType ) {
24+
25+ this . getDurationDefault = function ( animationType ) {
26+ switch ( animationType ) {
2727 case "scale" :
2828 return 100 ;
2929 default :
3030 return 300 ;
3131 }
3232 } ;
3333 }
34-
34+
3535
3636 FloatingActionButton . prototype . onLoaded = function ( ) {
3737 _super . prototype . onLoaded . call ( this ) ;
3838
39- if ( this . swipeEventAttached === false ) {
39+ if ( this . swipeEventAttached === false ) {
4040 var fab = this ;
4141 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 ) ;
4444 var animationType = ( this . swipeAnimation ) ? this . swipeAnimation : "slideDown"
45-
46- if ( swipeItem !== undefined ) {
45+
46+ if ( swipeItem !== undefined ) {
4747 var duration = ( this . hideAnimationDuration ) ? this . hideAnimationDuration : this . getDurationDefault ( animationType ) ;
48-
48+
4949 swipeItem . on ( "pan" , function ( args ) {
5050 //Swipe up
5151 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+ } ) ;
5562 break ;
5663 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+ } ) ;
5872 break ;
5973 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+ } ) ;
6182 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+ } ) ;
6492 break ;
6593 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+ } ) ;
67101 break ;
68102 }
69-
70- }
103+
104+ }
71105 //Swipe Down
72106 else if ( args . deltaY > 0 ) {
73- switch ( animationType ) {
107+ switch ( animationType ) {
74108 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+ } ) ;
76117 break ;
77118 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+ } ) ;
79127 break ;
80128 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+ } ) ;
82137 break ;
83138 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+ } ) ;
85147 break ;
86148 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+ } ) ;
88156 break ;
89157 }
90- } ;
158+ } ;
91159 } ) ;
92160
93161 this . swipeEventAttached = true ;
@@ -126,9 +194,9 @@ var FloatingActionButton = (function (_super) {
126194 FloatingActionButton . backColorProperty = new dObservable . Property ( "backColor" , "FloatingActionButton" , new proxy . PropertyMetadata ( 0 , dObservable . PropertyMetadataSettings . AffectsLayout ) ) ;
127195 FloatingActionButton . iconProperty = new dObservable . Property ( "icon" , "FloatingActionButton" , new proxy . PropertyMetadata ( 0 , dObservable . PropertyMetadataSettings . AffectsLayout ) ) ;
128196 FloatingActionButton . rippleColorProperty = new dObservable . Property ( "rippleColor" , "FloatingActionButton" , new proxy . PropertyMetadata ( 0 , dObservable . PropertyMetadataSettings . AffectsLayout ) ) ;
129-
130-
197+
198+
131199 return FloatingActionButton ;
132200} ) ( view . View ) ;
133201
134- exports . Fab = FloatingActionButton ;
202+ exports . Fab = FloatingActionButton ;
0 commit comments