Added linting by jshint

This commit is contained in:
Ramon Gebben
2015-01-18 11:59:12 +01:00
parent 203ef442d8
commit 49ab4771b9
4 changed files with 60 additions and 52 deletions

View File

@@ -2,10 +2,10 @@
var Cquence;
Cquence = function(){
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function( f ){ setTimeout( f, 1000/60 ); };
var elem = function( id ){ return document.getElementById( id ); }
// IE checking
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function( f ){ setTimeout( f, 1000/60 ); };
var elem = function( id ){ return document.getElementById( id ); };
// IE checking
var IEVERSION = getInternetExplorerVersion();
var IE8 = IEVERSION === 8;
var IEWTF = IEVERSION < 8 && IEVERSION > -1;
@@ -14,15 +14,15 @@ Cquence = function(){
if( k === 'opacity' ){
if( IE8 ){ // gemene browsers
e.style[ "-ms-filter" ] = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + Math.floor( v * 100 ) + ")";
e.style[ "filter" ] = "alpha(opacity=" + Math.floor( v * 100 ) + ")";// ;
e.style.filter = "alpha(opacity=" + Math.floor( v * 100 ) + ")";
} else { // lieve browsers
e.style[k] = v;
e.style[k] = v;
}
} else {
e.style[k] = v + "px";
}
}
};
var combine = function(){
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments
@@ -31,8 +31,8 @@ Cquence = function(){
for( var i=0; i<list.length; i++ ){
d = Math.max( list[i].d, d );
}
return {
d: d,
return {
d: d,
f: function( t ){
for( var i=0; i<list.length; i++ ){
var last = list[i];
@@ -44,11 +44,11 @@ Cquence = function(){
last.done = true;
}
}
}
}
};
}
};
var sequence = function(){
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments
@@ -57,19 +57,19 @@ Cquence = function(){
for( var i=0; i<timeline.length; i++ ){
d = d + timeline[i].d;
}
return {
d: d,
return {
d: d,
f: function( t ){
var last = null;
var total = 0;
for( var i=0; i<timeline.length; i++ ){
var last = timeline[i];
last = timeline[i];
if( total + last.d > t ){
last.f( t - total );
return;
}
last.f( t - total );
return;
}
if( !last.done ){
last.f( last.d );
last.done = true;
@@ -77,37 +77,37 @@ Cquence = function(){
total = total + last.d;
}
}
}
}
};
};
var animate = function( transform ){
var animate = function( transform ){
return function( id, dur, begin, fin ){
return {
d: dur,
return {
d: dur,
f: function( t ){
var e = elem( id );
for( var k in begin ){
var bv = begin[k]; // begin waarde
var fv = fin[k]; // finish waarde
var dx = fv - bv; // verschil (afstand)
// p is nu een waarde tussen de 0 en 1 .. en geeft aan hoe ver de animatie is
var p = transform( Math.max( t/dur, 0 ) );
// p is nu een waarde tussen de 0 en 1 .. en geeft aan hoe ver de animatie is
var p = transform( Math.max( t/dur, 0 ) );
// nieuwe waarde is de factor maal de afstand
var nv = bv + (p * dx);
var nv = bv + (p * dx);
style( e, k, nv );
}
}
}
}
}
};
};
};
// animation variants
// http://upshots.org/actionscript/jsas-understanding-easing
var linear = animate( function( p ){
return p;
var linear = animate( function( p ){
return p;
});
var easeIn = animate( function( p ){
return Math.pow( p, 5 );
@@ -116,8 +116,8 @@ Cquence = function(){
return 1 - Math.pow( 1 - p, 5 );
});
var sleep = function( d ){
return { d: d, f: function(t){} }
}
return { d: d, f: function(t){} };
};
/* from: http://stackoverflow.com/questions/10964966/detect-ie-version-in-javascript */
function getInternetExplorerVersion()
@@ -129,14 +129,14 @@ Cquence = function(){
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
if (re.exec(ua) !== null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
var timeline = [];
var start = (+new Date); // unix timestamp
var start = (+new Date()); // unix timestamp
var second = 1000;
var stop = 15 * second;
var render = null;
@@ -144,12 +144,12 @@ Cquence = function(){
// gets called recursive by request-animation-frame
var renderloop = function(){
// console.log('1. ', window.render );
var now = (+new Date) - start; // relatieve tijd vanaf begin animatie
var now = (+new Date()) - start; // relatieve tijd vanaf begin animatie
if( now < stop ) raf( renderloop ); // recursion, baby
// console.log('2. ', window.render );
if( window.render ) window.render.f( now );
}
};
return {
combine: combine,
@@ -160,8 +160,6 @@ Cquence = function(){
easeOut: easeOut,
sleep: sleep,
renderloop: renderloop
}
};
}();

View File

@@ -1,9 +1,17 @@
var gulp=require("gulp"),
uglify = require("gulp-uglify");
var gulp = require("gulp"),
uglify = require("gulp-uglify"),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish');
gulp.task('lint', function() {
return gulp.src('./Cquence.js')
.pipe(jshint())
.pipe(jshint.reporter( stylish ));
});
gulp.task("compress", function(){
gulp.src("Cquence.js").pipe( uglify() ).pipe( gulp.dest("minified") )
gulp.src("./Cquence.js").pipe( uglify() ).pipe( gulp.dest("minified") );
});
gulp.task('ci', ['compress']);
gulp.task('ci', ['lint', 'compress']);

View File

@@ -1 +1 @@
var Cquence;Cquence=function(){function n(){var n=-1;if("Microsoft Internet Explorer"==navigator.appName){var e=navigator.userAgent,t=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");null!=t.exec(e)&&(n=parseFloat(RegExp.$1))}return n}var e=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(n){setTimeout(n,1e3/60)},t=function(n){return document.getElementById(n)},r=function(n,e,t){"opacity"===e?s?(n.style["-ms-filter"]="progid:DXImageTransform.Microsoft.Alpha(Opacity="+Math.floor(100*t)+")",n.style.filter="alpha(opacity="+Math.floor(100*t)+")"):n.style[e]=t:n.style[e]=t+"px"},o=function(){for(var n=Array.prototype.slice.call(arguments,0),e=0,t=0;t<n.length;t++)e=Math.max(n[t].d,e);return{d:e,f:function(e){for(var t=0;t<n.length;t++){var r=n[t];r.d>e?r.f(e):r.done||(r.f(r.d),r.done=!0)}}}},a=function(){for(var n=Array.prototype.slice.call(arguments,0),e=0,t=0;t<n.length;t++)e+=n[t].d;return{d:e,f:function(e){for(var t=null,r=0,o=0;o<n.length;o++){var t=n[o];if(r+t.d>e)return void t.f(e-r);t.done||(t.f(t.d),t.done=!0),r+=t.d}}}},i=function(n){return function(e,o,a,i){return{d:o,f:function(u){var f=t(e);for(var c in a){var l=a[c],d=i[c],s=d-l,m=n(Math.max(u/o,0)),p=l+m*s;r(f,c,p)}}}}},u=i(function(n){return n}),f=i(function(n){return Math.pow(n,5)}),c=i(function(n){return 1-Math.pow(1-n,5)}),l=function(n){return{d:n,f:function(){}}},d=n(),s=8===d,m=+new Date,p=1e3,w=15*p,v=function(){var n=+new Date-m;w>n&&e(v),window.render&&window.render.f(n)};return{combine:o,sequence:a,linear:u,animate:i,easeIn:f,easeOut:c,sleep:l,renderloop:v}}();
var Cquence;Cquence=function(){function n(){var n=-1;if("Microsoft Internet Explorer"==navigator.appName){var e=navigator.userAgent,t=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");null!==t.exec(e)&&(n=parseFloat(RegExp.$1))}return n}var e=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(n){setTimeout(n,1e3/60)},t=function(n){return document.getElementById(n)},r=n(),o=8===r,a=function(n,e,t){"opacity"===e?o?(n.style["-ms-filter"]="progid:DXImageTransform.Microsoft.Alpha(Opacity="+Math.floor(100*t)+")",n.style.filter="alpha(opacity="+Math.floor(100*t)+")"):n.style[e]=t:n.style[e]=t+"px"},i=function(){for(var n=Array.prototype.slice.call(arguments,0),e=0,t=0;t<n.length;t++)e=Math.max(n[t].d,e);return{d:e,f:function(e){for(var t=0;t<n.length;t++){var r=n[t];r.d>e?r.f(e):r.done||(r.f(r.d),r.done=!0)}}}},u=function(){for(var n=Array.prototype.slice.call(arguments,0),e=0,t=0;t<n.length;t++)e+=n[t].d;return{d:e,f:function(e){for(var t=null,r=0,o=0;o<n.length;o++){if(t=n[o],r+t.d>e)return void t.f(e-r);t.done||(t.f(t.d),t.done=!0),r+=t.d}}}},f=function(n){return function(e,r,o,i){return{d:r,f:function(u){var f=t(e);for(var c in o){var l=o[c],d=i[c],s=d-l,m=n(Math.max(u/r,0)),p=l+m*s;a(f,c,p)}}}}},c=f(function(n){return n}),l=f(function(n){return Math.pow(n,5)}),d=f(function(n){return 1-Math.pow(1-n,5)}),s=function(n){return{d:n,f:function(){}}},m=+new Date,p=1e3,w=15*p,v=function(){var n=+new Date-m;w>n&&e(v),window.render&&window.render.f(n)};return{combine:i,sequence:u,linear:c,animate:f,easeIn:l,easeOut:d,sleep:s,renderloop:v}}();

View File

@@ -5,6 +5,8 @@
"version": "1.0.0",
"devDependencies": {
"gulp": "^3.8.10",
"gulp-uglify": "^1.0.2"
"gulp-jshint": "^1.9.0",
"gulp-uglify": "^1.0.2",
"jshint-stylish": "^1.0.0"
}
}