@@ -3,42 +3,50 @@ var color = require("color");
3
3
var frameModule = require ( "ui/frame" ) ;
4
4
var dObservable = require ( "ui/core/dependency-observable" ) ;
5
5
var proxy = require ( "ui/core/proxy" ) ;
6
-
6
+ var swipeLoaded = false ;
7
+
7
8
var FloatingActionButton = ( function ( _super ) {
8
9
global . __extends ( FloatingActionButton , _super ) ;
9
10
10
11
function FloatingActionButton ( ) {
11
12
_super . call ( this ) ;
12
13
}
13
14
15
+
14
16
FloatingActionButton . prototype . onLoaded = function ( ) {
15
17
_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
+ } ;
39
45
} ) ;
40
- } ;
41
- } ) ;
46
+
47
+ swipeLoaded = true ;
48
+ }
49
+ }
42
50
}
43
51
} ;
44
52
@@ -77,5 +85,4 @@ var FloatingActionButton = (function (_super) {
77
85
return FloatingActionButton ;
78
86
} ) ( view . View ) ;
79
87
80
-
81
88
exports . Fab = FloatingActionButton ;
0 commit comments