Repository: RamonGebben/Cquence Branch: master Commit: 365a01895449 Files: 8 Total size: 16.5 KB Directory structure: gitextract_6vgfpzsm/ ├── .gitignore ├── .travis.yml ├── Cquence.js ├── Gulpfile.js ├── README.md ├── example.html ├── minified/ │ └── Cquence.js └── package.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Ignore modules /node_modules ================================================ FILE: .travis.yml ================================================ language: node_js node_js: - 0.10 - 0.11 before_install: - npm install -g gulp script: - gulp ci ================================================ FILE: Cquence.js ================================================ var Cq; Cq = 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 IEVERSION = getInternetExplorerVersion(); var IE8 = IEVERSION === 8; var IEWTF = IEVERSION < 8 && IEVERSION > -1; var style = function( e, k, v ){ 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 ) + ")"; } else { // lieve browsers 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 var list = Array.prototype.slice.call( arguments, 0 ); var d = 0; for( var i=0; i t ){ last.f( t ); } else { if( !last.done ){ last.f( last.d ); last.done = true; } } } } }; }; var sequence = function(){ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments var timeline = Array.prototype.slice.call( arguments, 0 ); var d = 0; for( var i=0; i t ){ last.f( t - total ); return; } if( !last.done ){ last.f( last.d ); last.done = true; } total = total + last.d; } } }; }; var animate = function( transform ){ return function( id, dur, begin, fin ){ 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 ) ); // nieuwe waarde is de factor maal de afstand 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 easeIn = animate( function( p ){ return Math.pow( p, 5 ); }); var easeOut = animate( function( p ){ return 1 - Math.pow( 1 - p, 5 ); }); var sleep = function( d ){ return { d: d, f: function(t){} }; }; /* from: http://stackoverflow.com/questions/10964966/detect-ie-version-in-javascript */ function getInternetExplorerVersion() // Returns the version of Internet Explorer or a -1 // (indicating the use of another browser). { var rv = -1; // Return value assumes failure. if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) !== null) rv = parseFloat( RegExp.$1 ); } return rv; } var timeline = []; var start = (+new Date()); // unix timestamp var second = 1000; var stop = 15 * second; var render = null; // 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 if( now < stop ) raf( renderloop ); // recursion, baby // console.log('2. ', window.render ); if( window.render ) window.render.f( now ); }; return { combine: combine, sequence: sequence, linear: linear, animate: animate, easeIn: easeIn, easeOut: easeOut, sleep: sleep, renderloop: renderloop }; }(); ================================================ FILE: Gulpfile.js ================================================ 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.task('ci', ['lint', 'compress']); ================================================ FILE: README.md ================================================ # Cquence.js [![Build Status](https://travis-ci.org/RamonGebben/Cquence.svg?branch=master)](https://travis-ci.org/RamonGebben/Cquence) Cquence is a very small Javascript animation library developed for banners and advertisement. [Demo](http://ramongebben.github.io/Cquence) ## Basic usage ```javascript render = null; // Define the render object so that the renderloop knows what to render. render = Cquence.combine() // Combine fires the sequences in its body the same time render = Cquence.sequence() // Define the animations in order to create a timeline Cq.sequence( Cq.easIn( :id, :time, { :from }, { :to }), Cq.easOut( :id, :time, { :from }, { :to }), Cq.sleep( :time ) // Wait utill time is passed ) ``` ## Full example ```javascript render = Cq.combine( Cq.sequence( Cq.sleep( 100 ), Cq.linear('frame3', 10000, { left: -900 }, {left: 300 }) ), Cq.sequence( Cq.easeOut('frame1', 2000, { left: -1000 }, { left: 120 }), Cq.easeIn('frame6', 1000, { opacity: 0 }, { opacity: 1}), Cq.easeIn('frame7', 1000, { opacity: 0 }, { opacity: 1}), Cq.combine( Cq.easeIn('frame6', 1500, { opacity: 1 }, { opacity: 0}), Cq.easeIn('frame7', 1500, { opacity: 1 }, { opacity: 0}), Cq.easeIn('frame8', 1500, { opacity: 0 }, { opacity: 1}) ), Cq.sleep(1000), Cq.easeIn('frame8', 1000, { opacity: 1 }, { opacity: 0}), Cq.easeIn('frame9', 1000, { opacity: 0, left: -300 }, { opacity: 1, left: 10}), Cq.sleep(1500), Cq.sequence( Cq.combine( Cq.easeIn('frame1', 1500, { left: 120 }, { left: -620 }), Cq.easeOut('frame9', 2000, { opacity: 1, left: 10 }, { opacity: 0, left: -300 }) ), Cq.easeIn('frame2', 1000, { opacity: 0 },{ opacity: 0 }), Cq.easeOut('frame10', 1000, { bottom: -260 }, { bottom: 0 }) ) ) ); // launch the animation Cq.renderloop(); ``` Then your HMTL should look something like this: ```html

Hey there,

People call me

RamonGebben

And this is an awesome lib

Download
``` ## Development We use Gulp for build tasks. To minify/uglify for production use: ```bash gulp compress ``` ### Linting We use jshint for linting. Run the gulp task to check. ```bash gulp lint ``` ## Licence Copyright (c) 2015 RamonGebben Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: example.html ================================================ Cquence example

Hey there,

People call me

Ramon Gebben

And this is an awesome lib

Download

================================================ FILE: minified/Cquence.js ================================================ var Cq;Cq=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;te?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;te)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}}(); ================================================ FILE: package.json ================================================ { "name": "Cquence", "description": "A very tiny Javascript animation library", "author": "Ramon Gebben ", "version": "1.0.0", "devDependencies": { "gulp": "^3.8.10", "gulp-jshint": "^1.9.0", "gulp-uglify": "^1.0.2", "jshint-stylish": "^1.0.0" } }