New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-effects

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-effects - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

100

package.json
{
"name": "nativescript-effects",
"version": "0.3.0",
"main": "tns-effects.js",
"description": "A NativeScript plugin that extend animations to include common animation scenarios.",
"nativescript": {
"platforms": {
"android": "1.5.0",
"ios": "1.5.2"
},
"tns-ios": {
"version": "1.5.2"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/alexziskind1/nativescript-effects.git"
},
"keywords": [
"NativeScript",
"native",
"script",
"animation",
"effects"
],
"contributors": [
{
"name": "Steve McNiven-Scott",
"email": "steve@sitefinitysteve.com",
"url": "https://github.com/sitefinitysteve"
}
],
"author": {
"name": "Alexander Ziskind",
"email": "alex@nuvious.com",
"url": "https://github.com/alexziskind1"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/alexziskind1/nativescript-effects/issues"
},
"homepage": "https://github.com/alexziskind1/nativescript-effects",
"readmeFilename": "README.md",
"gitHead": "7a5addbe9192a7708fbaac9db42e33f2a156fea6",
"_id": "nativescript-effects@0.1.0",
"scripts": {},
"_shasum": "7bdee571649168a79ded1bf63beb6d7b4b9cfa2a",
"_from": "..",
"_resolved": "file:.."
"name": "nativescript-effects",
"version": "0.4.0",
"main": "tns-effects.js",
"description": "A NativeScript plugin that extend animations to include common animation scenarios.",
"nativescript": {
"platforms": {
"android": "1.5.0",
"ios": "1.5.2"
},
"tns-ios": {
"version": "1.5.2"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/alexziskind1/nativescript-effects.git"
},
"keywords": [
"NativeScript",
"native",
"script",
"animation",
"effects"
],
"contributors": [
{
"name": "Steve McNiven-Scott",
"email": "steve@sitefinitysteve.com",
"url": "https://github.com/sitefinitysteve"
}
],
"author": {
"name": "Alexander Ziskind",
"email": "alex@nuvious.com",
"url": "https://github.com/alexziskind1"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/alexziskind1/nativescript-effects/issues"
},
"homepage": "https://github.com/alexziskind1/nativescript-effects",
"readmeFilename": "README.md",
"gitHead": "7a5addbe9192a7708fbaac9db42e33f2a156fea6",
"_id": "nativescript-effects@0.1.0",
"scripts": {},
"_shasum": "7bdee571649168a79ded1bf63beb6d7b4b9cfa2a",
"_from": "..",
"_resolved": "file:..",
"devDependencies": {
"tns-core-modules": "^2.5.2",
"tns-platform-declarations": "^2.5.2"
}
}

@@ -8,3 +8,3 @@ # NativeScript Effects

```
$ tns plugin add nativescript-effects
$ npm install nativescript-effects --save
```

@@ -19,2 +19,4 @@

In the demo app, this require line is added to the `app.ts` file, but you can also add it to a single code behind file where you will use the effects.
``` js

@@ -24,2 +26,8 @@ var tnsfx = require('nativescript-effects');

### TypeScript
To avoid type checking errors, you must additionally configure TypeScript to recognize the method extensions to `View`. Simply add the following line to `references.d.ts` in the root of your project:
```typescript
/// <reference path="./node_modules/nativescript-effects/tns-effects.d.ts" />
```
Then get a reference to the view you want to animate and call one of the functions listed below. This view can be any child of the NativeScript View class such as Button, Label, etc.

@@ -112,3 +120,3 @@

----
## .shake() ![](./screenshots/new_70.png)
## .shake()
Description: *Shake the view back and forth a few times, like a headshake "no"*

@@ -153,2 +161,11 @@

----
## .slideToggle([duration])
Description: *Slide down or slide up the view based on current slide state.*
**duration** (default: 400)
Type: Number or String <br/>
A string or number determining how long the animation will run. Number is milliseconds. String is a constant value 'fast' or 'slow'.
----
## .spring([duration], [animation]) <- currently iOS only

@@ -155,0 +172,0 @@ Description: *Moves the view with a spring like bouncing motion.*

@@ -0,23 +1,24 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//nativescript-effects
var viewModule = require("ui/core/view");
//var viewModule = require("ui/core/view");
var typesModule = require("utils/types");
var definition = require("./tns-effects");
var enums = require("ui/enums");
var Effects = {
defaultDuration : 400,
defaultDuration: 400,
defaultSlideDistance: -100,
defaultFloatDirection: 'up',
presetDirections: {
'up': {x: 0, y: 100},
'down': {x: 0, y: -100},
'left': {x: 100, y: 0},
'right': {x: -100, y: 0}
'up': { x: 0, y: 100 },
'down': { x: 0, y: -100 },
'left': { x: 100, y: 0 },
'right': { x: -100, y: 0 }
},
presetDurations: {
'fast' : 200,
'slow' : 600
'fast': 200,
'slow': 600
},
getMsValue: function(duration) {
getMsValue: function (duration) {
if (typesModule.isString(duration)) {

@@ -27,3 +28,3 @@ if (typesModule.isDefined(Effects.presetDurations[duration])) {

}
}
}
else if (typesModule.isNumber(duration)) {

@@ -38,5 +39,6 @@ return duration;

exports.ViewEffects = Effects;
viewModule.View.prototype.fadeIn = function(duration) {
if (duration === void 0) { duration = Effects.defaultDuration; }
viewModule.View.prototype.fadeIn = function (duration) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
var msDuration = Effects.getMsValue(duration);

@@ -49,6 +51,7 @@ this.visibility = enums.Visibility.visible;

};
viewModule.View.prototype.fadeOut = function(duration) {
if (duration === void 0) { duration = Effects.defaultDuration; }
var msDuration = Effects.getMsValue(duration);
viewModule.View.prototype.fadeOut = function (duration) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
var msDuration = Effects.getMsValue(duration);
return this.animate({

@@ -59,6 +62,9 @@ opacity: 0,

};
viewModule.View.prototype.fadeTo = function(duration, opacity) {
if (duration === void 0) { duration = Effects.defaultDuration; }
if (opacity === void 0) { opacity = 1; }
viewModule.View.prototype.fadeTo = function (duration, opacity) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
if (opacity === void 0) {
opacity = 1;
}
var msDuration = Effects.getMsValue(duration);

@@ -71,5 +77,6 @@ this.visibility = enums.Visibility.visible;

};
viewModule.View.prototype.fadeToggle = function(duration) {
if (duration === void 0) { duration = Effects.defaultDuration; }
viewModule.View.prototype.fadeToggle = function (duration) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
if (this.opacity > 0) {

@@ -82,8 +89,11 @@ return this.fadeOut(duration);

};
//.floatIn( [duration ] )
//.floatIn( options )
viewModule.View.prototype.floatIn = function(duration, direction) {
if (duration === void 0) { duration = Effects.defaultDuration; }
if (direction === void 0) { direction = Effects.defaultFloatDirection; }
viewModule.View.prototype.floatIn = function (duration, direction) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
if (direction === void 0) {
direction = Effects.defaultFloatDirection;
}
var self = this;

@@ -96,3 +106,2 @@ var msDuration = Effects.getMsValue(duration);

}
var promiseSetup = self.animate({

@@ -103,17 +112,17 @@ translate: { x: dir.x, y: dir.y },

});
return promiseSetup.then(function() {
return self.animate({
return promiseSetup.then(function () {
return self.animate({
translate: { x: 0, y: 0 },
opacity: 1,
duration: msDuration
duration: msDuration
});
});
};
viewModule.View.prototype.floatOut = function(duration, direction) {
if (duration === void 0) { duration = Effects.defaultDuration; }
if (direction === void 0) { direction = Effects.defaultFloatDirection; }
viewModule.View.prototype.floatOut = function (duration, direction) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
if (direction === void 0) {
direction = Effects.defaultFloatDirection;
}
var msDuration = Effects.getMsValue(duration);

@@ -124,4 +133,4 @@ var dir = Effects.presetDirections[direction];

}
return this.animate({
translate: { x: dir.x, y: dir.y },
return this.animate({
translate: { x: dir.x, y: dir.y },
opacity: 0,

@@ -131,21 +140,23 @@ duration: msDuration

};
//.hide()
//.hide( [duration ] )
//.hide( options )
viewModule.View.prototype.hide = function(duration) {
if (duration === void 0) { duration = 1; }
viewModule.View.prototype.hide = function (duration) {
if (duration === void 0) {
duration = 1;
}
this.visibility = enums.Visibility.collapse;
return this.fadeOut(duration);
};
viewModule.View.prototype.show = function(duration) {
if (duration === void 0) { duration = 1; }
viewModule.View.prototype.show = function (duration) {
if (duration === void 0) {
duration = 1;
}
this.visibility = enums.Visibility.visible;
return this.fadeIn(duration);
};
viewModule.View.prototype.toggle = function(duration) {
if (duration === void 0) { duration = 1; }
viewModule.View.prototype.toggle = function (duration) {
if (duration === void 0) {
duration = 1;
}
if (this.visibility === enums.Visibility.collapse) {

@@ -158,16 +169,16 @@ return this.show(duration);

};
//.slideDown( [duration ] )
//.slideDown( options )
viewModule.View.prototype.slideDown = function(duration, distance) {
if (duration === void 0) { duration = Effects.defaultDuration; }
if (distance === void 0) { distance = Effects.defaultSlideDistance; }
viewModule.View.prototype.slideDown = function (duration, distance) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
if (distance === void 0) {
distance = Effects.defaultSlideDistance;
}
var self = this;
var msDuration = Effects.getMsValue(duration);
this.visibility = enums.Visibility.visible;
this.translateY = distance;
this.opacity = 0;
var promiseSetup = self.animate({

@@ -178,19 +189,20 @@ translate: { x: 0, y: distance },

});
return promiseSetup.then(function() {
return self.animate({
return promiseSetup.then(function () {
return self.animate({
translate: { x: 0, y: 0 },
opacity: 1,
duration: msDuration
duration: msDuration
});
});
};
viewModule.View.prototype.slideUp = function(duration, distance) {
if (duration === void 0) { duration = Effects.defaultDuration; }
if (distance === void 0) { distance = Effects.defaultSlideDistance; }
viewModule.View.prototype.slideUp = function (duration, distance) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
if (distance === void 0) {
distance = Effects.defaultSlideDistance;
}
var msDuration = Effects.getMsValue(duration);
return this.animate({
translate: { x: 0, y: distance },
return this.animate({
translate: { x: 0, y: distance },
opacity: 0,

@@ -200,7 +212,9 @@ duration: msDuration

};
viewModule.View.prototype.slideToggle = function(duration, distance) {
if (duration === void 0) { duration = Effects.defaultDuration; }
if (distance === void 0) { distance = Effects.defaultSlideDistance; }
viewModule.View.prototype.slideToggle = function (duration, distance) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
if (distance === void 0) {
distance = Effects.defaultSlideDistance;
}
if (this.opacity > 0) {

@@ -213,23 +227,23 @@ return this.slideUp(duration, distance);

};
viewModule.View.prototype.spring = function(duration, animation) {
if (duration === void 0) { duration = Effects.defaultDuration; }
viewModule.View.prototype.spring = function (duration, animation) {
if (duration === void 0) {
duration = Effects.defaultDuration;
}
var msDuration = Effects.getMsValue(duration);
if (!animation) {
animation = {
translate: {
x: 0,
y: -100
},
scale: {
x: 2,
y: 2
},
duration: msDuration,
delay: 0,
dampingRatio: 0.3,
velocity: 2.0,
options: null
};
translate: {
x: 0,
y: -100
},
scale: {
x: 2,
y: 2
},
duration: msDuration,
delay: 0,
dampingRatio: 0.3,
velocity: 2.0,
options: null
};
}

@@ -239,24 +253,21 @@ else {

}
var fx = new definition.ViewEffects(this);
return fx.nativeSpring(animation);
}
//.shake( )
viewModule.View.prototype.shake = function() {
};
viewModule.View.prototype.shake = function () {
var view = this;
return new Promise(function (resolve, reject) {
view.animate({ translate: { x: -20, y: 0}, duration: 60, curve: enums.AnimationCurve.linear})
.then(function () { return view.animate({ translate: { x: 20, y: 0}, duration: 60, curve: enums.AnimationCurve.linear}) })
.then(function () { return view.animate({ translate: { x: -20, y: 0}, duration: 60, curve: enums.AnimationCurve.linear}) })
.then(function () { return view.animate({ translate: { x: 20, y: 0}, duration: 60, curve: enums.AnimationCurve.linear}) })
.then(function () { return view.animate({ translate: { x: -10, y: 0}, duration: 60, curve: enums.AnimationCurve.linear}) })
.then(function () { return view.animate({ translate: { x: 10, y: 0}, duration: 60, curve: enums.AnimationCurve.linear}) })
.then(function () { return view.animate({ translate: { x: -5, y: 0}, duration: 60, curve: enums.AnimationCurve.linear}) })
.then(function () { return view.animate({ translate: { x: 5, y: 0}, duration: 60, curve: enums.AnimationCurve.linear}) })
.then(function () { return view.animate({ translate: { x: 0, y: 0}, duration: 60, curve: enums.AnimationCurve.linear}) })
return new Promise(function (resolve, reject) {
view.animate({ translate: { x: -20, y: 0 }, duration: 60, curve: enums.AnimationCurve.linear })
.then(function () { return view.animate({ translate: { x: 20, y: 0 }, duration: 60, curve: enums.AnimationCurve.linear }); })
.then(function () { return view.animate({ translate: { x: -20, y: 0 }, duration: 60, curve: enums.AnimationCurve.linear }); })
.then(function () { return view.animate({ translate: { x: 20, y: 0 }, duration: 60, curve: enums.AnimationCurve.linear }); })
.then(function () { return view.animate({ translate: { x: -10, y: 0 }, duration: 60, curve: enums.AnimationCurve.linear }); })
.then(function () { return view.animate({ translate: { x: 10, y: 0 }, duration: 60, curve: enums.AnimationCurve.linear }); })
.then(function () { return view.animate({ translate: { x: -5, y: 0 }, duration: 60, curve: enums.AnimationCurve.linear }); })
.then(function () { return view.animate({ translate: { x: 5, y: 0 }, duration: 60, curve: enums.AnimationCurve.linear }); })
.then(function () { return view.animate({ translate: { x: 0, y: 0 }, duration: 60, curve: enums.AnimationCurve.linear }); })
.then(function () {
return resolve(view);
});
return resolve(view);
});
});
}
};

@@ -0,1 +1,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var common = require("./tns-effects-common");

@@ -12,3 +14,3 @@ global.moduleMerge(common, exports);

return ViewEffects;
})();
}());
exports.ViewEffects = ViewEffects;

@@ -7,10 +7,10 @@ declare module "ui/core/view" {

fadeToggle(duration?: string | number): Promise<void>;
floatIn(duration?: string|number, direction?: string): Promise<void>;
floatOut(duration?: string|number, direction?: string): Promise<void>;
floatIn(duration?: string | number, direction?: string): Promise<void>;
floatOut(duration?: string | number, direction?: string): Promise<void>;
show(duration?: string | number): Promise<void>;
hide(duration?: string | number): Promise<void>;
toggle(duration?: string | number): Promise<void>;
slideDown(duration?: string | number, distance?: number): Promise<void>;

@@ -20,6 +20,6 @@ slideUp(duration?: string | number, distance?: number): Promise<void>;

spring(duration?: string | number, animation?:any): Promise<void>;
shake(): Promise<void>;
spring(duration?: string | number, animation?: any): Promise<void>;
shake(): Promise<any>;
}
}

@@ -0,1 +1,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var common = require("./tns-effects-common");

@@ -41,3 +43,3 @@ global.moduleMerge(common, exports);

return ViewEffects;
})();
}());
exports.ViewEffects = ViewEffects;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc