@@ -3,42 +3,50 @@ var color = require("color");
33var frameModule = require ( "ui/frame" ) ;
44var dObservable = require ( "ui/core/dependency-observable" ) ;
55var proxy = require ( "ui/core/proxy" ) ;
6-
6+ var swipeLoaded = false ;
7+
78var FloatingActionButton = ( function ( _super ) {
89 global . __extends ( FloatingActionButton , _super ) ;
910
1011 function FloatingActionButton ( ) {
1112 _super . call ( this ) ;
1213 }
1314
15+
1416 FloatingActionButton . prototype . onLoaded = function ( ) {
1517 _super . prototype . onLoaded . call ( this ) ;
16- var fab = this ;
17- var viewToAttachTo = this . hideOnSwipeOfView ;
18- var swipeItem = this . page . getViewById ( viewToAttachTo ) ;
19-
20- if ( swipeItem !== undefined ) {
21- var duration = ( this . hideAnimationDuration == undefined ) ? 300 : this . hideAnimationDuration ;
22-
23- //Wire up action
24- swipeItem . on ( "swipe" , function ( args ) {
25-
26- //if scrolling down (swipe up) -- hide FAB
27- if ( args . direction === 4 ) {
28- fab . animate ( {
29- translate : { x : 0 , y : 200 } ,
30- opacity : 0 ,
31- duration : duration
32- } ) ;
33- } //if scrolling up (swipe down) -- show FAB
34- else if ( args . direction === 8 ) {
35- fab . animate ( {
36- translate : { x : 0 , y : 0 } ,
37- opacity : 1 ,
38- duration : duration
18+
19+ if ( swipeLoaded === false ) {
20+ var fab = this ;
21+ var viewToAttachTo = this . hideOnSwipeOfView ;
22+ if ( viewToAttachTo !== undefined ) {
23+ var swipeItem = this . page . getViewById ( viewToAttachTo ) ;
24+
25+ if ( swipeItem !== undefined ) {
26+ console . log ( "Wiring up swipe" ) ;
27+ var duration = ( this . hideAnimationDuration == undefined ) ? 300 : this . hideAnimationDuration ;
28+ swipeItem . on ( "swipe" , function ( args ) {
29+ //Swipe up
30+ if ( args . direction === 4 ) {
31+ fab . animate ( {
32+ translate : { x : 0 , y : 200 } ,
33+ opacity : 0 ,
34+ duration : duration
35+ } ) ;
36+ }
37+ //Swipe Down
38+ else if ( args . direction === 8 ) {
39+ fab . animate ( {
40+ translate : { x : 0 , y : 0 } ,
41+ opacity : 1 ,
42+ duration : duration
43+ } ) ;
44+ } ;
3945 } ) ;
40- } ;
41- } ) ;
46+
47+ swipeLoaded = true ;
48+ }
49+ }
4250 }
4351 } ;
4452
@@ -77,5 +85,4 @@ var FloatingActionButton = (function (_super) {
7785 return FloatingActionButton ;
7886} ) ( view . View ) ;
7987
80-
8188exports . Fab = FloatingActionButton ;
0 commit comments