NPM/Bower and UMD support.
- Supports `require()` and `define()` style loading. - Is available on Bower through Git tags. Not yet via NPM. (run `npm publish` inside the project to do so) - README updated with hint of usability with module loaders In the code: - Implemented UMD method, using AMD in first instance. - Error is thrown is the root KuteJS could not be found. What is missing: - Sub-modules should export their factory rather than doing this on their own.
This commit is contained in:
parent
37348c3609
commit
e2aa72e14b
24
README.md
24
README.md
|
@ -6,6 +6,13 @@ A minimal <b>native Javascript</b> tweening engine with <b>jQuery</b> plugin, fo
|
|||
# CDN
|
||||
Thanks to jsdelivr, we have CDN link <a target="_blank" href="http://www.jsdelivr.com/#!kute.js">here</a>.
|
||||
|
||||
# NPM/Bower
|
||||
You can install this through NPM or bower respectively:
|
||||
|
||||
$ npm install kute.js
|
||||
# or
|
||||
$ bower install kute.js
|
||||
|
||||
# Basic Usage
|
||||
At a glance, you can write one line and you're done.
|
||||
```javascript
|
||||
|
@ -16,6 +23,23 @@ new KUTE.fromTo('selector', fromValues, toValues, options);
|
|||
$('selector').KUTE('fromTo', fromValues, toValues, options);
|
||||
```
|
||||
|
||||
# CommonJS/AMD support
|
||||
You can use this module through any of the common javascript module systems. For instance:
|
||||
|
||||
```javascript
|
||||
// NodeJS/CommonJS style
|
||||
var kute = require("kute.js");
|
||||
// Add Bezier/Easing...
|
||||
require("kute.js/kute-bezier");
|
||||
|
||||
// AMD
|
||||
define([
|
||||
"kute.js",
|
||||
"kute.js/kute-bezier.js"
|
||||
], function(KUTE){
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
# Advanced Usage
|
||||
Quite easily, you can write 'bit more lines and you're making the earth go round.
|
||||
|
|
30
bower.json
Normal file
30
bower.json
Normal file
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "KUTE.js",
|
||||
"version": "0.9.4",
|
||||
"homepage": "http://thednp.github.io/kute.js",
|
||||
"authors": [
|
||||
"thednp"
|
||||
],
|
||||
"description": "A minimal Native Javascript animation engine with jQuery plugin.",
|
||||
"main": "kute.js",
|
||||
"moduleType": [
|
||||
"amd",
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"animations",
|
||||
"native-javascript",
|
||||
"kute.js",
|
||||
"tweening",
|
||||
"engine"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
295
kute-bezier.js
295
kute-bezier.js
|
@ -6,154 +6,173 @@
|
|||
* Licensed under MIT-License
|
||||
*/
|
||||
|
||||
KUTE.Ease = {};
|
||||
|
||||
KUTE.Ease.bezier = function(mX1, mY1, mX2, mY2) {
|
||||
return _bz.pB(mX1, mY1, mX2, mY2);
|
||||
};
|
||||
|
||||
var _bz = KUTE.Ease.bezier.prototype;
|
||||
|
||||
// These values are established by empiricism with tests (tradeoff: performance VS precision)
|
||||
_bz.ni = 4; // NEWTON_ITERATIONS
|
||||
_bz.nms = 0.001; // NEWTON_MIN_SLOPE
|
||||
_bz.sp = 0.0000001; // SUBDIVISION_PRECISION
|
||||
_bz.smi = 10, // SUBDIVISION_MAX_ITERATIONS
|
||||
|
||||
_bz.ksts = 11; // k Spline Table Size
|
||||
_bz.ksss = 1.0 / (_bz.ksts - 1.0); // k Sample Step Size
|
||||
|
||||
_bz.f32as = 'Float32Array' in window; // float32ArraySupported
|
||||
_bz.msv = _bz.f32as ? new Float32Array (_bz.ksts) : new Array (_bz.ksts); // m Sample Values
|
||||
|
||||
_bz.A = function(aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; };
|
||||
_bz.B = function(aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; };
|
||||
_bz.C = function(aA1) { return 3.0 * aA1; };
|
||||
|
||||
_bz.r = {};
|
||||
_bz.pB = function (mX1, mY1, mX2, mY2) {
|
||||
this._p = false; var self = this;
|
||||
|
||||
_bz.r = function(aX){
|
||||
if (!self._p) _bz.pc(mX1, mX2, mY1, mY2);
|
||||
if (mX1 === mY1 && mX2 === mY2) return aX;
|
||||
|
||||
if (aX === 0) return 0;
|
||||
if (aX === 1) return 1;
|
||||
return _bz.cB(_bz.gx(aX, mX1, mX2), mY1, mY2);
|
||||
};
|
||||
return _bz.r;
|
||||
};
|
||||
|
||||
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
|
||||
_bz.cB = function(aT, aA1, aA2) { // calc Bezier
|
||||
return ((_bz.A(aA1, aA2)*aT + _bz.B(aA1, aA2))*aT + _bz.C(aA1))*aT;
|
||||
};
|
||||
|
||||
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
|
||||
_bz.gS = function (aT, aA1, aA2) { // getSlope
|
||||
return 3.0 * _bz.A(aA1, aA2)*aT*aT + 2.0 * _bz.B(aA1, aA2) * aT + _bz.C(aA1);
|
||||
};
|
||||
|
||||
_bz.bS = function(a, aA, aB, mX1, mX2) { // binary Subdivide
|
||||
var x, t, i = 0, j = _bz.sp, y = _bz.smi;
|
||||
do {
|
||||
t = aA + (aB - aA) / 2.0;
|
||||
x = _bz.cB(t, mX1, mX2) - a;
|
||||
if (x > 0.0) {
|
||||
aB = t;
|
||||
} else {
|
||||
aA = t;
|
||||
}
|
||||
} while (Math.abs(x) > j && ++i < y);
|
||||
return t;
|
||||
};
|
||||
|
||||
_bz.nri = function (aX, agt, mX1, mX2) { // newton Raphs on Iterate
|
||||
var i = 0, j = _bz.ni;
|
||||
for (i; i < j; ++i) {
|
||||
var cs = _bz.gS(agt, mX1, mX2);
|
||||
if (cs === 0.0) return agt;
|
||||
var x = _bz.cB(agt, mX1, mX2) - aX;
|
||||
agt -= x / cs;
|
||||
}
|
||||
return agt;
|
||||
};
|
||||
|
||||
_bz.csv = function (mX1, mX2) { // calc Sample Values
|
||||
var i = 0, j = _bz.ksts;
|
||||
for (i; i < j; ++i) {
|
||||
_bz.msv[i] = _bz.cB(i * _bz.ksss, mX1, mX2);
|
||||
}
|
||||
};
|
||||
|
||||
_bz.gx = function (aX,mX1,mX2) { //get to X
|
||||
var iS = 0.0, cs = 1, ls = _bz.ksts - 1;
|
||||
|
||||
for (; cs != ls && _bz.msv[cs] <= aX; ++cs) {
|
||||
iS += _bz.ksss;
|
||||
}
|
||||
--cs;
|
||||
|
||||
// Interpolate to provide an initial guess for t
|
||||
var dist = (aX - _bz.msv[cs]) / (_bz.msv[cs+1] - _bz.msv[cs]),
|
||||
gt = iS + dist * _bz.ksss,
|
||||
ins = _bz.gS(gt, mX1, mX2),
|
||||
fiS = iS + _bz.ksss;
|
||||
|
||||
if (ins >= _bz.nms) {
|
||||
return _bz.nri(aX, gt, mX1, mX2);
|
||||
} else if (ins === 0.0) {
|
||||
return gt;
|
||||
(function(kute_ea){
|
||||
// Obtain a reference to the base KUTE.
|
||||
// Since KUTE supports a variety of module systems,
|
||||
// we need to pick up which one to use.
|
||||
if(define == "function") {
|
||||
define(["./kute.js"], function(KUTE){ kute_ea(KUTE); return KUTE; });
|
||||
} else if(typeof module == "object" && typeof require == "function") {
|
||||
// We assume, that require() is sync.
|
||||
var KUTE = require("./kute.js");
|
||||
kute_ea(KUTE);
|
||||
// Export the modified one. Not really required, but convenient.
|
||||
module.exports = KUTE;
|
||||
} else if(typeof root.KUTE != "undefined") {
|
||||
kute_ea(root.KUTE);
|
||||
} else {
|
||||
return _bz.bS(aX, iS, fiS, mX1, mX2);
|
||||
throw new Error("KUTE.js Bezier/Easing depends on KUTE.js. Read the docs for more info.")
|
||||
}
|
||||
};
|
||||
})(function(KUTE){
|
||||
KUTE.Ease = {};
|
||||
|
||||
_bz.pc = function(mX1, mX2, mY1, mY2) {
|
||||
this._p = true;
|
||||
if (mX1 != mY1 || mX2 != mY2)
|
||||
_bz.csv(mX1, mX2);
|
||||
};
|
||||
KUTE.Ease.bezier = function(mX1, mY1, mX2, mY2) {
|
||||
return _bz.pB(mX1, mY1, mX2, mY2);
|
||||
};
|
||||
|
||||
// predefined bezier based easings, can be accessed via string, eg 'easeIn' or 'easeInOutQuart'
|
||||
// _easings = ["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInExpo","easeOutExpo","easeInOutExpo","slowMo","slowMo1","slowMo2"],
|
||||
KUTE.Ease.easeIn = function(){ return _bz.pB(0.42, 0.0, 1.00, 1.0); };
|
||||
KUTE.Ease.easeOut = function(){ return _bz.pB(0.00, 0.0, 0.58, 1.0); };
|
||||
KUTE.Ease.easeInOut = function(){ return _bz.pB(0.50, 0.16, 0.49, 0.86); };
|
||||
var _bz = KUTE.Ease.bezier.prototype;
|
||||
|
||||
KUTE.Ease.easeInSine = function(){ return _bz.pB(0.47, 0, 0.745, 0.715); };
|
||||
KUTE.Ease.easeOutSine = function(){ return _bz.pB(0.39, 0.575, 0.565, 1); };
|
||||
KUTE.Ease.easeInOutSine = function(){ return _bz.pB(0.445, 0.05, 0.55, 0.95); };
|
||||
// These values are established by empiricism with tests (tradeoff: performance VS precision)
|
||||
_bz.ni = 4; // NEWTON_ITERATIONS
|
||||
_bz.nms = 0.001; // NEWTON_MIN_SLOPE
|
||||
_bz.sp = 0.0000001; // SUBDIVISION_PRECISION
|
||||
_bz.smi = 10, // SUBDIVISION_MAX_ITERATIONS
|
||||
|
||||
KUTE.Ease.easeInQuad = function () { return _bz.pB(0.550, 0.085, 0.680, 0.530); };
|
||||
KUTE.Ease.easeOutQuad = function () { return _bz.pB(0.250, 0.460, 0.450, 0.940); };
|
||||
KUTE.Ease.easeInOutQuad = function () { return _bz.pB(0.455, 0.030, 0.515, 0.955); };
|
||||
_bz.ksts = 11; // k Spline Table Size
|
||||
_bz.ksss = 1.0 / (_bz.ksts - 1.0); // k Sample Step Size
|
||||
|
||||
KUTE.Ease.easeInCubic = function () { return _bz.pB(0.55, 0.055, 0.675, 0.19); };
|
||||
KUTE.Ease.easeOutCubic = function () { return _bz.pB(0.215, 0.61, 0.355, 1); };
|
||||
KUTE.Ease.easeInOutCubic = function () { return _bz.pB(0.645, 0.045, 0.355, 1); };
|
||||
_bz.f32as = 'Float32Array' in window; // float32ArraySupported
|
||||
_bz.msv = _bz.f32as ? new Float32Array (_bz.ksts) : new Array (_bz.ksts); // m Sample Values
|
||||
|
||||
KUTE.Ease.easeInQuart = function () { return _bz.pB(0.895, 0.03, 0.685, 0.22); };
|
||||
KUTE.Ease.easeOutQuart = function () { return _bz.pB(0.165, 0.84, 0.44, 1); };
|
||||
KUTE.Ease.easeInOutQuart = function () { return _bz.pB(0.77, 0, 0.175, 1); };
|
||||
_bz.A = function(aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; };
|
||||
_bz.B = function(aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; };
|
||||
_bz.C = function(aA1) { return 3.0 * aA1; };
|
||||
|
||||
KUTE.Ease.easeInQuint = function(){ return _bz.pB(0.755, 0.05, 0.855, 0.06); };
|
||||
KUTE.Ease.easeOutQuint = function(){ return _bz.pB(0.23, 1, 0.32, 1); };
|
||||
KUTE.Ease.easeInOutQuint = function(){ return _bz.pB(0.86, 0, 0.07, 1); };
|
||||
_bz.r = {};
|
||||
_bz.pB = function (mX1, mY1, mX2, mY2) {
|
||||
this._p = false; var self = this;
|
||||
|
||||
KUTE.Ease.easeInExpo = function(){ return _bz.pB(0.95, 0.05, 0.795, 0.035); };
|
||||
KUTE.Ease.easeOutExpo = function(){ return _bz.pB(0.19, 1, 0.22, 1); };
|
||||
KUTE.Ease.easeInOutExpo = function(){ return _bz.pB(1, 0, 0, 1); };
|
||||
_bz.r = function(aX){
|
||||
if (!self._p) _bz.pc(mX1, mX2, mY1, mY2);
|
||||
if (mX1 === mY1 && mX2 === mY2) return aX;
|
||||
|
||||
KUTE.Ease.easeInCirc = function(){ return _bz.pB(0.6, 0.04, 0.98, 0.335); };
|
||||
KUTE.Ease.easeOutCirc = function(){ return _bz.pB(0.075, 0.82, 0.165, 1); };
|
||||
KUTE.Ease.easeInOutCirc = function(){ return _bz.pB(0.785, 0.135, 0.15, 0.86); };
|
||||
if (aX === 0) return 0;
|
||||
if (aX === 1) return 1;
|
||||
return _bz.cB(_bz.gx(aX, mX1, mX2), mY1, mY2);
|
||||
};
|
||||
return _bz.r;
|
||||
};
|
||||
|
||||
KUTE.Ease.easeInBack = function(){ return _bz.pB(0.600, -0.280, 0.735, 0.045); };
|
||||
KUTE.Ease.easeOutBack = function(){ return _bz.pB(0.175, 0.885, 0.320, 1.275); };
|
||||
KUTE.Ease.easeInOutBack = function(){ return _bz.pB(0.68, -0.55, 0.265, 1.55); };
|
||||
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
|
||||
_bz.cB = function(aT, aA1, aA2) { // calc Bezier
|
||||
return ((_bz.A(aA1, aA2)*aT + _bz.B(aA1, aA2))*aT + _bz.C(aA1))*aT;
|
||||
};
|
||||
|
||||
KUTE.Ease.slowMo = function(){ return _bz.pB(0.000, 0.500, 1.000, 0.500); };
|
||||
KUTE.Ease.slowMo1 = function(){ return _bz.pB(0.000, 0.700, 1.000, 0.300); };
|
||||
KUTE.Ease.slowMo2 = function(){ return _bz.pB(0.000, 0.900, 1.000, 0.100); };
|
||||
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
|
||||
_bz.gS = function (aT, aA1, aA2) { // getSlope
|
||||
return 3.0 * _bz.A(aA1, aA2)*aT*aT + 2.0 * _bz.B(aA1, aA2) * aT + _bz.C(aA1);
|
||||
};
|
||||
|
||||
_bz.bS = function(a, aA, aB, mX1, mX2) { // binary Subdivide
|
||||
var x, t, i = 0, j = _bz.sp, y = _bz.smi;
|
||||
do {
|
||||
t = aA + (aB - aA) / 2.0;
|
||||
x = _bz.cB(t, mX1, mX2) - a;
|
||||
if (x > 0.0) {
|
||||
aB = t;
|
||||
} else {
|
||||
aA = t;
|
||||
}
|
||||
} while (Math.abs(x) > j && ++i < y);
|
||||
return t;
|
||||
};
|
||||
|
||||
_bz.nri = function (aX, agt, mX1, mX2) { // newton Raphs on Iterate
|
||||
var i = 0, j = _bz.ni;
|
||||
for (i; i < j; ++i) {
|
||||
var cs = _bz.gS(agt, mX1, mX2);
|
||||
if (cs === 0.0) return agt;
|
||||
var x = _bz.cB(agt, mX1, mX2) - aX;
|
||||
agt -= x / cs;
|
||||
}
|
||||
return agt;
|
||||
};
|
||||
|
||||
_bz.csv = function (mX1, mX2) { // calc Sample Values
|
||||
var i = 0, j = _bz.ksts;
|
||||
for (i; i < j; ++i) {
|
||||
_bz.msv[i] = _bz.cB(i * _bz.ksss, mX1, mX2);
|
||||
}
|
||||
};
|
||||
|
||||
_bz.gx = function (aX,mX1,mX2) { //get to X
|
||||
var iS = 0.0, cs = 1, ls = _bz.ksts - 1;
|
||||
|
||||
for (; cs != ls && _bz.msv[cs] <= aX; ++cs) {
|
||||
iS += _bz.ksss;
|
||||
}
|
||||
--cs;
|
||||
|
||||
// Interpolate to provide an initial guess for t
|
||||
var dist = (aX - _bz.msv[cs]) / (_bz.msv[cs+1] - _bz.msv[cs]),
|
||||
gt = iS + dist * _bz.ksss,
|
||||
ins = _bz.gS(gt, mX1, mX2),
|
||||
fiS = iS + _bz.ksss;
|
||||
|
||||
if (ins >= _bz.nms) {
|
||||
return _bz.nri(aX, gt, mX1, mX2);
|
||||
} else if (ins === 0.0) {
|
||||
return gt;
|
||||
} else {
|
||||
return _bz.bS(aX, iS, fiS, mX1, mX2);
|
||||
}
|
||||
};
|
||||
|
||||
_bz.pc = function(mX1, mX2, mY1, mY2) {
|
||||
this._p = true;
|
||||
if (mX1 != mY1 || mX2 != mY2)
|
||||
_bz.csv(mX1, mX2);
|
||||
};
|
||||
|
||||
// predefined bezier based easings, can be accessed via string, eg 'easeIn' or 'easeInOutQuart'
|
||||
// _easings = ["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInExpo","easeOutExpo","easeInOutExpo","slowMo","slowMo1","slowMo2"],
|
||||
KUTE.Ease.easeIn = function(){ return _bz.pB(0.42, 0.0, 1.00, 1.0); };
|
||||
KUTE.Ease.easeOut = function(){ return _bz.pB(0.00, 0.0, 0.58, 1.0); };
|
||||
KUTE.Ease.easeInOut = function(){ return _bz.pB(0.50, 0.16, 0.49, 0.86); };
|
||||
|
||||
KUTE.Ease.easeInSine = function(){ return _bz.pB(0.47, 0, 0.745, 0.715); };
|
||||
KUTE.Ease.easeOutSine = function(){ return _bz.pB(0.39, 0.575, 0.565, 1); };
|
||||
KUTE.Ease.easeInOutSine = function(){ return _bz.pB(0.445, 0.05, 0.55, 0.95); };
|
||||
|
||||
KUTE.Ease.easeInQuad = function () { return _bz.pB(0.550, 0.085, 0.680, 0.530); };
|
||||
KUTE.Ease.easeOutQuad = function () { return _bz.pB(0.250, 0.460, 0.450, 0.940); };
|
||||
KUTE.Ease.easeInOutQuad = function () { return _bz.pB(0.455, 0.030, 0.515, 0.955); };
|
||||
|
||||
KUTE.Ease.easeInCubic = function () { return _bz.pB(0.55, 0.055, 0.675, 0.19); };
|
||||
KUTE.Ease.easeOutCubic = function () { return _bz.pB(0.215, 0.61, 0.355, 1); };
|
||||
KUTE.Ease.easeInOutCubic = function () { return _bz.pB(0.645, 0.045, 0.355, 1); };
|
||||
|
||||
KUTE.Ease.easeInQuart = function () { return _bz.pB(0.895, 0.03, 0.685, 0.22); };
|
||||
KUTE.Ease.easeOutQuart = function () { return _bz.pB(0.165, 0.84, 0.44, 1); };
|
||||
KUTE.Ease.easeInOutQuart = function () { return _bz.pB(0.77, 0, 0.175, 1); };
|
||||
|
||||
KUTE.Ease.easeInQuint = function(){ return _bz.pB(0.755, 0.05, 0.855, 0.06); };
|
||||
KUTE.Ease.easeOutQuint = function(){ return _bz.pB(0.23, 1, 0.32, 1); };
|
||||
KUTE.Ease.easeInOutQuint = function(){ return _bz.pB(0.86, 0, 0.07, 1); };
|
||||
|
||||
KUTE.Ease.easeInExpo = function(){ return _bz.pB(0.95, 0.05, 0.795, 0.035); };
|
||||
KUTE.Ease.easeOutExpo = function(){ return _bz.pB(0.19, 1, 0.22, 1); };
|
||||
KUTE.Ease.easeInOutExpo = function(){ return _bz.pB(1, 0, 0, 1); };
|
||||
|
||||
KUTE.Ease.easeInCirc = function(){ return _bz.pB(0.6, 0.04, 0.98, 0.335); };
|
||||
KUTE.Ease.easeOutCirc = function(){ return _bz.pB(0.075, 0.82, 0.165, 1); };
|
||||
KUTE.Ease.easeInOutCirc = function(){ return _bz.pB(0.785, 0.135, 0.15, 0.86); };
|
||||
|
||||
KUTE.Ease.easeInBack = function(){ return _bz.pB(0.600, -0.280, 0.735, 0.045); };
|
||||
KUTE.Ease.easeOutBack = function(){ return _bz.pB(0.175, 0.885, 0.320, 1.275); };
|
||||
KUTE.Ease.easeInOutBack = function(){ return _bz.pB(0.68, -0.55, 0.265, 1.55); };
|
||||
|
||||
KUTE.Ease.slowMo = function(){ return _bz.pB(0.000, 0.500, 1.000, 0.500); };
|
||||
KUTE.Ease.slowMo1 = function(){ return _bz.pB(0.000, 0.700, 1.000, 0.300); };
|
||||
KUTE.Ease.slowMo2 = function(){ return _bz.pB(0.000, 0.900, 1.000, 0.100); };
|
||||
});
|
||||
|
|
|
@ -4,7 +4,28 @@
|
|||
* Licensed under MIT-License
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
(function(kutejQuery){
|
||||
// We need to require the root KUTE and jQuery.
|
||||
if(define == "function") {
|
||||
define(["./kute.js", "jQuery"], function(KUTE, $){
|
||||
kutejQuery($, KUTE);
|
||||
return KUTE;
|
||||
});
|
||||
} else if(typeof module == "object" && typeof require == "function") {
|
||||
// We assume, that require() is sync.
|
||||
var KUTE = require("./kute.js");
|
||||
var $ = require("jQuery");
|
||||
kutejQuery($, KUTE);
|
||||
// Export the modified one. Not really required, but convenient.
|
||||
module.exports = $;
|
||||
} else if(typeof root.KUTE != "undefined") {
|
||||
// jQuery always has two ways of existing... Find one, and pass.
|
||||
var $ = root.jQuery || root.$;
|
||||
kutejQuery($, root.KUTE);
|
||||
} else {
|
||||
throw new Error("KUTE.js jQuery depends on KUTE.js and jQuery. Read the docs for more info.")
|
||||
}
|
||||
})(function($, KUTE) {
|
||||
$.fn.KUTE = function( method, start, end, ops ) { // method can be Animate(), fromTo(), to(), stop(), start(), chain(), pause()
|
||||
var tws = [], i, l = this.length;
|
||||
|
||||
|
@ -23,4 +44,4 @@
|
|||
}
|
||||
return tws;
|
||||
};
|
||||
})(jQuery);
|
||||
});
|
||||
|
|
553
kute-physics.js
553
kute-physics.js
|
@ -6,297 +6,316 @@
|
|||
* Licensed under MIT-License
|
||||
*/
|
||||
|
||||
KUTE.Physics = {};
|
||||
var _kp = KUTE.Physics, _hPI = Math.PI / 2;
|
||||
|
||||
// spring easing
|
||||
_kp.spring = function(options) {
|
||||
options = options || {};
|
||||
|
||||
var fq = Math.max(1, (options.frequency || 300 ) / 20),
|
||||
fc = Math.pow(20, (options.friction || 200 ) / 100),
|
||||
aSt = options.anticipationStrength || 0,
|
||||
aS = (options.anticipationSize || 0) / 1000;
|
||||
|
||||
_kps.run = function(t) {
|
||||
var A, At, a, angle, b, frictionT, y0, yS;
|
||||
|
||||
frictionT = (t / (1 - aS)) - (aS / (1 - aS));
|
||||
if (t < aS) {
|
||||
yS = (aS / (1 - aS)) - (aS / (1 - aS));
|
||||
y0 = (0 / (1 - aS)) - (aS / (1 - aS));
|
||||
b = Math.acos(1 / _kps.A1(t,yS));
|
||||
a = (Math.acos(1 / _kps.A1(t,y0)) - b) / (fq * (-aS));
|
||||
A = _kps.A1;
|
||||
(function(kutePhysics){
|
||||
// Obtain a reference to the base KUTE.
|
||||
// Since KUTE supports a variety of module systems,
|
||||
// we need to pick up which one to use.
|
||||
if(define == "function") {
|
||||
define(["./kute.js"], function(KUTE){ kutePhysics(KUTE); return KUTE; });
|
||||
} else if(typeof module == "object" && typeof require == "function") {
|
||||
// We assume, that require() is sync.
|
||||
var KUTE = require("./kute.js");
|
||||
kutePhysics(KUTE);
|
||||
// Export the modified one. Not really required, but convenient.
|
||||
module.exports = KUTE;
|
||||
} else if(typeof root.KUTE != "undefined") {
|
||||
kutePhysics(root.KUTE);
|
||||
} else {
|
||||
A = _kps.A2;
|
||||
b = 0;
|
||||
a = 1;
|
||||
throw new Error("KUTE.js Physics depends on KUTE.js. Read the docs for more info.")
|
||||
}
|
||||
At = A(frictionT,aS,aSt,fc);
|
||||
angle = fq * (t - aS) * a + b;
|
||||
return 1 - (At * Math.cos(angle));
|
||||
};
|
||||
})(function(KUTE){
|
||||
KUTE.Physics = {};
|
||||
var _kp = KUTE.Physics, _hPI = Math.PI / 2;
|
||||
|
||||
return _kps.run;
|
||||
};
|
||||
// spring easing
|
||||
_kp.spring = function(options) {
|
||||
options = options || {};
|
||||
|
||||
var _kps = _kp.spring.prototype;
|
||||
_kps.run = {};
|
||||
_kps.A1 = function(t,aS,aSt) {
|
||||
var a, b, x0, x1;
|
||||
x0 = aS / (1 - aS);
|
||||
x1 = 0;
|
||||
b = (x0 - (0.8 * x1)) / (x0 - x1);
|
||||
a = (0.8 - b) / x0;
|
||||
return (a * t * aSt / 100) + b;
|
||||
};
|
||||
_kps.A2 = function(t,aS,aSt,f) {
|
||||
return Math.pow(f / 10, -t) * (1 - t);
|
||||
};
|
||||
var fq = Math.max(1, (options.frequency || 300 ) / 20),
|
||||
fc = Math.pow(20, (options.friction || 200 ) / 100),
|
||||
aSt = options.anticipationStrength || 0,
|
||||
aS = (options.anticipationSize || 0) / 1000;
|
||||
|
||||
_kps.run = function(t) {
|
||||
var A, At, a, angle, b, frictionT, y0, yS;
|
||||
|
||||
// bounce
|
||||
_kp.bounce = function(options) {
|
||||
options = options || {};
|
||||
var fq = Math.max(1, (options.frequency || 300) / 20),
|
||||
f = Math.pow(20, (options.friction || 200) / 100);
|
||||
|
||||
_kpo.run = function(t) {
|
||||
var At = Math.pow(f / 10, -t) * (1 - t),
|
||||
angle = fq * t * 1 + _hPI;
|
||||
return At * Math.cos(angle);
|
||||
};
|
||||
return _kpo.run;
|
||||
};
|
||||
|
||||
var _kpo = _kp.bounce.prototype;
|
||||
_kpo.run = {};
|
||||
|
||||
|
||||
// gravity
|
||||
_kp.gravity = function(options) {
|
||||
var bounciness, curves, elasticity, gravity, initialForce;
|
||||
|
||||
options = options || {};
|
||||
bounciness = ( options.bounciness || 400 ) / 1250;
|
||||
elasticity = ( options.elasticity || 200 ) / 1000;
|
||||
initialForce = options.initialForce || false;
|
||||
|
||||
gravity = 100;
|
||||
curves = [];
|
||||
_kpg.L = (function() {
|
||||
var b, curve;
|
||||
b = Math.sqrt(2 / gravity);
|
||||
curve = {
|
||||
a: -b,
|
||||
b: b,
|
||||
H: 1
|
||||
};
|
||||
if (initialForce) {
|
||||
curve.a = 0;
|
||||
curve.b = curve.b * 2;
|
||||
}
|
||||
while (curve.H > 0.001) {
|
||||
_kpg.L = curve.b - curve.a;
|
||||
curve = {
|
||||
a: curve.b,
|
||||
b: curve.b + _kpg.L * bounciness,
|
||||
H: curve.H * bounciness * bounciness
|
||||
frictionT = (t / (1 - aS)) - (aS / (1 - aS));
|
||||
if (t < aS) {
|
||||
yS = (aS / (1 - aS)) - (aS / (1 - aS));
|
||||
y0 = (0 / (1 - aS)) - (aS / (1 - aS));
|
||||
b = Math.acos(1 / _kps.A1(t,yS));
|
||||
a = (Math.acos(1 / _kps.A1(t,y0)) - b) / (fq * (-aS));
|
||||
A = _kps.A1;
|
||||
} else {
|
||||
A = _kps.A2;
|
||||
b = 0;
|
||||
a = 1;
|
||||
}
|
||||
At = A(frictionT,aS,aSt,fc);
|
||||
angle = fq * (t - aS) * a + b;
|
||||
return 1 - (At * Math.cos(angle));
|
||||
};
|
||||
}
|
||||
return curve.b;
|
||||
})();
|
||||
|
||||
(function() {
|
||||
var L2, b, curve, _results;
|
||||
b = Math.sqrt(2 / (gravity * _kpg.L * _kpg.L));
|
||||
curve = {
|
||||
a: -b,
|
||||
b: b,
|
||||
H: 1
|
||||
return _kps.run;
|
||||
};
|
||||
if (initialForce) {
|
||||
curve.a = 0;
|
||||
curve.b = curve.b * 2;
|
||||
}
|
||||
curves.push(curve);
|
||||
L2 = _kpg.L;
|
||||
_results = [];
|
||||
while (curve.b < 1 && curve.H > 0.001) {
|
||||
L2 = curve.b - curve.a;
|
||||
curve = {
|
||||
a: curve.b,
|
||||
b: curve.b + L2 * bounciness,
|
||||
H: curve.H * elasticity
|
||||
|
||||
var _kps = _kp.spring.prototype;
|
||||
_kps.run = {};
|
||||
_kps.A1 = function(t,aS,aSt) {
|
||||
var a, b, x0, x1;
|
||||
x0 = aS / (1 - aS);
|
||||
x1 = 0;
|
||||
b = (x0 - (0.8 * x1)) / (x0 - x1);
|
||||
a = (0.8 - b) / x0;
|
||||
return (a * t * aSt / 100) + b;
|
||||
};
|
||||
_kps.A2 = function(t,aS,aSt,f) {
|
||||
return Math.pow(f / 10, -t) * (1 - t);
|
||||
};
|
||||
|
||||
|
||||
// bounce
|
||||
_kp.bounce = function(options) {
|
||||
options = options || {};
|
||||
var fq = Math.max(1, (options.frequency || 300) / 20),
|
||||
f = Math.pow(20, (options.friction || 200) / 100);
|
||||
|
||||
_kpo.run = function(t) {
|
||||
var At = Math.pow(f / 10, -t) * (1 - t),
|
||||
angle = fq * t * 1 + _hPI;
|
||||
return At * Math.cos(angle);
|
||||
};
|
||||
_results.push(curves.push(curve));
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
_kpg.fn = function(t) {
|
||||
var curve, i, v;
|
||||
i = 0;
|
||||
curve = curves[i];
|
||||
while (!(t >= curve.a && t <= curve.b)) {
|
||||
i += 1;
|
||||
curve = curves[i];
|
||||
if (!curve) {
|
||||
break;
|
||||
return _kpo.run;
|
||||
};
|
||||
|
||||
var _kpo = _kp.bounce.prototype;
|
||||
_kpo.run = {};
|
||||
|
||||
|
||||
// gravity
|
||||
_kp.gravity = function(options) {
|
||||
var bounciness, curves, elasticity, gravity, initialForce;
|
||||
|
||||
options = options || {};
|
||||
bounciness = ( options.bounciness || 400 ) / 1250;
|
||||
elasticity = ( options.elasticity || 200 ) / 1000;
|
||||
initialForce = options.initialForce || false;
|
||||
|
||||
gravity = 100;
|
||||
curves = [];
|
||||
_kpg.L = (function() {
|
||||
var b, curve;
|
||||
b = Math.sqrt(2 / gravity);
|
||||
curve = {
|
||||
a: -b,
|
||||
b: b,
|
||||
H: 1
|
||||
};
|
||||
if (initialForce) {
|
||||
curve.a = 0;
|
||||
curve.b = curve.b * 2;
|
||||
}
|
||||
while (curve.H > 0.001) {
|
||||
_kpg.L = curve.b - curve.a;
|
||||
curve = {
|
||||
a: curve.b,
|
||||
b: curve.b + _kpg.L * bounciness,
|
||||
H: curve.H * bounciness * bounciness
|
||||
};
|
||||
}
|
||||
return curve.b;
|
||||
})();
|
||||
|
||||
(function() {
|
||||
var L2, b, curve, _results;
|
||||
b = Math.sqrt(2 / (gravity * _kpg.L * _kpg.L));
|
||||
curve = {
|
||||
a: -b,
|
||||
b: b,
|
||||
H: 1
|
||||
};
|
||||
if (initialForce) {
|
||||
curve.a = 0;
|
||||
curve.b = curve.b * 2;
|
||||
}
|
||||
curves.push(curve);
|
||||
L2 = _kpg.L;
|
||||
_results = [];
|
||||
while (curve.b < 1 && curve.H > 0.001) {
|
||||
L2 = curve.b - curve.a;
|
||||
curve = {
|
||||
a: curve.b,
|
||||
b: curve.b + L2 * bounciness,
|
||||
H: curve.H * elasticity
|
||||
};
|
||||
_results.push(curves.push(curve));
|
||||
}
|
||||
return _results;
|
||||
})();
|
||||
_kpg.fn = function(t) {
|
||||
var curve, i, v;
|
||||
i = 0;
|
||||
curve = curves[i];
|
||||
while (!(t >= curve.a && t <= curve.b)) {
|
||||
i += 1;
|
||||
curve = curves[i];
|
||||
if (!curve) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!curve) {
|
||||
v = initialForce ? 0 : 1;
|
||||
} else {
|
||||
v = _kpg.getPointInCurve(curve.a, curve.b, curve.H, t, options, _kpg.L);
|
||||
}
|
||||
return v;
|
||||
};
|
||||
|
||||
return _kpg.fn;
|
||||
};
|
||||
|
||||
var _kpg = _kp.gravity.prototype;
|
||||
_kpg.L = {};
|
||||
_kpg.fn = {};
|
||||
_kpg.getPointInCurve = function(a, b, H, t, o, L) {
|
||||
var c, t2;
|
||||
L = b - a;
|
||||
t2 = (2 / L) * t - 1 - (a * 2 / L);
|
||||
c = t2 * t2 * H - H + 1;
|
||||
if (o.initialForce) {
|
||||
c = 1 - c;
|
||||
}
|
||||
}
|
||||
if (!curve) {
|
||||
v = initialForce ? 0 : 1;
|
||||
} else {
|
||||
v = _kpg.getPointInCurve(curve.a, curve.b, curve.H, t, options, _kpg.L);
|
||||
}
|
||||
return v;
|
||||
};
|
||||
return c;
|
||||
};
|
||||
|
||||
return _kpg.fn;
|
||||
};
|
||||
|
||||
var _kpg = _kp.gravity.prototype;
|
||||
_kpg.L = {};
|
||||
_kpg.fn = {};
|
||||
_kpg.getPointInCurve = function(a, b, H, t, o, L) {
|
||||
var c, t2;
|
||||
L = b - a;
|
||||
t2 = (2 / L) * t - 1 - (a * 2 / L);
|
||||
c = t2 * t2 * H - H + 1;
|
||||
if (o.initialForce) {
|
||||
c = 1 - c;
|
||||
}
|
||||
return c;
|
||||
};
|
||||
|
||||
//throw up and pull down by gravity
|
||||
_kp.forceWithGravity = function(o) {
|
||||
var ops = o || {};
|
||||
ops.initialForce = true;
|
||||
return _kp.gravity(ops);
|
||||
};
|
||||
//throw up and pull down by gravity
|
||||
_kp.forceWithGravity = function(o) {
|
||||
var ops = o || {};
|
||||
ops.initialForce = true;
|
||||
return _kp.gravity(ops);
|
||||
};
|
||||
|
||||
|
||||
// multi point bezier
|
||||
_kp.bezier = function(options) {
|
||||
options = options || {};
|
||||
var points = options.points,
|
||||
returnsToSelf = false, Bs = [];
|
||||
// multi point bezier
|
||||
_kp.bezier = function(options) {
|
||||
options = options || {};
|
||||
var points = options.points,
|
||||
returnsToSelf = false, Bs = [];
|
||||
|
||||
(function() {
|
||||
var i, k;
|
||||
(function() {
|
||||
var i, k;
|
||||
|
||||
for (i in points) {
|
||||
k = parseInt(i);
|
||||
if (k >= points.length - 1) {
|
||||
for (i in points) {
|
||||
k = parseInt(i);
|
||||
if (k >= points.length - 1) {
|
||||
break;
|
||||
}
|
||||
_kpb.fn(points[k], points[k + 1], Bs);
|
||||
}
|
||||
return Bs;
|
||||
})();
|
||||
|
||||
_kpb.run = function(t) {
|
||||
if (t === 0) {
|
||||
return 0;
|
||||
} else if (t === 1) {
|
||||
return 1;
|
||||
} else {
|
||||
return _kpb.yForX(t, Bs, returnsToSelf);
|
||||
}
|
||||
};
|
||||
return _kpb.run;
|
||||
};
|
||||
|
||||
var _kpb = _kp.bezier.prototype;
|
||||
_kpb.B2 = {};
|
||||
_kpb.run = {};
|
||||
|
||||
_kpb.fn = function(pointA, pointB, Bs) {
|
||||
var B2 = function(t) {
|
||||
return _kpb.Bezier(t, pointA, pointA.cp[pointA.cp.length - 1], pointB.cp[0], pointB);
|
||||
};
|
||||
return Bs.push(B2);
|
||||
};
|
||||
|
||||
_kpb.Bezier = function(t, p0, p1, p2, p3) {
|
||||
return {
|
||||
x: (Math.pow(1 - t, 3) * p0.x) + (3 * Math.pow(1 - t, 2) * t * p1.x) + (3 * (1 - t) * Math.pow(t, 2) * p2.x) + Math.pow(t, 3) * p3.x,
|
||||
y: (Math.pow(1 - t, 3) * p0.y) + (3 * Math.pow(1 - t, 2) * t * p1.y) + (3 * (1 - t) * Math.pow(t, 2) * p2.y) + Math.pow(t, 3) * p3.y
|
||||
};
|
||||
};
|
||||
|
||||
_kpb.yForX = function(xTarget, Bs, rTS) {
|
||||
var B, aB, i, lower, percent, upper, x, xT, _i = 0, _len = Bs.length;
|
||||
B = null;
|
||||
for (_i; _i < _len; _i++) {
|
||||
aB = Bs[_i];
|
||||
if (xTarget >= aB(0).x && xTarget <= aB(1).x) {
|
||||
B = aB;
|
||||
}
|
||||
if (B !== null) {
|
||||
break;
|
||||
}
|
||||
_kpb.fn(points[k], points[k + 1], Bs);
|
||||
}
|
||||
return Bs;
|
||||
})();
|
||||
|
||||
_kpb.run = function(t) {
|
||||
if (t === 0) {
|
||||
return 0;
|
||||
} else if (t === 1) {
|
||||
return 1;
|
||||
} else {
|
||||
return _kpb.yForX(t, Bs, returnsToSelf);
|
||||
if (!B) {
|
||||
return ( rTS ? 0 : 1 );
|
||||
}
|
||||
xT = 0.0001; // xTolerance
|
||||
lower = 0; upper = 1;
|
||||
percent = (upper + lower) / 2;
|
||||
x = B(percent).x; i = 0;
|
||||
while (Math.abs(xTarget - x) > xT && i < 100) {
|
||||
if (xTarget > x) {
|
||||
lower = percent;
|
||||
} else {
|
||||
upper = percent;
|
||||
}
|
||||
percent = (upper + lower) / 2;
|
||||
x = B(percent).x;
|
||||
i++;
|
||||
}
|
||||
return B(percent).y;
|
||||
};
|
||||
return _kpb.run;
|
||||
};
|
||||
|
||||
var _kpb = _kp.bezier.prototype;
|
||||
_kpb.B2 = {};
|
||||
_kpb.run = {};
|
||||
_kp.physicsInOut = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [ { x: 0, y: 0, cp: [ { x: 0.92 - (friction / 1000), y: 0 } ] }, { x: 1, y: 1, cp: [ { x: 0.08 + (friction / 1000), y: 1 } ] } ] });
|
||||
};
|
||||
|
||||
_kpb.fn = function(pointA, pointB, Bs) {
|
||||
var B2 = function(t) {
|
||||
return _kpb.Bezier(t, pointA, pointA.cp[pointA.cp.length - 1], pointB.cp[0], pointB);
|
||||
};
|
||||
return Bs.push(B2);
|
||||
};
|
||||
_kp.physicsIn = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [ { x: 0, y: 0, cp: [ { x: 0.92 - (friction / 1000), y: 0 } ] }, { x: 1, y: 1, cp: [ { x: 1, y: 1 } ] } ] });
|
||||
};
|
||||
|
||||
_kpb.Bezier = function(t, p0, p1, p2, p3) {
|
||||
return {
|
||||
x: (Math.pow(1 - t, 3) * p0.x) + (3 * Math.pow(1 - t, 2) * t * p1.x) + (3 * (1 - t) * Math.pow(t, 2) * p2.x) + Math.pow(t, 3) * p3.x,
|
||||
y: (Math.pow(1 - t, 3) * p0.y) + (3 * Math.pow(1 - t, 2) * t * p1.y) + (3 * (1 - t) * Math.pow(t, 2) * p2.y) + Math.pow(t, 3) * p3.y
|
||||
};
|
||||
};
|
||||
_kp.physicsOut = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [ { x: 0, y: 0, cp: [ { x: 0, y: 0 } ] }, { x: 1, y: 1, cp: [ { x: 0.08 + (friction / 1000), y: 1 } ] }] });
|
||||
};
|
||||
|
||||
_kpb.yForX = function(xTarget, Bs, rTS) {
|
||||
var B, aB, i, lower, percent, upper, x, xT, _i = 0, _len = Bs.length;
|
||||
B = null;
|
||||
for (_i; _i < _len; _i++) {
|
||||
aB = Bs[_i];
|
||||
if (xTarget >= aB(0).x && xTarget <= aB(1).x) {
|
||||
B = aB;
|
||||
}
|
||||
if (B !== null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!B) {
|
||||
return ( rTS ? 0 : 1 );
|
||||
}
|
||||
xT = 0.0001; // xTolerance
|
||||
lower = 0; upper = 1;
|
||||
percent = (upper + lower) / 2;
|
||||
x = B(percent).x; i = 0;
|
||||
while (Math.abs(xTarget - x) > xT && i < 100) {
|
||||
if (xTarget > x) {
|
||||
lower = percent;
|
||||
} else {
|
||||
upper = percent;
|
||||
}
|
||||
percent = (upper + lower) / 2;
|
||||
x = B(percent).x;
|
||||
i++;
|
||||
}
|
||||
return B(percent).y;
|
||||
};
|
||||
_kp.physicsBackOut = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [{"x":0,"y":0,"cp":[{"x":0,"y":0}]},{"x":1,"y":1,"cp":[{"x":0.735+(friction/1000),"y":1.3}]}] });
|
||||
};
|
||||
|
||||
_kp.physicsInOut = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [ { x: 0, y: 0, cp: [ { x: 0.92 - (friction / 1000), y: 0 } ] }, { x: 1, y: 1, cp: [ { x: 0.08 + (friction / 1000), y: 1 } ] } ] });
|
||||
};
|
||||
_kp.physicsBackIn = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [{"x":0,"y":0,"cp":[{"x":0.28-(friction / 1000),"y":-0.6}]},{"x":1,"y":1,"cp":[{"x":1,"y":1}]}] });
|
||||
};
|
||||
|
||||
_kp.physicsIn = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [ { x: 0, y: 0, cp: [ { x: 0.92 - (friction / 1000), y: 0 } ] }, { x: 1, y: 1, cp: [ { x: 1, y: 1 } ] } ] });
|
||||
};
|
||||
|
||||
_kp.physicsOut = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [ { x: 0, y: 0, cp: [ { x: 0, y: 0 } ] }, { x: 1, y: 1, cp: [ { x: 0.08 + (friction / 1000), y: 1 } ] }] });
|
||||
};
|
||||
|
||||
_kp.physicsBackOut = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [{"x":0,"y":0,"cp":[{"x":0,"y":0}]},{"x":1,"y":1,"cp":[{"x":0.735+(friction/1000),"y":1.3}]}] });
|
||||
};
|
||||
|
||||
_kp.physicsBackIn = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [{"x":0,"y":0,"cp":[{"x":0.28-(friction / 1000),"y":-0.6}]},{"x":1,"y":1,"cp":[{"x":1,"y":1}]}] });
|
||||
};
|
||||
|
||||
_kp.physicsBackInOut = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [{"x":0,"y":0,"cp":[{"x":0.68-(friction / 1000),"y":-0.55}]},{"x":1,"y":1,"cp":[{"x":0.265+(friction / 1000),"y":1.45}]}] });
|
||||
};
|
||||
_kp.physicsBackInOut = function(options) {
|
||||
var friction;
|
||||
options = options || {};
|
||||
friction = options.friction|| 500;
|
||||
return _kp.bezier({ points: [{"x":0,"y":0,"cp":[{"x":0.68-(friction / 1000),"y":-0.55}]},{"x":1,"y":1,"cp":[{"x":0.265+(friction / 1000),"y":1.45}]}] });
|
||||
};
|
||||
});
|
||||
|
|
2
kute.js
2
kute.js
|
@ -5,7 +5,7 @@
|
|||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['KUTE'], factory); // AMD. Register as an anonymous module.
|
||||
define([], factory); // AMD. Register as an anonymous module.
|
||||
} else if (typeof exports == 'object') {
|
||||
module.exports = factory(); // Node, not strict CommonJS
|
||||
} else {
|
||||
|
|
25
package.json
Normal file
25
package.json
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "kute.js",
|
||||
"version": "0.9.4",
|
||||
"description": "A minimal Native Javascript animation engine with jQuery plugin.",
|
||||
"main": "kute.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/thednp/kute.js.git"
|
||||
},
|
||||
"keywords": [
|
||||
"kute.js",
|
||||
"animation",
|
||||
"animations",
|
||||
"native-javascript"
|
||||
],
|
||||
"author": "thednp",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/thednp/kute.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/thednp/kute.js#readme"
|
||||
}
|
Loading…
Reference in a new issue