|
1 | 1 | var view = require("ui/core/view"); |
2 | 2 | var color = require("color"); |
| 3 | +var frameModule = require("ui/frame"); |
3 | 4 | var dObservable = require("ui/core/dependency-observable"); |
4 | 5 | var proxy = require("ui/core/proxy"); |
5 | | - |
| 6 | +var swipeLoaded = false; |
| 7 | + |
6 | 8 | var FloatingActionButton = (function (_super) { |
7 | 9 | global.__extends(FloatingActionButton, _super); |
8 | 10 |
|
9 | 11 | function FloatingActionButton() { |
10 | 12 | _super.call(this); |
11 | 13 | } |
| 14 | + |
| 15 | + |
| 16 | + FloatingActionButton.prototype.onLoaded = function () { |
| 17 | + _super.prototype.onLoaded.call(this); |
| 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 | + }; |
| 45 | + }); |
| 46 | + |
| 47 | + swipeLoaded = true; |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + }; |
12 | 52 |
|
13 | 53 | Object.defineProperty(FloatingActionButton.prototype, "rippleColor", { |
14 | 54 | get: function () { |
@@ -41,6 +81,7 @@ var FloatingActionButton = (function (_super) { |
41 | 81 | FloatingActionButton.iconProperty = new dObservable.Property("icon", "FloatingActionButton", new proxy.PropertyMetadata(0, dObservable.PropertyMetadataSettings.AffectsLayout)); |
42 | 82 | FloatingActionButton.rippleColorProperty = new dObservable.Property("rippleColor", "FloatingActionButton", new proxy.PropertyMetadata(0, dObservable.PropertyMetadataSettings.AffectsLayout)); |
43 | 83 |
|
| 84 | + |
44 | 85 | return FloatingActionButton; |
45 | 86 | })(view.View); |
46 | 87 |
|
|
0 commit comments