Skip to content

Commit

Permalink
fix #36 - bump
Browse files Browse the repository at this point in the history
  • Loading branch information
bradmartin committed Nov 15, 2016
1 parent cb9f567 commit dceaaf5
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 33 deletions.
130 changes: 99 additions & 31 deletions fab-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,75 +19,143 @@ var FloatingActionButton = (function (_super) {

function FloatingActionButton() {
_super.call(this);

this.swipeEventAttached = false;
this.getDurationDefault = function(animationType){
switch(animationType){

this.getDurationDefault = function (animationType) {
switch (animationType) {
case "scale":
return 100;
default:
return 300;
}
};
}


FloatingActionButton.prototype.onLoaded = function () {
_super.prototype.onLoaded.call(this);

if(this.swipeEventAttached === false){
if (this.swipeEventAttached === false) {
var fab = this;
var viewToAttachTo = this.hideOnSwipeOfView;
if(viewToAttachTo !== undefined){
var swipeItem = this.page.getViewById(viewToAttachTo);
if (viewToAttachTo !== undefined) {
var swipeItem = frameModule.topmost().getViewById(viewToAttachTo);
var animationType = (this.swipeAnimation) ? this.swipeAnimation : "slideDown"
if(swipeItem !== undefined){

if (swipeItem !== undefined) {
var duration = (this.hideAnimationDuration) ? this.hideAnimationDuration : this.getDurationDefault(animationType);

swipeItem.on("pan", function (args) {
//Swipe up
if (args.deltaY < -10) {
switch(animationType){
case "slideUp":
fab.animate({ translate: { x: 0, y: -200 }, opacity: 0, duration: duration });
switch (animationType) {
case "slideUp":
fab.animate({
translate: {
x: 0,
y: -200
},
opacity: 0,
duration: duration
});
break;
case "slideDown":
fab.animate({ translate: { x: 0, y: 200 }, opacity: 0, duration: duration });
fab.animate({
translate: {
x: 0,
y: 200
},
opacity: 0,
duration: duration
});
break;
case "slideRight":
fab.animate({ translate: { x: 200, y: 0 }, opacity: 0, duration: duration });
fab.animate({
translate: {
x: 200,
y: 0
},
opacity: 0,
duration: duration
});
break;
case "slideLeft":
fab.animate({ translate: { x: -200, y: 0 }, opacity: 0, duration: duration });
case "slideLeft":
fab.animate({
translate: {
x: -200,
y: 0
},
opacity: 0,
duration: duration
});
break;
case "scale":
fab.animate({ scale: { x: 0, y: 0 }, duration: duration });
fab.animate({
scale: {
x: 0,
y: 0
},
duration: duration
});
break;
}
}

}
//Swipe Down
else if (args.deltaY > 0) {
switch(animationType){
switch (animationType) {
case "slideUp":
fab.animate({ translate: { x: 0, y: 0 }, opacity: 1, duration: duration });
fab.animate({
translate: {
x: 0,
y: 0
},
opacity: 1,
duration: duration
});
break;
case "slideDown":
fab.animate({ translate: { x: 0, y: 0 }, opacity: 1, duration: duration });
fab.animate({
translate: {
x: 0,
y: 0
},
opacity: 1,
duration: duration
});
break;
case "slideRight":
fab.animate({ translate: { x: 0, y: 0 }, opacity: 1, duration: duration });
fab.animate({
translate: {
x: 0,
y: 0
},
opacity: 1,
duration: duration
});
break;
case "slideLeft":
fab.animate({ translate: { x: 0, y: 0 }, opacity: 1, duration: duration });
fab.animate({
translate: {
x: 0,
y: 0
},
opacity: 1,
duration: duration
});
break;
case "scale":
fab.animate({ scale: { x: 1, y: 1 }, duration: duration });
fab.animate({
scale: {
x: 1,
y: 1
},
duration: duration
});
break;
}
};
};
});

this.swipeEventAttached = true;
Expand Down Expand Up @@ -126,9 +194,9 @@ var FloatingActionButton = (function (_super) {
FloatingActionButton.backColorProperty = new dObservable.Property("backColor", "FloatingActionButton", new proxy.PropertyMetadata(0, dObservable.PropertyMetadataSettings.AffectsLayout));
FloatingActionButton.iconProperty = new dObservable.Property("icon", "FloatingActionButton", new proxy.PropertyMetadata(0, dObservable.PropertyMetadataSettings.AffectsLayout));
FloatingActionButton.rippleColorProperty = new dObservable.Property("rippleColor", "FloatingActionButton", new proxy.PropertyMetadata(0, dObservable.PropertyMetadataSettings.AffectsLayout));


return FloatingActionButton;
})(view.View);

exports.Fab = FloatingActionButton;
exports.Fab = FloatingActionButton;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nativescript-floatingactionbutton",
"version": "2.2.5",
"description": "A NativeScript plugin to provide an XML widget to implement the Material Design Floating Action Button in NativeScript apps.",
"version": "2.2.6",
"description": "A NativeScript plugin for Material Design Floating Action Button.",
"main": "fab.js",
"nativescript": {
"platforms": {
Expand Down

0 comments on commit dceaaf5

Please sign in to comment.