This commit is contained in:
thednp 2016-03-16 15:42:03 +02:00
parent 05bad2c336
commit 320cc59b05
14 changed files with 1367 additions and 1599 deletions

View file

@ -9,7 +9,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="KUTE.js is a minimal Javascript animation engine">
<meta name="description" content="About KUTE.js performance, project, code and a short glossary with most used terminology in Javascript animation.">
<meta name="keywords" content="kute,kute.js,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.png"> <!-- TO DO -->
@ -24,7 +24,9 @@
<!-- Ion Icons -->
<link type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
<!-- Polyfill -->
<script src="./assets/js/minifill.js"> </script>
</head>
<body>
@ -36,9 +38,30 @@
<div class="content-wrap">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<ul class="nav">
<li><a href="features.html">Features</a></li>
<li><a href="examples.html">Examples</a></li>
<li><a href="api.html">API</a></li>
<li class="btn-group"><a href="#" data-function="toggle">Features <span class="caret"></span></a>
<ul class="subnav">
<li><a href="features.html">Feature Overview</a></li>
<li><a href="properties.html">Supported Properties</a></li>
</ul>
</li>
<li class="btn-group">
<a href="#" data-function="toggle">Examples <span class="caret"></span></a>
<ul class="subnav">
<li><a href="examples.html">Core Engine</a></li>
<li><a href="css.html">CSS Plugin </a></li>
<li><a href="svg.html">SVG Plugin </a></li>
<li><a href="attr.html">Attributes Plugin </a></li>
</ul>
</li>
<li class="btn-group">
<a href="#" data-function="toggle">API <span class="caret"></span></a>
<ul class="subnav">
<li><a href="start.html">Getting Started</a></li>
<li><a href="api.html">Public Methods</a></li>
<li><a href="easing.html">Easing Functions</a></li>
<li><a href="extend.html">Extend Guide</a></li>
</ul>
</li>
<li class="active"><a href="about.html">About</a></li>
</ul>
</div>
@ -47,7 +70,7 @@
<div class="content-wrap">
<h2>Did you know?</h2>
<p><strong>Tween</strong> is a term used by animators and software engineers to define the numeric start, end and the <a href="https://en.wikipedia.org/wiki/Inbetweening" target="_blank"><em>inbetween</em></a> values used in digital animation, while the digital animation uses these tween values on a given frequency (interval) or scaled by hardware capability (monitors refresh rate, GPU frames per second, etc). The term was introduced to the world of web development by early Javascrpt libraries and later used in dedicated animation libraries such as <a href="https://greensock.com" target="_blank">GSAP</a>, <a href="http://dynamicsjs.com" target="_blank">Dynamics</a>, <a href="http://julian.com/research/velocity/" target="_blank">Velocity</a>, <a href="https://jeremyckahn.github.io/shifty/" target="_blank">Shifty</a>, our own <strong>KUTE.js</strong> here and many others.</p>
<p><strong>Tween</strong> is a term used by animators and software engineers to define the numeric start, end and the <a href="https://en.wikipedia.org/wiki/Inbetweening" target="_blank"><em>inbetween</em></a> values used in digital animation, while the digital animation uses these tween values on a given frequency (interval) or scaled by hardware capability (monitors refresh rate, GPU frames per second, etc). The term was introduced to the world of web development by early Javascrpt libraries and later used in dedicated animation libraries such as <a href="https://greensock.com" target="_blank">GSAP</a>, <a href="http://dynamicsjs.com" target="_blank">Dynamics</a>, <a href="http://julian.com/research/velocity/" target="_blank">Velocity</a>, <a href="https://jeremyckahn.github.io/shifty/" target="_blank">Shifty</a>, our own <strong>KUTE.js</strong> here and many others. When used as a verb, it actually reffers to the interpolation of the values.</p>
<p><strong>Tween Object</strong> is a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" target="_blank"><em>Javascript Object</em></a> that stores temporarily or for a given time a set of variables such as tween values, HTML elements to animate, CSS properties and other tween options to be used for animation. To improve performance on repetitive animations, this object can be cached and reused whenever needed. In Javascript animation, the term <strong>tween</strong> actually refers to the <strong>tween object</strong>.</p>
<p><strong>polyfill</strong> is a term introduced by Remy Sharp back in 2009 as "a piece of code (or plugin) that provides the technology that you, the developer, expect the browser to provide <em>natively</em>". Basically a polyfill covers what legacy browsers don't support or in other cases corrects the implemented behavior that is different from the standards. <a href="https://remysharp.com/2010/10/08/what-is-a-polyfill" target="_blank">More details</a>.</p>
<p><strong>requestAnimationFrame</strong> is a <a href="https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame" target="_blank"><em>Javascript method</em></a> developed to enable hardware acceleration animations for the web today. In Javascript, the <code>window.requestAnimationFrame(callback);</code> method is all we need to setup animations really for all the above mentioned animation engines. Some developers built a <a href="http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/">polyfil</a> to cover the legacy browsers chaos.</p>
@ -71,7 +94,6 @@
<h3>Function Nesting</h3>
<p>This could be one of the most important factors that influence performance, because we neglect this fact most of the time and changing the scope of an animation engine is important to look after. A quick example would be when we create tween objects on events such as <code>click</code>, <code>scroll</code> or <code>resize</code>, we basically set a totally different scope for the animation and we fill the memory with large chunks of trash/jank, especially on events like <code>resize</code>.</p>
<p>A better way to handle this is to create the tween objects outside the event handlers and only start the animation with these handlers when certain conditions are met. EG: <code>if (window.clientWidth > 760) { myTween.start() }</code>. Also keep in mind that this approach will eliminate any possible syncronization issues, but creating many animations is a huge temptation and this will create lots of problems for the old browsers, so keep the function nesting to as minimal as possible as a general rule.</p>
<p>In all animation engines, GSAP is the only one that exports all it's methods and computed values to the global scope to help diminish the time to access/execute, but it will find soon that it's no longer the case because modern browsers continuously improve their Javascript engines to a point where the access speed is the same, blazing fast, no matter how deep Javascript animation scope goes.</p>
<h3>Translate and Position</h3>
<p>While the code execution is the <strong>fastest</strong> for the <em>layout modifiers</em> or what we call <em>box-model</em>, say the <code>position</code> based properties set such as <code>left</code> or <code>top</code>, they may force the entire page layout to change and thus requires the browser to repaint all elements affected by animated repositioning and their parent elements. On the other side <code>translate</code> doesn't trigger a repaint but involves more complex operations such as object traversing, string concatenation or check for certain conditions to be met. All of this is because <code>translate</code> is part of <code>transform</code> CSS3 property that has to stack in a single line many more properties such as <code>rotate</code>, <code>skew</code> and <code>scale</code>. <a href="http://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/" target="_blank">An article</a> by Paul Irish explains more about differences in performance between position and translation.</p>
@ -134,7 +156,7 @@
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2007 - 2015 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
<p>&copy; 2007 - 2016 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
</div>
</footer>
@ -145,6 +167,8 @@
<!-- JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/kute.js"></script> <!-- KUTE.js core -->
<script src="./assets/js/scripts.js"></script> <!-- some stuff -->
</body>
</html>

View file

@ -9,7 +9,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="KUTE.js is a minimal Javascript animation engine">
<meta name="description" content="A detailed API documentation on KUTE.js main methods, options and easing functions.">
<meta name="keywords" content="kute,kute.js,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.png"> <!-- TO DO -->
@ -28,6 +28,9 @@
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<!-- Polyfill -->
<script src="./assets/js/minifill.js"> </script>
<!-- legacy browsers support via polyfill
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,getComputedStyle|gated"> </script> -->
<!--[if IE]>
@ -46,44 +49,38 @@
<div class="content-wrap">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<ul class="nav">
<li><a href="features.html">Features</a></li>
<li><a href="examples.html">Examples</a></li>
<li class="active"><a href="api.html">API</a></li>
<li class="btn-group"><a href="#" data-function="toggle">Features <span class="caret"></span></a>
<ul class="subnav">
<li><a href="features.html">Feature Overview</a></li>
<li><a href="properties.html">Supported Properties</a></li>
</ul>
</li>
<li class="btn-group">
<a href="#" data-function="toggle">Examples <span class="caret"></span></a>
<ul class="subnav">
<li><a href="examples.html">Core Engine</a></li>
<li><a href="css.html">CSS Plugin </a></li>
<li><a href="svg.html">SVG Plugin </a></li>
<li><a href="attr.html">Attributes Plugin </a></li>
</ul>
</li>
<li class="btn-group active">
<a href="#" data-function="toggle">API <span class="caret"></span></a>
<ul class="subnav">
<li><a href="start.html">Getting Started</a></li>
<li class="active"><a href="api.html">Public Methods</a></li>
<li><a href="easing.html">Easing Functions</a></li>
<li><a href="extend.html">Extend Guide</a></li>
</ul>
</li>
<li><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div class="content-wrap">
<h2>Getting Started</h2>
<p>Welcome to KUTE.js API documentation, here we're going to talk about how to download, install, use, control and set up cross browser animations, in great detailed. KUTE.js can be found on <a href="http://www.jsdelivr.com/#!kute.js" target="_blank">CDN</a> and also npm and Bower repositories with all it's features and tools.</p>
<h3>Bower and NPM</h3>
<p>You can install KUTE.js package by using either Bower or NPM.</p>
<pre><code class="language-clike">$ npm install --save kute.js
# Or
$ bower install --save kute.js
</code></pre>
<h3>Websites</h3>
<p>In your website add the following code, the best would be to put it at the end of your <code>body</code> tag:</p>
<pre><code class="language-markup">&lt;script src="https://cdn.jsdelivr.net/kute.js/1.0.1/kute.min.js">&lt;/script> &lt;!-- core KUTE.js --></code></pre>
<p>Also you can include the tools that you need for your project:</p>
<pre><code class="language-markup">&lt;script src="https://cdn.jsdelivr.net/kute.js/1.0.1/kute-jquery.min.js">&lt;/script> &lt;!-- jQuery Plugin -->
&lt;script src="https://cdn.jsdelivr.net/kute.js/1.0.1/kute-easing.min.js">&lt;/script> &lt;!-- Bezier Easing Functions -->
&lt;script src="https://cdn.jsdelivr.net/kute.js/1.0.1/kute-physics.min.js">&lt;/script> &lt;!-- Physics Easing Functions -->
</code></pre>
<p>Your awesome animation coding would follow after these script links.</p>
<h3>Targeting Legacy Browsers</h3>
<p>You need to know when users' browser is a legacy one in order to use KUTE.js only for what browsers actually support. A quick note here: IE8 doesn't support any <code>transform</code> property or <code>RGBA</code> colors while IE9 can only do 2D transformations. Check the <a href="http://caniuse.com/#feat=transforms2d" target="_blank">2D transforms</a> and the <a href="http://caniuse.com/#feat=transforms3d" target="_blank">3D transforms</a> browser support list for more information.</p>
<p>Don't use <a href="https://modernizr.com/" target="_blank">Modernizr</a>, the best thing you can actually do is to use the Microsoft's synthax for it's own legacy browsers, and <a target="_blank" href="http://www.paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">here is the full refference</a> on that. For other legacy browsers there is a ton of ways to target them, quite efficiently I would say: <a href="http://browserhacks.com/" target="_blank">there you go</a>.</p>
</div>
<div class="content-wrap">
<h2>Main Methods</h2>
<h2>Public Methods</h2>
<p>These methods allow you to create <strong>tween objects</strong> and collections of <strong>tween objects</strong>; as we know, a tween object is essentially like an animation setup for a given HTML element, defining CSS properties, animation duration, repeat or other options. The methods have different uses and performance scores while making it easy to work with.</p>
<h3>Single Tween Object</h3>
@ -111,12 +108,6 @@ var myDivsTweens = KUTE.allTo( myDivs, {opacity:1}, {offset: 200, duration: 5
<p><kbd>.allFromTo()</kbd> method is also a method to animate a collection of elements and it uses the <code>.fromTo()</code> method. Quick example:</p>
<pre><code class="language-javascript">KUTE.allFromTo( myDivs, {opacity:1}, {opacity:0}, {offset: 200, duration: 500} ).start()</code></pre>
<p>Considering that the selector matches two DIV elements, the value for the above variable <code>myDivsTweens</code> is an object that only stores the two tweens, one for each element found:</p>
<pre><code class="language-javascript">
myDivsTweens = { // console.log(myDivsTweens);
tweens = [ Tween, Tween ] console.log(myDivsTweens.tweens);
}
</code></pre>
<p>As you can see the above code, these methods have a specific tween option called <code>offset</code> that allows you to set a delay in miliseconds between the starting time of each tween animation. Most tween control methods apply to both methods, except for the <code>.chain()</code> method. In order to chain another tween to one of the <code>myDivsTweens</code> objects, we would need to access it from the array, but let's leave that for later.</p>
</div>
@ -211,19 +202,25 @@ tween.chain(tween1,tween2);
<p>Another thing we talked before is the ability to chain to one of the tween object within the array built with <code>.allTo()</code> or <code>.allFromTo()</code> methods.</p>
<pre><code class="language-javascript">// chain to a tween from collection
var tweensCollection = KUTE.allTo('.a-class-for-multiple-elements', {opacity: 1}, {opacity: 0}, {duration: 500});
var tweensCollection = KUTE.allTo('.a-class-for-multiple-elements', {opacity: 1}, {opacity: 0});
// considering the collection has 5 tweens,
// the array is right here tweensCollection.tweens, so
// let's grab the second and chain another tween to it
tweensCollection.tweens[1].chain(tween2);
</code></pre>
<p>Also we can chain the tweens created with <code>.allTo()</code> and <code>.allFromTo()</code> methods like this:</p>
<pre><code class="language-javascript">// chain a collection of tweens to another tween
var tweensCollection2 = KUTE.allTo('.a-class-for-multiple-elements', {opacity: 1}, {opacity: 0});
// the array is right here tweensCollection2.tweens
// we can pass it in the chain of another tween
tween2.chain(tweensCollection2.tweens);
</code></pre>
</div>
<div class="content-wrap">
<h2>Tween Options</h2>
<h2 id="tweenoptions">Tween Options</h2>
<h3>Common Options</h3>
<p>These options affect all types of tweens, no matter the properties used or context.</p>
<p><kbd>duration: 500</kbd> option allows you to set the animation duration in miliseconds. The default value is <strong>700</strong>.</p>
@ -242,6 +239,15 @@ tweensCollection.tweens[1].chain(tween2);
<p><kbd>parentPerspectiveOrigin: "50% 50%"</kbd> option allows you to set a <code>perspectiveOrigin</code> for the parent of the HTML element subject to the transform animation. Also like the above similar options, this options only accepts valid CSS values.</p>
<p><kbd>transformOrigin: "50% 50%"</kbd> option allows you to set a <code>transformOrigin</code> for the HTML element subject to the transform animation. Also this options only accepts valid CSS values.</p>
<h3>SVG Options</h3>
<p>These options only affect animation of the <code>path</code> tween property, or what you know as SVG morphing.</p>
<p><kbd>showMorphInfo: true</kbd> when <code>true</code> the script will log valuable information about the morph in order to help you maximize both performance and visuals of the morph.</p>
<p><kbd>morphPrecision: Number</kbd> option allows you to set the sampling size of the morph. The lesser value the better visual but the more power consumption.</p>
<p><kbd>morphIndex: Number</kbd> option allows you to rotate the second/end path in a way that the points travel the least possible distance during morph, and as an effect the morph animation feel more "natural".</p>
<p><kbd>reverseFirstPath: true</kbd> when is <code>true</code> this option allows you to reverse the draw direction of the FIRST shape.</p>
<p><kbd>reverseSecondPath: true</kbd> when is <code>true</code> this option allows you to reverse the draw direction of the SECOND shape.</p>
<h3>Callback Options</h3>
<p>These options also affect all types of tweens, and are bound by the tween control options and the internal update functions.</p>
<p><kbd>start: function</kbd> option allows you to set a function to run once tween animation starts.</p>
@ -263,92 +269,7 @@ KUTE.fromTo(div,{left:150},{left:0},{complete: callback}).start();
<p><kbd>keepHex: true</kbd> option allows you to always use <code>HEX</code> color format, even if you have used <code>RGB</code> or <code>RGBA</code>. This option is useful when tweening color properties on legacy browsers, however modern browsers may ignore this option for performance reasons.</p>
</div>
<div class="content-wrap">
<h2>Easing Functions</h2>
<p>The easing functions generally make animations closer to reality and completely eliminate the boring factor for a given context. The most simple example to understand what they do, think of gravity. Dropping an object from a given height, will start moving to the ground with accelerated speed. If the object has some sort of bounciness like a ball, it will jump back up and up again, till the gravity will eventually stick the object to the ground.</p>
<p>What scientists observed and put in theory houndreads of years ago, later the pioneers of scripting started to implement the laws of physics into digital animation and came up with this notion of easing to describe the progression of movement. If you care to dig into the concept, <a href="http://upshots.org/actionscript/jsas-understanding-easing" targt="_blank">here's an excellent resource</a> some developers recommend. I would also recommend <a href="https://medium.com/@sureshvselvaraj/animation-principles-in-ui-design-understanding-easing-bea05243fe3" target="_blank">this one</a> too.</p>
<h3>Core Functions</h3>
<p>Modern browsers that support <code>transition</code> can also make use of some generic easing functions via the CSS3 <code>transition-timing-function:ease-out</code> property, but in Javascript animation, we need some special functions. The popular <a href="robertpenner.com/easing/" target="_blank">Robert Penner's easing functions</a> set is one of them, and is the default set included with KUTE.js because it's the fastest set I know in terms of performance. Some functions may lack a bit of accuracy but they cover the most animation needs. Generally the easing functions' names are built with keywords that describe the type of easing, like <em>circular</em> or <em>exponential</em>, and also the type of progression <em>in</em> and/or <em>out</em>.</p>
<p>To use them, simply set a tween option like so <code>easing: KUTE.Easing.easingSinusoidalInOut</code> or simply <code>easing: 'easingSinusoidalInOut'</code>.</p>
<p><kbd>linear</kbd> is the default easing function and just as it sounds, it means that the animation has no acceleration or deceleration over time. While this one is basically boring, it's the fastest in all, and it's very useful when animating opacity or colors because we cannot really distinguish changes in speed for such cases, but mostly for movement.</p>
<p><kbd>curve</kbd> based functions are the next set of easings we are going to tak about. They are basically the same, the only difference is the number of multipliers applied (better think of it like the more weight an object has, the more acceleration):</p>
<ul>
<li><strong>Sinusoidal</strong> - multiplier of 1 (super light object, like a feather)</li>
<li><strong>Quadratic</strong> - multiplier of 2</li>
<li><strong>Cubic</strong> - multiplier of 3</li>
<li><strong>Quartic</strong> - multiplier of 4</li>
<li><strong>Quintic</strong> - multiplier of 5</li>
<li><strong>Circular</strong> - multiplier of 6</li>
<li><strong>Exponential</strong> - multiplier of 10 (super heavy object, like a truck)</li>
</ul>
<p>The In / Out explained:</p>
<ul>
<li><strong>In</strong> - means that the animation starts with very very low speed and gains acceleration over time, but when it reaches the maximum speed, animation stops. These functions are: <kbd>easingSinusoidalIn</kbd>, <kbd>easingQuadraticIn</kbd>,<kbd>easingCubicIn</kbd>, <kbd>easingQuarticIn</kbd>, <kbd>easingQuinticIn</kbd>, <kbd>easingCircularIn</kbd> and <kbd>easingExponentialIn</kbd>.</li>
<li><strong>Out</strong> - means that the animation starts with maximum speed and constantly decelerates over time until the animation stops. These functions are: <kbd>easingSinusoidalOut</kbd>, <kbd>easingQuadraticOut</kbd>, <kbd>easingCubicOut</kbd>, <kbd>easingQuarticOut</kbd>, <kbd>easingQuinticOut</kbd>, <kbd>easingCircularOut</kbd> and <kbd>easingExponentialOut</kbd>.</li>
<li><strong>InOut</strong> - means that the animation accelerates halfway until it reaches the maximum speed, then begins to decelerate until it stops. These functions are: <kbd>easingSinusoidalInOut</kbd>, <kbd>easingQuadraticInOut</kbd>, <kbd>easingCubicInOut</kbd>, <kbd>easingQuarticInOut</kbd>, <kbd>easingQuinticInOut</kbd>, <kbd>easingCircularInOut</kbd> and <kbd>easingExponentialInOut</kbd>.</li>
</ul>
<p><kbd>back</kbd> easing functions describe more complex animations (I would call them <em>reverse gravity</em> easings). They also come with <em>in</em> and/or <em>out</em> types of progression. </p>
<ul>
<li><kbd>easingBackIn</kbd> would be best described when you throw an object into the air with a small amount of physical power, it will move up decelerating until it stops, then will move to the grund with acceleration.</li>
<li><kbd>easingBackOut</kbd> would be best described as the previous function, but viewed in reverse mode.</li>
<li><kbd>easingBackInOut</kbd> is a combination of the other two.</li>
</ul>
<p><kbd>elasticity</kbd> easing functions describe the kind of animation where the object is elastic. With <em>in</em> and/or <em>out</em> as well. </p>
<ul>
<li><kbd>easingElasticOut</kbd> would be best described by the movement of a guitar string after being pinched, moving up and down, with decreasing frequency, until it stops.</li>
<li><kbd>easingElasticIn</kbd> would be best described as the above function but viewed in reverse mode.</li>
<li><kbd>easingElasticInOut</kbd> is simply a combination of the other two.</li>
</ul>
<p><kbd>gravity</kbd> based easing functions describe the kind of animation where the object has a certain degree of bounciness, like a ball. With <em>in</em> and/or <em>out</em> as well.</p>
<ul>
<li><kbd>easingBounceOut</kbd> looks just like a ball falling on the ground and start boucing up and down with decreasing frequency untill it stops.</li>
<li><kbd>easingBounceIn</kbd> looks like the previous viewed in reverse mode</li>
<li><kbd>easingBounceInOut</kbd> is a combination of the other two.</li>
</ul>
<h3>Cubic Bezier Functions</h3>
<p>While modern browsers support CSS3 <code>transition</code> with <code>transition-timing-function: cubic-bezier(0.1,0.5,0.8,0.5)</code>, in Javascript animation we need some specific functions to cover that kind of functionality. As mentioned in the <a href="features.html">features page</a>, we are using a modified version of the <a href="https://github.com/gre/bezier-easing" target="_blank">cubic-bezier</a> by Gaëtan Renaudeau. I believe this must be most accurate easing functions set.</p>
<p>You can use them either with <code>easing: KUTE.Ease.bezier(mX1, mY1, mX2, mY2)</code> or <code>easing: 'bezier(mX1, mY1, mX2, mY2)'</code>, where mX1, mY1, mX2, mY2 are <em>Float</em> values from 0 to 1. You can find the right values you need <a href="http://cubic-bezier.com/" target="_blank">right here</a>.</p>
<p>There is also a pack of presets, and the keywords look very similar if you have used jQuery.Easing plugin before:</p>
<ul>
<li>Equivalents of the browser's <strong>generic</strong> timing functions: <kbd>easeIn</kbd>, <kbd>easeOut</kbd> and <kbd>easeInOut</kbd></li>
<li><strong>Sinusoidal</strong> timing functions: <kbd>easeInSine</kbd>, <kbd>easeOutSine</kbd> and <kbd>easeInOutSine</kbd></li>
<li><strong>Quadratic</strong> timing functions: <kbd>easeInQuad</kbd>, <kbd>easeOutQuad</kbd> and <kbd>easeInOutQuad</kbd></li>
<li><strong>Cubic</strong> timing functions: <kbd>easeInCubic</kbd>, <kbd>easeOutCubic</kbd> and <kbd>easeInOutCubic</kbd></li>
<li><strong>Quartic</strong> timing functions: <kbd>easeInQuart</kbd>, <kbd>easeInQuart</kbd> and <kbd>easeInOutQuart</kbd></li>
<li><strong>Quintic</strong> timing functions: <kbd>easeInQuint</kbd>, <kbd>easeOutQuint</kbd> and <kbd>easeInOutQuint</kbd></li>
<li><strong>Exponential</strong> timing functions: <kbd>easeInExpo</kbd>, <kbd>easeOutExpo</kbd> and <kbd>easeInOutExpo</kbd></li>
<li><strong>Back</strong> timing functions: <kbd>easeInBack</kbd>, <kbd>easeOutBack</kbd> and <kbd>easeInOutBack</kbd></li>
<li><strong>Special slow motion</strong> timing functions look <a href="http://cubic-bezier.com/#0,.58,1,.3" target="_blank">like this</a>: <kbd>slowMo</kbd>, <kbd>slowMo1</kbd> and <kbd>slowMo2</kbd></li>
</ul>
<h3>Physics Based Functions</h3>
<p>KUTE.js also packs the <a href="http://dynamicsjs.com/" target="_blank">dynamics physics</a> easing functions by Michael Villar and I have to say these functions are amazing in terms of flexibility, control and performance. They allow you to control the friction, bounciness, frequency, elasticity, or multiple bezier points for your animations.</p>
<p>You can use them either with regular Javascript invocation as shown below and configure / visualize them on the <a href="http://dynamicsjs.com/" target="_blank">author's website</a>, while you can also use the pack of presets featuring mostly <kbd>bezier</kbd> based functions. Ok now, let's get to it:</p>
<ul>
<li><strong>spring</strong> function is basically an <strong>elastic</strong> type of easing that allows you to set <code>frequency:1-1000</code>, <code>friction:1-1000</code>, <code>anticipationSize:0-1000</code> (a kind of delay in miliseconds) and <code>anticipationStrength:0-1000</code> (a kind of a new curve to add to the function while waiting the anticipationSize). Usage: <code>easing: KUTE.Physics.spring({friction:100,frequency:600})</code>.</li>
<li><strong>bounce</strong> function is also an <strong>elastic</strong> easing function, but it works different than Robert Penner's version that's basically a <kbd>gravity</kbd> based function. This one here will always come back to the starting values. This function allows you to set <code>frequency:0-1000</code> and <code>friction:0-1000</code>. Usage: <code>easing: KUTE.Physics.bounce({friction:100,frequency:600})</code>.</li>
<li><strong>gravity</strong> function does what a ball dropped on the ground does, bounces until it stops. It allows you to set: <code>elasticity:1-1000</code> and <code>bounciness:0-1000</code>. Usage: <code>easing: KUTE.Physics.gravity({elasticity:100,bounciness:600})</code>.</li>
<li><strong>forceWithGravity</strong> function acts just like <code>gravity</code> except that the ball instead of being dropped it's thrown into the air. This allows you to set same options: <code>elasticity:1-1000</code> and <code>bounciness:0-1000</code>. Usage: <code>easing: KUTE.Physics.forceWithGravity({elasticity:100,bounciness:600})</code>.</li>
<li><strong>bezier</strong> easing function is a bit more complicated as it allows you to set multiple points of bezier curves. Usage: <code>easing: KUTE.Physics.bezier({points:POINTS_ARRAY_COMES HERE})</code>, again use the author's website, edit the bezier curve as you wish and copy paste the points array into this function. Here's how a basic <em>easeIn</em> looks like:
<pre><code class="language-javascript">// sample bezier based easing setting
easing: KUTE.Physics.bezier({points: [{"x":0,"y":0,"cp":[{"x":0.483,"y":0.445}]},{"x":1,"y":1,"cp":[{"x":0.009,"y":0.997}]}] })
</code></pre>
</li>
</ul>
<p>The presets can be used both as a string <code>easing:'physicsIn'</code> or <code>easing:KUTE.Physics.physicsIn(friction:200)</code>. The list is:</p>
<ul>
<li><strong>curves</strong>: <kbd>physicsIn</kbd>, <kbd>physicsOut</kbd>, <kbd>physicsInOut</kbd> can do all multipliers (from sinusoidal to exponential) via the <code>friction</code> option;</li>
<li><strong>back</strong>: <kbd>physicsBackIn</kbd>, <kbd>physicsBackOut</kbd>, <kbd>physicsBackInOut</kbd> also benefit from the <code>friction</code> option.</li>
</ul>
<div class="content-wrap">
<ul id="share" class="nav">
<li>Share </li>
@ -363,7 +284,7 @@ easing: KUTE.Physics.bezier({points: [{"x":0,"y":0,"cp":[{"x":0.483,"y":0.445}]}
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2007 - 2015 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
<p>&copy; 2007 - 2016 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
</div>
</footer>
@ -380,7 +301,7 @@ easing: KUTE.Physics.bezier({points: [{"x":0,"y":0,"cp":[{"x":0.483,"y":0.445}]}
<!--<script src="http://cdn.jsdelivr.net/kute.js/1.0.0/kute.full.min.js"></script> KUTE CDN -->
<script src="./src/kute.js"></script> <!-- some stuff -->
<script src="./src/kute.js"></script> <!-- KUTE.js core -->
<script src="./assets/js/scripts.js"></script> <!-- some stuff -->
</body>
</html>

View file

@ -9,7 +9,7 @@ body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 2; /* ~25px */
color: #ddd;
color: #ccc;
background-color: #999;
position: relative
@ -56,11 +56,13 @@ footer p {margin: 0 0 10px}
.navbar-wrapper h1 span { font-size: 24px; color: #555; letter-spacing: -1px; }
.navbar-wrapper h1.active span { color: #ffd626 }
.navbar-wrapper .nav { float: left; padding: 0 0 18px; margin: 0; border-bottom: 1px solid #555 }
.nav li { float: left; display: block; line-height: 25px; list-style: none }
.nav li:not(:last-child) { margin-right: 12px }
.nav > li { float: left; display: block; line-height: 25px; list-style: none }
.nav > li:not(:last-child) { margin-right: 12px }
.ie8 .nav li { margin-right: 12px }
.nav li.active a { color: #ffd626 }
.ie8 .nav li li { margin-right: 0 }
.nav li.active > a { color: #ffd626 }
.nav li a { color: #ccc }
.nav li a:hover, .nav li a:focus { text-decoration: none }
@media (max-width: 768px){
.navbar-wrapper .content-wrap { height: 94px}
.navbar-wrapper h1 {border: 0}
@ -91,6 +93,13 @@ background: #222;
/* easy hack to improve box model properties performance on modern browsers only ofc */
transform: translate3d(0px,0px,0px); -webkit-transform: translate3d(0px,0px,0px);
}
.example-box-model {
font-size: 40px; text-align:center; font-weight: bold;
float: left; position:relative;
border-radius: 5px; margin: 0 20px 20px 0;
}
.easing-example {float: none; font-size: 24px; width: 320px}
.example-buttons {position: absolute; top: 18px; right:0}
/* text properties example */
@ -109,7 +118,7 @@ h1.example-item span {
.ie8 h1.example-item span,
.ie8 .btn.example-item {filter: alpha(opacity=0)}
/*.ie8 .btn.example-item * {filter: inherit}*/
.ie8 .btn.example-item * {filter: inherit}
/* UTILITY STYLES
-------------------------------------------------- */
@ -171,7 +180,7 @@ div { background-color: rgba(0,0,0,0.2) }*/
/* TYPO STYLES
-------------------------------------------------- */
p, ul, ol { margin: 0 0 20px }
h1, h2, h3, h4, strong {color: #ffd626}
h1, h2, h3, h4, strong {color: #fff}
h1 { font-size: 54px; letter-spacing:-3px; line-height: 0.92; font-weight: normal; }
h2 { font-size: 46px; letter-spacing:-2px; line-height: 1.08; font-weight: normal; margin: 1.08em 0 0.27em; width: 100%; }
h3 { font-size: 24px; letter-spacing:0px; line-height: 0.96; font-weight: normal; }
@ -258,24 +267,26 @@ hr {
}
/* share */
#share {position: fixed; top: 20px;right: 20px;}
#share {position: fixed; top: 0px; right: 0px; padding:10px 20px; background: #2e2e2e;}
#share .icon {font-size: 24px; line-height: 1}
/* buttons */
.btn { padding: 12px 15px; color:#fff; border:0; background-color: #999; line-height: 44px; }
.bg-gray { color:#fff; background-color: #555; }
.bg-gray { color:#fff; background-color: #555; fill: #555 }
.btn.active { background-color: #2196F3 }
.btn:hover, .btn:active, .btn:focus { color: #fff; text-decoration: none; background-color: #777}
.btn-olive, .bg-olive {background-color: #9C27B0; color: #fff} .btn-olive:hover, .btn-olive:active, .btn-olive:focus { background-color: #673AB7 }
.btn-indigo, .bg-indigo { background-color: #673AB7; color: #fff} .btn-indigo:hover, .btn-indigo:active, .btn-indigo:focus { background-color: #ffd626; color:#000 }
.btn-green, .bg-green { background-color: #4CAF50; color: #fff} .btn-green:hover, .btn-green:active, .btn-green:focus { background-color: #9C27B0 }
.btn-red, .bg-red { background-color: #e91b1f; color: #fff} .btn-red:hover, .btn-red:active, .btn-red:focus { background-color: #4CAF50 }
.btn-yellow, .bg-yellow { background-color: #ffd626; color:#000} .btn-yellow:hover, .btn-yellow:active, .btn-yellow:focus { background-color: #4CAF50; color: #000 }
.btn-blue, .bg-blue { background-color: #2196F3; color: #fff} .btn-blue:hover, .btn-blue:active, .btn-blue:focus { background-color: #e91b1f }
.btn-pink, .bg-pink { background-color: #E91E63; color: #fff} .btn-pink:hover, .btn-pink:active, .btn-pink:focus { background-color: #2196F3 }
.btn-orange, .bg-orange { background-color: #FF5722; color: #fff} .btn-orange:hover, .btn-orange:active, .btn-orange:focus { background-color: #4CAF50 }
.btn-lime, .bg-lime { background-color: #CDDC39; color: #000} .btn-lime:hover, .btn-lime:active, .btn-lime:focus { background-color: #e91b1f }
.btn-teal, .bg-teal { background-color: #009688; color: #fff} .btn-teal:hover, .btn-teal:active, .btn-teal:focus { background-color: #9C27B0 }
.btn-olive, .bg-olive {background-color: #9C27B0; color: #fff; fill: #9C27B0} .btn-olive:hover, .btn-olive:active, .btn-olive:focus { background-color: #673AB7 }
.btn-indigo, .bg-indigo { background-color: #673AB7; color: #fff; fill: #673AB7} .btn-indigo:hover, .btn-indigo:active, .btn-indigo:focus { background-color: #ffd626; color:#000 }
.btn-green, .bg-green { background-color: #4CAF50; color: #fff; fill: #4CAF50} .btn-green:hover, .btn-green:active, .btn-green:focus { background-color: #9C27B0 }
.btn-red, .bg-red { background-color: #e91b1f; color: #fff; fill: #e91b1f} .btn-red:hover, .btn-red:active, .btn-red:focus { background-color: #4CAF50 }
.btn-yellow, .bg-yellow { background-color: #ffd626; color:#000; fill: #ffd626} .btn-yellow:hover, .btn-yellow:active, .btn-yellow:focus { background-color: #4CAF50; color: #000 }
.btn-blue, .bg-blue { background-color: #2196F3; color: #fff; fill: #2196F3} .btn-blue:hover, .btn-blue:active, .btn-blue:focus { background-color: #e91b1f }
.btn-pink, .bg-pink { background-color: #E91E63; color: #fff; fill: #E91E63} .btn-pink:hover, .btn-pink:active, .btn-pink:focus { background-color: #2196F3 }
.btn-orange, .bg-orange { background-color: #FF5722; color: #fff; fill: #FF5722} .btn-orange:hover, .btn-orange:active, .btn-orange:focus { background-color: #4CAF50 }
.btn-lime, .bg-lime { background-color: #CDDC39; color: #000; fill: #CDDC39} .btn-lime:hover, .btn-lime:active, .btn-lime:focus { background-color: #e91b1f }
.btn-teal, .bg-teal { background-color: #009688; color: #fff; fill: #009688} .btn-teal:hover, .btn-teal:active, .btn-teal:focus { background-color: #9C27B0 }
.bg-light {background-color: #fff; color: #777; fill: #fff}
.icon-large { font-size: 78px; line-height: 0.64; text-shadow: 2px 2px 0 #FFF,3px 3px 0px #ccc;}
.icon-large.fa-cogs:before { color: #4CAF50 }
@ -290,6 +301,54 @@ hr {
.btn span.right { margin: 0 0 0 10px }
.btn span.left { margin: 0 10px 0 0 }
.btn-group { position: relative; display: inline-block }
.btn-group ul {
background: #555; max-height: 300px; width: 200px;
position: absolute; bottom: -9999em; left: 0; list-style: none;
overflow: auto; padding: 0; z-index: 5
}
.btn-group ul li { padding: 5px 15px; cursor: pointer; display: block }
.btn-group ul.subnav li { padding: 0; }
.btn-group ul.subnav li > a { padding: 5px 15px; display: block }
.btn-group ul li.titlef { font-weight: bold; }
.btn-group ul li:hover {
background: #333;
}
.btn-group.open ul {
bottom: 26px;
}
.nav .btn-group ul {bottom: auto; top: -999em}
.nav .btn-group.open ul {
top: 43px;
}
/* Style the scrolBar for modern browsers */
.btn-group ul::-webkit-scrollbar {
width: 7px;
}
.btn-group ul::-webkit-scrollbar-thumb {
-webkit-border-radius: 3px;
border-radius: 3px;
background: rgba(92,92,92,0.8);
box-shadow: inset 0 0 0 1px rgba(255,255,255,0.5);
}
.btn-group ul::-webkit-scrollbar-thumb:window-inactive {
background: rgba(255,255,255,0.4);
}
/* caret */
.caret {
display: inline-block;
width: 0;
height: 0;
margin-left: 2px;
vertical-align: middle;
border-top: 4px dashed;
border-top: 4px solid\9;
border-right: 4px solid transparent;
border-left: 4px solid transparent;
}
/* STYLE CODE WRAPPING
-------------------------------------------------- */

View file

@ -2,87 +2,73 @@
var isIE = (new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null) ? parseFloat( RegExp.$1 ) : false,
isIE8 = isIE === 8,
isIE9 = isIE === 9;
/* TRANSFORMS EXAMPLES */
var featurettes = document.querySelectorAll('.featurettes'), fl = featurettes.length;
var translateExamples = document.getElementById('translate-examples'),
translateBtn = translateExamples.querySelector('.btn'),
tr2d = translateExamples.getElementsByTagName('div')[0],
trx = translateExamples.getElementsByTagName('div')[1],
trry = translateExamples.getElementsByTagName('div')[2],
trz = translateExamples.getElementsByTagName('div')[3],
tr2dTween = KUTE.to(tr2d, {translate:170}, {easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500}),
trxTween = KUTE.to(trx, {translateX:-170}, {easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500}),
trryTween = KUTE.to(trry, {translate3d:[0,170,0]}, {easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500}),
trzTween = KUTE.to(trz, {translate3d:[0,0,-100]}, {perspective:200, easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500});
translateBtn.addEventListener('click', function(){
!tr2dTween.playing && tr2dTween.start();
!trxTween.playing && trxTween.start();
!trryTween.playing && trryTween.start();
!trzTween.playing && trzTween.start();
}, false);
for ( var i=0; i<fl; i++){
var example = featurettes[i];
if ( example.querySelector('[data-]') !== undefined ) {
var items = example.querySelectorAll('.example-item'), bl = items.length, tweens = [];
for (var j=0;j<bl;j++) {
var data = processData(items[j]),
pp = data.options.perspective,
ppp = data.options.parentPerspective,
to = data.properties, fr = getFrom(data.properties,items[j]),
tween1 = KUTE.fromTo(items[j], fr, to, {easing: 'easingCubicInOut', yoyo: true, repeat: 1, duration: 1500, perspective: pp, parentPerspective: ppp} );
tweens.push(tween1);
}
addListener(example,tweens);
}
}
var rotExamples = document.getElementById('rotExamples'),
rotBtn = rotExamples.querySelector('.btn'),
r2d = rotExamples.querySelectorAll('div')[0],
rx = rotExamples.querySelectorAll('div')[1],
ry = rotExamples.querySelectorAll('div')[2],
rz = rotExamples.querySelectorAll('div')[3],
r2dTween = KUTE.to(r2d, {rotate:-720}, {easing:'easingCircularInOut', yoyo:true, repeat: 1, duration:1500}),
rxTween = KUTE.to(rx, {rotateX:180}, {easing:'linear', yoyo:true, repeat: 1, duration:1500}),
ryTween = KUTE.to(ry, {rotateY:-180,scale:1.5}, {perspective:200, easing:'easingCubicInOut', yoyo:true, repeat: 1, duration:1500}),
rzTween = KUTE.to(rz, {rotateZ:360}, {easing:'easingBounceOut', yoyo:true, repeat: 1, duration:1500});
rotBtn.addEventListener('click', function(){
!r2dTween.playing && r2dTween.start();
!rxTween.playing && rxTween.start();
!ryTween.playing && ryTween.start();
!rzTween.playing && rzTween.start();
}, false);
var skewExamples = document.getElementById('skewExamples'),
skewBtn = skewExamples.querySelector('.btn'),
sx = skewExamples.querySelectorAll('div')[0],
sy = skewExamples.querySelectorAll('div')[1],
sxTween = KUTE.to(sx, {skewX:-25}, {easing:'easingCircularInOut', yoyo:true, repeat: 1, duration:1500}),
syTween = KUTE.to(sy, {skewY:25}, {easing:'easingCircularInOut', yoyo:true, repeat: 1, duration:1500});
skewBtn.addEventListener('click', function(){
!sxTween.playing && sxTween.start();
!syTween.playing && syTween.start();
}, false);
var mixTransforms = document.getElementById('mixTransforms'),
skewBtn = mixTransforms.querySelector('.btn'),
mt1 = mixTransforms.querySelectorAll('div')[0],
mt2 = mixTransforms.querySelectorAll('div')[1],
pp = KUTE.property('perspective'),
tfp = KUTE.property('transform'),
tfo = KUTE.property('transformOrigin'),
mt1Tween = KUTE.to(mt1, {translateX:200,rotateX:360,rotateY:15,rotateZ:5}, { perspective:400, easing:'easingCubicInOut', yoyo:true, repeat: 1, duration:1500}),
mt2Tween = KUTE.to(mt2, {translateX:-200,rotateX:360,rotateY:15,rotateZ:5}, { easing:'easingCubicInOut', yoyo:true, repeat: 1, duration:1500});
mt1.style[tfo] = '50% 50% 50px'; mt1.style[tfp] = 'perspective(400px) translateX(0px) rotateX(0deg) rotateY(0deg) rotateZ(0deg)';
mt2.style[tfo] = '50% 50% 50px'; mt2.parentNode.style[pp] = '400px';
skewBtn.addEventListener('click', function(){
!mt1Tween.playing && mt1Tween.start();
!mt2Tween.playing && mt2Tween.start();
}, false);
function addListener(example,tweens){
example.querySelector('.btn').addEventListener('click',function(e){
e.preventDefault();
for (var i=0;i<tweens.length;i++) {
tweens[i].start();
}
},false);
}
function getFrom(to,el) {
var start = {}, css = window.getComputedStyle(el);
for (var p in to) {
if (p==='translate3d') {
start[p] = [0,0,0];
} else if (p==='color' || p==='backgroundColor' || p==='border-color') {
start[p] = css[p] || 'rgba(0,0,0,0)';
} else if ( p === 'backgroundPosition' ){
start[p] = [50,50];
} else if ( p === 'clip' ){
start[p] = css[p] || [0,0,0,0];
} else if ( p === 'borderRadius' ){
start[p] = '5px';
} else if ( p === 'scale' || p === 'opacity' ){
start[p] = 1;
} else {
start[p] = css[p] || 0;
}
}
return start;
}
//make a sort of data-api animation
function processData(el){
var options = {}, properties = {}, l=0, attr=el.attributes;
for (l;l<attr.length;l++){
if (/^data-/.test(attr[l].nodeName)) {
if (/option/.test(attr[l].nodeName)) {
var op = attr[l].nodeName.replace('data-option-','').replace(/\s/,'').split('-');
for (var i=0;i<op.length;i++) {
if (i>0 && op[i]!==undefined) {
op[i] = op[i].charAt(0).toUpperCase() + op[i].slice(1);
}
}
op = op.join('');
options[op] = attr[l].value;
} else if (/property/.test(attr[l].nodeName)) {
var pp = attr[l].nodeName.replace('data-property-','').replace(/\s/,'').split('-');
for (var j=0;j<pp.length;j++) {
if (j>0 && pp[j]!==undefined) {
pp[j] = pp[j].charAt(0).toUpperCase() + pp[j].slice(1);
}
}
pp = pp.join('');
properties[pp] = pp === 'translate3d' || pp === 'translate' ? attr[l].value.replace(/\[|\]/g,'').split(',') : attr[l].value;
}
}
}
return {options: options, properties: properties};
}
/* TRANSFORMS EXAMPLES */
@ -117,12 +103,13 @@ var tween32 = KUTE.to(el3,{translate3d:[200,20,0], rotateY: 15}, {perspective:10
var tween33 = KUTE.to(el3,{translate3d:[0,0,0], rotateX: 0, rotateY:0}, {perspective:100, duration: 2000});
// chain tweens
tween31.chain(tween32);
tween32.chain(tween33);
tween31.chain(tween32); tween32.chain(tween33);
ctb.addEventListener('click',function(e){
e.preventDefault();
tween11.start(); tween21.start(); tween31.start();
!tween11.playing && !tween12.playing && !tween13.playing && tween11.start();
!tween21.playing && !tween22.playing && !tween23.playing && tween21.start();
!tween31.playing && !tween32.playing && !tween33.playing && tween31.start();
},false);
/* CHAINED TWEENS EXAMPLE */
@ -136,82 +123,28 @@ var boxModel = document.getElementById('boxModel'),
var bm1 = KUTE.to(box,{width:250},{ yoyo: true, repeat: 1, duration: 1500, update: onWidth});
var bm2 = KUTE.to(box,{height:250},{ yoyo: true, repeat: 1, duration: 1500, update: onHeight});
var bm3 = KUTE.to(box,{left:250},{ yoyo: true, repeat: 1, duration: 1500, update: onLeft});
var bm4 = KUTE.to(box,{top:-250},{ yoyo: true, repeat: 1, duration: 1500, update: onTop});
var bm5 = KUTE.fromTo(box,{padding:0},{padding:20},{ yoyo: true, repeat: 1, duration: 1500, update: onPadding});
var bm6 = KUTE.to(box,{marginTop:50,marginLeft:50,marginBottom:70},{ yoyo: true, repeat: 1, duration: 1500, update: onMargin, complete: onComplete});
var bm4 = KUTE.to(box,{top:-250},{ yoyo: true, repeat: 1, duration: 1500, update: onTop, complete: onComplete});
// chain the bms
bm1.chain(bm2);
bm2.chain(bm3);
bm3.chain(bm4);
bm4.chain(bm5);
bm5.chain(bm6);
//callback functions
function onWidth() { var css = box.currentStyle || window.getComputedStyle(box); box.innerHTML = 'WIDTH<br>'+parseInt(css.width)+'px'; }
function onHeight() { var css = box.currentStyle || window.getComputedStyle(box); box.innerHTML = 'HEIGHT<br>'+parseInt(css.height)+'px'; }
function onLeft() { var css = box.currentStyle || window.getComputedStyle(box); box.innerHTML = 'LEFT<br>'+parseInt(css.left)+'px'; }
function onTop() { var css = box.currentStyle || window.getComputedStyle(box); box.innerHTML = 'TOP<br>'+parseInt(css.top)+'px'; }
function onPadding() { var css = box.currentStyle || window.getComputedStyle(box); box.innerHTML = 'PADDING<br>'+(parseInt(css.padding)+'px')||'auto'; }
function onMargin() { var css = box.currentStyle || window.getComputedStyle(box); box.innerHTML = 'MARGIN<br>'+parseInt(css.marginTop)+'px'; }
function onComplete() { box.innerHTML = 'BOX<br>MODEL'; btb.style.display='inline'; }
function onComplete() { box.innerHTML = 'BOX<br>MODEL'; }
btb.addEventListener('click', function(e){
e.preventDefault();
bm1.start();
btb.style.display='none';
!bm1.playing && !bm2.playing && !bm3.playing && !bm4.playing && bm1.start();
},false);
/* BOX MODEL EXAMPLE */
/* TEXT PROPERTIES EXAMPLE */
var textProperties = document.getElementById('textProperties'),
heading = textProperties.querySelector('h1'),
button = textProperties.querySelectorAll('.btn')[0],
tbt = textProperties.querySelectorAll('.btn')[1],
// let's split the heading text by character
chars = heading.innerHTML.split('');
// wrap the splits into spans and build an object with these spans
heading.innerHTML = '<span>' + chars.join('</span><span>') + '</span>';
var charsObject = heading.getElementsByTagName('SPAN'), l = charsObject.length;
// built the tween objects
var tp1 = KUTE.fromTo(
button,
{width: 150, opacity:0, height: 70, lineHeight:70, fontSize: 40},
{width: 100, opacity:1, height: 35, lineHeight:35, fontSize: 20});
function runHeadingAnimation() {
for (var i=0; i<l; i++){
var fn = i === l-1 ? startButtonAnimation : null,
delay = 250*i;
KUTE.fromTo(charsObject[i],
{opacity:0, height: 50, fontSize:80, letterSpacing: 20},
{opacity:1, height: 35, fontSize:50, letterSpacing: 0},
{complete: fn, delay: delay, duration: 500, easing: 'easingCubicOut'}
).start()
}
function startButtonAnimation(){
tp1.start();
}
}
tbt.addEventListener('click', function(e){
e.preventDefault();
for (var i=0;i<l; i++) {
charsObject[i].style.opacity ="";
}
button.style.opacity = '';
runHeadingAnimation();
},false);
/* TEXT PROPERTIES EXAMPLE */
/* COLORS EXAMPLE */
var colBox = document.getElementById('colBox'),
colBoxElement = colBox.querySelector('.example-box'),
@ -219,67 +152,20 @@ var colBox = document.getElementById('colBox'),
var colTween1 = KUTE.to(colBoxElement, {color: '#9C27B0'}, {duration: 1000});
var colTween2 = KUTE.to(colBoxElement, {backgroundColor: '#069'}, {duration: 1000});
var colTween3 = KUTE.to(colBoxElement, {borderColor: '#069'}, {duration: 1000});
var colTween4 = KUTE.to(colBoxElement, {color: '#fff'}, {duration: 1000});
var colTween5 = KUTE.to(colBoxElement, {borderTopColor: '#9C27B0'}, {duration: 1000});
var colTween6 = KUTE.to(colBoxElement, {borderRightColor: '#9C27B0'}, {duration: 1000});
var colTween7 = KUTE.to(colBoxElement, {borderBottomColor: '#9C27B0'}, {duration: 1000});
var colTween8 = KUTE.to(colBoxElement, {borderLeftColor: '#9C27B0'}, {duration: 1000});
var colTween9 = KUTE.to(colBoxElement, {backgroundColor: '#9C27B0'}, {duration: 1000});
var colTween3 = KUTE.to(colBoxElement, {color: '#fff'}, {duration: 1000});
var colTween4 = KUTE.to(colBoxElement, {backgroundColor: '#9C27B0'}, {duration: 1000});
colTween1.chain(colTween2);
colTween2.chain(colTween3);
colTween3.chain(colTween4);
colTween4.chain(colTween5);
colTween5.chain(colTween6);
colTween6.chain(colTween7);
colTween7.chain(colTween8);
colTween8.chain(colTween9);
colbtn.addEventListener('click', function(e){
e.preventDefault();
colTween1.start();
!colTween1.playing && !colTween2.playing && !colTween3.playing && !colTween4.playing && colTween1.start();
},false);
/* COLORS EXAMPLE */
/* CLIP EXAMPLE */
var clipExample = document.getElementById('clip'),
clipElement = clipExample.querySelector('.example-box'),
clpbtn = clipExample.querySelector('.btn');
var clp1 = KUTE.fromTo(clipElement, {clip: [0,150,150,0]}, {clip: [0,20,150,0]}, {duration:500, easing: 'easingCubicOut'});
var clp2 = KUTE.fromTo(clipElement, {clip: [0,20,150,0]}, {clip: [0,150,150,130]}, {duration:600, easing: 'easingCubicOut'});
var clp3 = KUTE.fromTo(clipElement, {clip: [0,150,150,130]}, {clip: [0,150,20,0]}, {duration:800, easing: 'easingCubicOut'});
var clp4 = KUTE.fromTo(clipElement, {clip: [0,150,20,0]}, {clip: [0,150,150,0]}, {duration:1200, easing: 'easingExponentialInOut'});
//chain some clps
clp1.chain(clp2);
clp2.chain(clp3);
clp3.chain(clp4);
clpbtn.addEventListener('click', function(e){
e.preventDefault();
clp1.start();
},false);
/* CLIP EXAMPLE */
/* BACKGROUND POSITION EXAMPLE */
var bgPos = document.getElementById('bgPos'),
bgBox = bgPos.querySelector('.example-box'),
bgb = bgPos.querySelector('.btn'),
bpTween1 = KUTE.fromTo(bgBox, {backgroundPosition: ['50%','50%']}, {backgroundPosition: ['0%','50%']}, { yoyo: true, repeat: 1, duration: 1500, easing: 'easingCubicOut'});
bgb.addEventListener('click', function(e){
e.preventDefault();
bpTween1.start();
},false);
/* BACKGROUND POSITION EXAMPLE */
/* CROSS BROWSER EXAMPLE */
// grab an HTML element to build a tween object for it
var element = document.getElementById("myElement");
@ -351,6 +237,49 @@ var tweenMulti = KUTE.allFromTo('.example-multi',
{transformOrigin: '10% 10%', offset: 300, duration: 1000, easing: 'easingCubicOut', repeat: 1, repeatDelay: 1000, yoyo: true}
);
function startMultiTween() {
tweenMulti.start();
!tweenMulti.tweens[0].playing && !tweenMulti.tweens[tweenMulti.tweens.length-1].playing && tweenMulti.start();
}
/* MULTI TWEENS EXAMPLE */
/* MULTI TWEENS EXAMPLE */
/* EASINGS EXAMPLE */
var esProp1 = isIE && isIE < 9 ? { left:0 } : { translate: 0},
esProp2 = isIE && isIE < 9 ? { left:250 } : { translate: 250},
tweenEasingElements = document.querySelectorAll('.easing-example'),
easings = document.getElementById('easings'),
startEasingTween = document.getElementById('startEasingTween'),
easingSelectButton = document.getElementById('easingSelectButton'),
tweenEasing1 = KUTE.fromTo(tweenEasingElements[0], esProp1, esProp2,
{ duration: 1000, easing: 'linear', repeat: 1, yoyo: true}),
tweenEasing2 = KUTE.fromTo(tweenEasingElements[1], esProp1, esProp2,
{ duration: 1000, easing: 'linear', repeat: 1, yoyo: true});
easings.addEventListener('click',function(e){
if (!e.target.className){
var es = e.target.innerHTML;
easingSelectButton.innerHTML = es;
tweenEasingElements[1].innerHTML = es;
if (es === 'gravity') {
tweenEasing2._e = KUTE.Physics.gravity({elasticity:200,bounciness:600});
} else if (es === 'forceWithGravity') {
tweenEasing2._e = KUTE.Physics.forceWithGravity({elasticity:100,bounciness:600});
} else if (es === 'spring') {
tweenEasing2._e = KUTE.Physics.spring({friction:100,frequency:600});
} else if (es === 'bounce') {
tweenEasing2._e = KUTE.Physics.bounce({friction:100,frequency:600});
} else if (es === 'bezier') {
tweenEasing2._e = KUTE.Physics.bezier({points: [{"x":0,"y":0,"cp":[{"x":0.483,"y":0.445}]},{"x":1,"y":1,"cp":[{"x":0.009,"y":0.997}]}] });
} else if (es === 'multiPointBezier') {
tweenEasing2._e = KUTE.Physics.bezier({points: [{"x":0,"y":0,"cp":[{"x":0.387,"y":0.007}]},{"x":0.509,"y":0.48,"cp":[{"x":0.069,"y":0.874},{"x":0.928,"y":0.139}]},{"x":1,"y":1,"cp":[{"x":0.639,"y":0.988}]}] });
} else {
tweenEasing2._e = KUTE.pe(es);
}
}
},false);
startEasingTween.addEventListener('click', function(e) {
e.preventDefault();
!tweenEasing1.playing && tweenEasing1.start();
!tweenEasing2.playing && tweenEasing2.start();
}, false);
/* EASINGS EXAMPLE */

View file

@ -1,9 +1,19 @@
// Document
// HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
if (!this.Document){this.Document = this.HTMLDocument; }
// Element
if (!window.HTMLElement) { window.HTMLElement = window.Element; }
// Window
(function(global) {
if (global.constructor) {
global.Window = global.constructor;
} else {
(global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
}
}(this));
// Date.now
if(!Date.now){ Date.now = function now() { return new Date().getTime(); }; }
@ -20,6 +30,7 @@ if(!Date.now){ Date.now = function now() { return new Date().getTime(); }; }
}
})();
// Array.prototype.indexOf
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function indexOf(searchElement) {
@ -160,53 +171,24 @@ if (!('getComputedStyle' in window)) {
})();
}
// requestAnimationFrame
if (!window.requestAnimationFrame) {
var lT = Date.now(); // lastTime
window.requestAnimationFrame = function (callback) {
'use strict';
if (typeof callback !== 'function') {
throw new TypeError(callback + 'is not a function');
}
var cT = Date.now(), // currentTime
dl = 16 + lT - cT; // delay
if (dl < 0) { dl = 0; }
lT = cT;
return setTimeout(function () {
lT = Date.now();
callback(window.performance.now());
}, dl);
};
window.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
}
// Event
if (!window.Event||!Window.prototype.Event) {
(function (){
window.Event = Window.prototype.Event = Document.prototype.Event = Element.prototype.Event = function Event(t, args) {
if (!t) { throw new Error('Not enough arguments'); } // t is event.type
var ev,
b = args && args.bubbles !== undefined ? args.bubbles : false,
c = args && args.cancelable !== undefined ? args.cancelable : false;
window.Event = Window.prototype.Event = Document.prototype.Event = Element.prototype.Event = function Event(type, eventInitDict) {
if (!type) { throw new Error('Not enough arguments'); }
var event,
bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false,
cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
if ( 'createEvent' in document ) {
ev = document.createEvent('Event');
ev.initEvent(t, b, c);
event = document.createEvent('Event');
event.initEvent(type, bubbles, cancelable);
} else {
ev = document.createEventObject();
ev.type = t;
ev.bubbles = b;
ev.cancelable = c;
event = document.createEventObject();
event.type = type;
event.bubbles = bubbles;
event.cancelable = cancelable;
}
return ev;
return event;
};
})();
}
@ -214,13 +196,13 @@ if (!window.Event||!Window.prototype.Event) {
// CustomEvent
if (!('CustomEvent' in window) || !('CustomEvent' in Window.prototype)) {
(function(){
window.CustomEvent = Window.prototype.CustomEvent = Document.prototype.CustomEvent = Element.prototype.CustomEvent = function CustomEvent(type, args) {
window.CustomEvent = Window.prototype.CustomEvent = Document.prototype.CustomEvent = Element.prototype.CustomEvent = function CustomEvent(type, eventInitDict) {
if (!type) {
throw Error('TypeError: Failed to construct "CustomEvent": An event name must be provided.');
}
var ev = new Event(type, args);
ev.detail = args && args.detail || null;
return ev;
var event = new Event(type, eventInitDict);
event.detail = eventInitDict && eventInitDict.detail || null;
return event;
};
})()
@ -230,76 +212,83 @@ if (!('CustomEvent' in window) || !('CustomEvent' in Window.prototype)) {
if (!window.addEventListener||!Window.prototype.addEventListener) {
(function (){
window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
var el = this, // element
t = arguments[0], // type
l = arguments[1]; // listener
var element = this,
type = arguments[0],
listener = arguments[1];
if (!el._events) { el._events = {}; }
if (!element._events) { element._events = {}; }
if (!el._events[t]) {
el._events[t] = function (e) {
var ls = el._events[e.type].list, evs = ls.slice(), i = -1, lg = evs.length, eE; // list | events | index | length | eventElement
e.preventDefault = function preventDefault() {
if (e.cancelable !== false) {
e.returnValue = false;
if (!element._events[type]) {
element._events[type] = function (event) {
var list = element._events[event.type].list,
events = list.slice(),
index = -1,
length = events.length,
eventElement;
event.preventDefault = function preventDefault() {
if (event.cancelable !== false) {
event.returnValue = false;
}
};
e.stopPropagation = function stopPropagation() {
e.cancelBubble = true;
event.stopPropagation = function stopPropagation() {
event.cancelBubble = true;
};
e.stopImmediatePropagation = function stopImmediatePropagation() {
e.cancelBubble = true;
e.cancelImmediate = true;
event.stopImmediatePropagation = function stopImmediatePropagation() {
event.cancelBubble = true;
event.cancelImmediate = true;
};
e.currentTarget = el;
e.relatedTarget = e.fromElement || null;
e.target = e.target || e.srcElement || el;
e.timeStamp = new Date().getTime();
event.currentTarget = element;
event.relatedTarget = event.fromElement || null;
event.target = event.target || event.srcElement || element;
event.timeStamp = new Date().getTime();
if (e.clientX) {
e.pageX = e.clientX + document.documentElement.scrollLeft;
e.pageY = e.clientY + document.documentElement.scrollTop;
if (event.clientX) {
event.pageX = event.clientX + document.documentElement.scrollLeft;
event.pageY = event.clientY + document.documentElement.scrollTop;
}
while (++i < lg && !e.cancelImmediate) {
if (i in evs) {
eE = evs[i];
while (++index < length && !event.cancelImmediate) {
if (index in events) {
eventElement = events[index];
if (ls.indexOf(eE) !== -1 && typeof eE === 'function') {
eE.call(el, e);
if (list.indexOf(eventElement) !== -1 && typeof eventElement === 'function') {
eventElement.call(element, event);
}
}
}
};
el._events[t].list = [];
element._events[type].list = [];
if (el.attachEvent) {
el.attachEvent('on' + t, el._events[t]);
if (element.attachEvent) {
element.attachEvent('on' + type, element._events[type]);
}
}
el._events[t].list.push(l);
element._events[type].list.push(listener);
};
window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
var el = this, t = arguments[0], l = arguments[1], i; // element // type // listener // index
if (el._events && el._events[t] && el._events[t].list) {
i = el._events[t].list.indexOf(l);
var element = this,
type = arguments[0],
listener = arguments[1],
index;
if (i !== -1) {
el._events[t].list.splice(i, 1);
if (element._events && element._events[type] && element._events[type].list) {
index = element._events[type].list.indexOf(listener);
if (!el._events[t].list.length) {
if (el.detachEvent) {
el.detachEvent('on' + t, el._events[t]);
if (index !== -1) {
element._events[type].list.splice(index, 1);
if (!element._events[type].list.length) {
if (element.detachEvent) {
element.detachEvent('on' + type, element._events[type]);
}
delete el._events[t];
delete element._events[type];
}
}
}
@ -310,47 +299,47 @@ if (!window.addEventListener||!Window.prototype.addEventListener) {
// Event dispatcher / trigger
if (!window.dispatchEvent||!Window.prototype.dispatchEvent||!Document.prototype.dispatchEvent||!Element.prototype.dispatchEvent) {
(function(){
window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(e) {
window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
if (!arguments.length) {
throw new Error('Not enough arguments');
}
if (!e || typeof e.type !== 'string') {
if (!event || typeof event.type !== 'string') {
throw new Error('DOM Events Exception 0');
}
var el = this, t = e.type; // element | event type
var element = this, type = event.type;
try {
if (!e.bubbles) {
e.cancelBubble = true;
if (!event.bubbles) {
event.cancelBubble = true;
var cancelBubbleEvent = function (event) {
event.cancelBubble = true;
(el || window).detachEvent('on' + t, cancelBubbleEvent);
(element || window).detachEvent('on' + type, cancelBubbleEvent);
};
this.attachEvent('on' + t, cancelBubbleEvent);
this.attachEvent('on' + type, cancelBubbleEvent);
}
this.fireEvent('on' + t, e);
this.fireEvent('on' + type, event);
} catch (error) {
e.target = el;
event.target = element;
do {
e.currentTarget = el;
event.currentTarget = element;
if ('_events' in el && typeof el._events[t] === 'function') {
el._events[t].call(el, e);
if ('_events' in element && typeof element._events[type] === 'function') {
element._events[type].call(element, event);
}
if (typeof el['on' + t] === 'function') {
el['on' + t].call(el, e);
if (typeof element['on' + type] === 'function') {
element['on' + type].call(element, event);
}
el = el.nodeType === 9 ? el.parentWindow : el.parentNode;
} while (el && !e.cancelBubble);
element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
} while (element && !event.cancelBubble);
}
return true;

View file

@ -1,5 +1,5 @@
//returns browser prefix
function getPrefix() {
function getPrefix() {
var div = document.createElement('div'), i = 0, pf = ['Moz', 'moz', 'Webkit', 'webkit', 'O', 'o', 'Ms', 'ms'], pl = pf.length,
s = ['MozTransform', 'mozTransform', 'WebkitTransform', 'webkitTransform', 'OTransform', 'oTransform', 'MsTransform', 'msTransform'];
@ -21,11 +21,11 @@ var prefix = getPrefix(), // prefix
var container = document.getElementById('container'),
easing = 'easingQuadraticInOut',
tweens = [];
function createTest(count, property, engine, repeat, hack) {
function createTest(count, property, engine, repeat) {
var update;
for (var i = 0; i < count; i++) {
var tween,
div = document.createElement('div'),
var div = document.createElement('div'),
windowHeight = document.documentElement.clientHeight - 10,
left = random(-200, 200),
toLeft = random(-200, 200),
@ -40,7 +40,6 @@ function createTest(count, property, engine, repeat, hack) {
if (property==='left') {
div.style.left = left + 'px';
if (hack) { div.className += ' hack'; }
fromValues = engine==="tween" ? { left: left, div: div } : { left: left };
toValues = { left: toLeft }
} else {
@ -58,35 +57,23 @@ function createTest(count, property, engine, repeat, hack) {
// perf test
if (engine==='kute') {
tween = KUTE.fromTo(div, fromValues, toValues, { delay: 100, easing: easing, repeat: repeat, yoyo: true, duration: 1000, complete: fn });
tweens.push(tween);
tweens.push(KUTE.fromTo(div, fromValues, toValues, { delay: 100, easing: easing, repeat: repeat, yoyo: true, duration: 1000, complete: fn }));
} else if (engine==='gsap') {
if (property==="left"){
tween = TweenMax.fromTo(div, 1, fromValues, {left : toValues.left, repeat : repeat, yoyo : true, ease : Quad.easeInOut, onComplete: fn });
TweenMax.fromTo(div, 1, fromValues, {left : toValues.left, repeat : repeat, yoyo : true, ease : Quad.easeInOut, onComplete: fn });
} else {
tween = TweenMax.fromTo(div, 1, fromValues, { x:toValues.x, repeat : repeat, yoyo : true, ease : Quad.easeInOut, onComplete: fn });
TweenMax.fromTo(div, 1, fromValues, { x:toValues.x, repeat : repeat, yoyo : true, ease : Quad.easeInOut, onComplete: fn });
}
} else if (engine==='tween') {
var update;
if (property==="left"){
update = function(){
this.div.style['left'] = this.left+'px';
}
update = updateLeft;
} else if (property==="translateX"){
update = function(){
this.div.style[transformProperty] = 'translate3d('+this.x + 'px,0px,0px)';
}
update = updateTranslate;
}
tween = new TWEEN.Tween(fromValues)
.to(toValues,1000)
.easing( TWEEN.Easing.Quadratic.InOut )
.onComplete( complete )
.onUpdate( update)
.repeat(repeat)
.yoyo(true);
tweens.push(tween);
tweens.push(new TWEEN.Tween(fromValues).to(toValues,1000).easing( TWEEN.Easing.Quadratic.InOut ).onComplete( complete ).onUpdate( update).repeat(repeat).yoyo(true));
}
}
if (engine==='tween') {
@ -95,14 +82,6 @@ function createTest(count, property, engine, repeat, hack) {
requestAnimationFrame( animate );
TWEEN.update( time );
}
}
// since our engines don't do sync, we make it our own here
if (engine==='tween'||engine==='kute') {
var now = window.performance.now();
for (var t =0; t<count; t++){
tweens[t].start(now+count/16)
}
}
}
@ -112,6 +91,15 @@ function complete(){
tweens = [];
}
function updateLeft(){
this.div.style['left'] = this.left+'px';
}
function updateTranslate(){
this.div.style[transformProperty] = 'translate3d('+this.x + 'px,0px,0px)';
}
//some button toggle
var btnGroups = document.querySelectorAll('.btn-group'), l = btnGroups.length;
@ -122,45 +110,36 @@ for (var i=0; i<l; i++) {
var link = this, b = link.parentNode.parentNode.parentNode.querySelector('.btn');
b.innerHTML = link.id.toUpperCase() + ' <span class="caret"></span>';
b.setAttribute('data-'+link.parentNode.parentNode.parentNode.id,link.id);
if ( /LEFT/.test(document.getElementById('property').querySelector('.btn').innerHTML) ) {
document.getElementById('hack').style.display = 'block';
} else {
document.getElementById('hack').style.display = 'none';
}
}
}
}
document.getElementById('hack').querySelector('.btn').onclick = function(){
var self= this;
setTimeout(function(){
if ( !self.querySelector('INPUT').checked ) {
self.className = self.className.replace('btn-info','btn-warning');
self.querySelector('.state').innerHTML = 'Hack ON';
} else if ( self.querySelector('INPUT').checked ) {
self.className = self.className.replace('btn-warning','btn-info');
self.querySelector('.state').innerHTML = 'Hack OFF';
}
},200)
}
// the start button handle
document.getElementById('start').onclick = function(){
document.getElementById('start').addEventListener('click', buildObjects, false);
function buildObjects(){
var c = document.querySelector('[data-count]'), e = document.querySelector('[data-engine]'), r = document.querySelector('[data-repeat]'),
p = document.querySelector('[data-property]'), ct = c && document.querySelector('[data-count]').getAttribute('data-count'),
count = ct ? parseInt(ct) : null,
engine = e && document.querySelector('[data-engine]').getAttribute('data-engine') || null,
repeat = r && document.querySelector('[data-repeat]').getAttribute('data-repeat') || null,
property = p && document.querySelector('[data-property]').getAttribute('data-property') || null,
hack = document.getElementById('hack').getElementsByTagName('INPUT')[0].getAttribute('checked') ? true : false,
warning = document.createElement('DIV');
warning.className = 'text-warning padding lead';
container.innerHTML = '';
if (count && engine && property && repeat) {
document.getElementById('info').style.display = 'none';
if (engine === 'gsap') {
document.getElementById('info').style.display = 'none';
}
createTest(count,property,engine,repeat,hack);
createTest(count,property,engine,repeat);
// since our engines don't do sync, we make it our own here
if (engine==='tween'||engine==='kute') {
document.getElementById('info').style.display = 'none';
start();
}
} else {
if (!count && !property && !repeat && !engine){
@ -175,4 +154,11 @@ document.getElementById('start').onclick = function(){
container.appendChild(warning);
}
}
function start() {
var now = window.performance.now(), count = tweens.length;
for (var t =0; t<count; t++){
tweens[t].start(now+count/16)
}
}

View file

@ -1,14 +1,52 @@
// common demo JS
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// utility functions
function addClass(el,c) { // where modern browsers fail, use classList
if (el.classList) { el.classList.add(c); } else { el.className += ' '+c; el.offsetWidth; }
}
function removeClass(el,c) {
if (el.classList) { el.classList.remove(c); } else { el.className = el.className.replace(c,'').replace(/^\s+|\s+$/g,''); el.offsetWidth; }
}
//scroll top?
var toTop = document.getElementById('toTop');
var toTop = document.getElementById('toTop'),
toTopTween = KUTE.to( 'window', { scroll: 0 }, {easing: 'easingQuarticOut', duration : 1500 } );
toTop.addEventListener('click',topHandler,false);
function topHandler(e){
e.preventDefault();
KUTE.to( 'window', { scroll: 0 }, {easing: 'easingQuarticOut', duration : 1500 } ).start();
}
toTopTween.start();
}
// toggles utility
var toggles = document.querySelectorAll('[data-function="toggle"]');
for (var i = 0, l = toggles.length; i< l; i ++ ){
toggles[i].addEventListener('click', toggleClass, false);
}
function toggleClass(e){
e.preventDefault();
var pr = this.parentNode;
if (!/open/.test(pr.className)){
addClass(pr,'open');
} else {
removeClass(pr,'open');
}
}
function closeToggles(el){
var pr = el.parentNode;
if (/open/.test(pr.className)){
removeClass(pr,'open');
}
}
document.addEventListener('click', function(e){
for (var i = 0, l = toggles.length; i< l; i ++ ){
if (toggles[i]!==e.target) closeToggles(toggles[i]);
}
}, false);

View file

@ -9,7 +9,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="KUTE.js is a minimal Javascript animation engine">
<meta name="description" content="Animation examples for KUTE.js core engine with most essential CSS properties and easing functions.">
<meta name="keywords" content="kute,kute.js,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.png"> <!-- TO DO -->
@ -27,11 +27,13 @@
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<!-- Polyfill -->
<script src="./assets/js/minifill.js"> </script>
<!-- legacy browsers support via polyfill
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,getComputedStyle|gated"> </script> -->
<!--[if IE]>
<script src="https://cdn.jsdelivr.net/minifill/0.0.2/minifill.min.js"> </script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<![endif]-->
</head>
@ -45,17 +47,38 @@
<div class="content-wrap">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<ul class="nav">
<li><a href="features.html">Features</a></li>
<li class="active"><a href="examples.html">Examples</a></li>
<li><a href="api.html">API</a></li>
<li class="btn-group"><a href="#" data-function="toggle">Features <span class="caret"></span></a>
<ul class="subnav">
<li><a href="features.html">Feature Overview</a></li>
<li><a href="properties.html">Supported Properties</a></li>
</ul>
</li>
<li class="btn-group active">
<a href="#" data-function="toggle">Examples <span class="caret"></span></a>
<ul class="subnav">
<li class="active"><a href="examples.html">Core Engine</a></li>
<li><a href="css.html">CSS Plugin </a></li>
<li><a href="svg.html">SVG Plugin </a></li>
<li><a href="attr.html">Attributes Plugin </a></li>
</ul>
</li>
<li class="btn-group">
<a href="#" data-function="toggle">API <span class="caret"></span></a>
<ul class="subnav">
<li><a href="start.html">Getting Started</a></li>
<li><a href="api.html">Public Methods</a></li>
<li><a href="easing.html">Easing Functions</a></li>
<li><a href="extend.html">Extend Guide</a></li>
</ul>
</li>
<li><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div class="content-wrap">
<h2>Quick Examples</h2>
<p>KUTE.js can be used in most cases with native Javascript, but also with jQuery. So, before we head over to the more advanced examples, let's have a quick look at these two basic examples here. <strong>Note</strong>: the examples are posted on <a href="http://codepen.io/thednp/pens/public/" target="_blank">codepen</a>.</p>
<h2>Core Engine</h2>
<p>KUTE.js core engine can animate by itself a great deal of CSS properties as well as scroll. You can do it all with native Javascript or with jQuery, but before we head over to the more advanced examples, let's have a quick look at these two basic examples here. <strong>Note</strong>: the examples are posted on <a href="http://codepen.io/thednp/pens/public/" target="_blank">codepen</a>.</p>
<h3>Basic Native Javascript Example</h3>
<p>When developing with native Javascript, a very basic syntax goes like this:</p>
@ -65,13 +88,15 @@
var tween = KUTE.fromTo('selector', {left: 0}, {left: 100}, {yoyo: true});</code>
</pre>
<p>Now the tween object is created, it's a good time for you to know that via Native Javascript we <strong>always</strong> animate the first HTML element only, even if you're using a class selector. To create/control a tween for multiple elements such as <code>querySelectorAll()</code> or <code>getElementsByTagName()</code>, you need to do a <code>for ()</code> loop. Now let's apply the tween control methods:</p>
<p>Now the tween object is created, it's a good time for you to know that via Native Javascript we <strong>always</strong> animate the first HTML element only, even if you're using a class selector. To create/control a tween for multiple elements such as <code>querySelectorAll()</code> or <code>getElementsByTagName()</code>, you need to do a <code>for ()</code> loop, or make use of the two new methods: <code>.allTo()</code> or <code>.allFromTo()</code>. Now let's apply the tween control methods:</p>
<pre><code class="language-javascript">tween.start(); // starts the animation
tween.stop(); // stops current tween and all chained tweens animating
tween.pause(); // pauses current tween animation
tween.play(); // or tween.resume(); resumes current tween animation
tween.chain(tween2); // when tween animation finished, you can trigger the start of another tween
</code></pre>
<p>The demo for the above example is <a href="http://codepen.io/thednp/pen/Bozbgg" target="_blank">here</a>.</p>
<h3>Basic jQuery Example</h3>
@ -88,10 +113,10 @@ $(tween).KUTE('chain',myTween2); // when tween animation finished, you can trigg
</code></pre>
<p>The demo for the above example is <a href="http://codepen.io/thednp/pen/dYXLyj" target="_blank">here</a>.</p>
<h2>Transform Properties Examples</h2>
<h3>Transform Properties Examples</h3>
<p>KUTE.js supports almost all about <code>transform</code> as described in the <a href="http://www.w3.org/TR/css3-transforms/" target="_blank">spec</a>: the 2D <code>translate</code>, <code>rotate</code>, <code>skewX</code>, <code>skewY</code> and <code>scale</code>, as well as the 3D <code>translateX</code>, <code>translateY</code>, <code>translateZ</code>, <code>translate3d</code>, <code>rotateX</code>, <code>rotateX</code>, <code>rotateY</code>, <code>rotateZ</code> properties. Additionally it allows you to set a <code>perspective</code> for the element or it's parent as well as a <code>perpective-origin</code> for the element or it's parent.</p>
<h3>Translations</h3>
<h4>Translations</h4>
<p>In the next example the first box is moving to left 250px with <code>translate</code> property, the second box is moving to the right by 200px using <code>translateX</code> and the third box is moving to the bottom using <code>translate3d</code>. The last box also uses <code>translate3d</code> but requires a <code>perspective</code> value for the animation on the Z axis to be effective.</p>
<pre><code class="language-javascript">var tween1 = KUTE.fromTo('selector1',{translate:0},{translate:-250}); // or translate:[x,y] for both axis
var tween2 = KUTE.fromTo('selector2',{translateX:0},{translateX:200});
@ -99,58 +124,59 @@ var tween3 = KUTE.fromTo('selector3',{translate3d:[0,0,0]},{translate3d:[0,100,0
var tween4 = KUTE.fromTo('selector4',{translate3d:[0,0,0]},{translate3d:[0,0,-100]},{parentPerspective: 100});
</code></pre>
<p>And here is how it looks like:</p>
<div class="featurettes">
<div data-property-translate="170" class="example-item example-box bg-indigo">2D</div>
<div data-property-translate-x="-170" class="example-item example-box bg-olive">X</div>
<div data-property-translate3d="[0,170,0]" class="example-item example-box bg-pink">Y</div>
<div data-property-translate3d="[0,0,-100]" data-option-parent-perspective="200" class="example-item example-box bg-red">Z</div>
<div id="translate-examples" class="featurettes">
<div class="example-item example-box bg-indigo">2D</div>
<div class="example-item example-box bg-olive">X</div>
<div class="example-item example-box bg-pink">Y</div>
<div class="example-item example-box bg-red">Z</div>
<div class="example-buttons">
<a class="btn btn-blue" href="#">Start</a>
<a class="btn btn-blue" href="javascript:void(0)">Start</a>
</div>
</div>
<p>As you can see in your browsers console, for all animations <code>translate3d</code> is used, as explained in the <a href="features.html">features page</a>. Also the first example that's using the 2D <code>translate</code> for both vertical and horizontal axis even if we only set X axis. You can download this example <a href="http://codepen.io/thednp/share/zip/rOLbyY">here</a>.</p>
<p><strong>Remember</strong>: stacking <code>translate</code> and <code>translate3d</code> together may not work and IE9 does not support <code>perspective</code>.</p>
<h3>Rotations</h3>
<h4>Rotations</h4>
<p>Next we're gonna animate 4 elements with one axis each element. Unlike translations, KUTE.js does not support <code>rotate3d</code>.</p>
<pre><code class="language-javascript">var tween1 = KUTE.fromTo('selector1',{rotate:0},{rotate:-720});
var tween2 = KUTE.fromTo('selector2',{rotateX:0},{rotateX:200});
var tween3 = KUTE.fromTo('selector3',{rotateY:0},{rotateY:160},{perspective:100});
var tween4 = KUTE.fromTo('selector4',{rotateZ:0},{rotateZ:360});
</code></pre>
</code></pre>
<p>And here is how it looks like:</p>
<div class="featurettes">
<div data-property-rotate="-720" class="example-item example-box bg-blue">2D</div>
<div data-property-rotate-x="180" class="example-item example-box bg-indigo">X</div>
<div data-property-rotate-y="-180" data-option-perspective="200" class="example-item example-box bg-olive">Y</div>
<div data-property-rotate-z="360" class="example-item example-box bg-pink">Z</div>
<div id="rotExamples" class="featurettes">
<div class="example-item example-box bg-blue">2D</div>
<div class="example-item example-box bg-indigo">X</div>
<div data-option-perspective="200" class="example-item example-box bg-olive">Y</div>
<div class="example-item example-box bg-pink">Z</div>
<div class="example-buttons">
<a class="btn btn-green" href="#">Start</a>
<a class="btn btn-green" href="javascript:void(0)">Start</a>
</div>
</div>
<p>The <code>rotateX</code> and <code>rotateY</code> are 3D based rotations, so they require a perspective in order to make the browser render proper 3D layers, but in the example they animate different because only the second, Y axis, uses a <code>perspective</code> setting. The rotation on Z axis does not require a perspective. Unlike translations, you can stack all axis rotation for your animation, but we will see that in a later example. You can download this example <a href="http://codepen.io/thednp/share/zip/NGrmMR">here</a>.</p>
<h3>Skews</h3>
<h4>Skews</h4>
<p>KUTE.js supports <code>skewX</code> and <code>skewY</code> so let's animate the two. Since they are 2D transformations, IE9 supports skews.</p>
<pre><code class="language-javascript">var tween1 = KUTE.fromTo('selector1',{skewX:0},{skewX:20});
var tween2 = KUTE.fromTo('selector2',{skewY:0},{skewY:45});
</code></pre>
</code></pre>
<p>And here is how it looks like:</p>
<div class="featurettes">
<div data-property-skew-x="-25" class="example-item example-box bg-teal">X</div>
<div data-property-skew-y="25" class="example-item example-box bg-green">Y</div>
<div id="skewExamples" class="featurettes">
<div class="example-item example-box bg-teal">X</div>
<div class="example-item example-box bg-green">Y</div>
<div class="example-buttons">
<a class="btn btn-yellow" href="#">Start</a>
<a class="btn btn-yellow" href="javascript:void(0)">Start</a>
</div>
</div>
<p>You can download this example <a href='http://codepen.io/thednp/share/zip/wKWbKd/'>here</a>.</p>
<h3>Mixed Transformations</h3>
<h4>Mixed Transformations</h4>
<p>The current specification does not support animating different transform properties with multiple tween objects at the same time, you must stack them all together into a single object. See the example below:</p>
<pre><code class="language-javascript">var tween1 = KUTE.fromTo('selector1',{rotateX:0},{rotateX:20}).start();
@ -173,19 +199,19 @@ var tween2 = KUTE.fromTo(
</code></pre>
<p>Now you can see we are using the specific transform options, the first tween object uses these settings for an element and the second for its parent.</p>
<div class="featurettes">
<div data-property-translate-x="200" data-property-rotate-x="360" data-property-rotate-y="15" data-property-rotate-z="5" data-option-perspective="400" class="example-item example-box bg-pink" style="line-height: 50px; font-size: 25px;">element perspective 400px</div>
<div data-property-translate-x="-200" data-property-rotate-x="360" data-property-rotate-y="15" data-property-rotate-z="5" data-option-parent-perspective="400" class="example-item example-box bg-orange" style="line-height: 50px; font-size: 25px;">parent perspective 400px</div>
<div id="mixTransforms" class="featurettes">
<div class="example-item example-box bg-pink" style="line-height: 50px; font-size: 25px;">element perspective 400px</div>
<div class="example-item example-box bg-orange" style="line-height: 50px; font-size: 25px;">parent perspective 400px</div>
<div class="example-buttons">
<a class="btn btn-olive" href="#">Start</a>
<a class="btn btn-olive" href="javascript:void(0)">Start</a>
</div>
</div>
<p>This example also shows the difference between an element's perspective and a parent's perspective. You can download the above example <a href='http://codepen.io/thednp/share/zip/jbrovv/'>here</a>.</p>
<h3>Chained Transformations</h3>
<p>I'm gonna insist on the tween chaining feature a bit because when we run animations one after another we are kinda expecting a certain degree of continuity. As explained before, the best solution is the <code>.to()</code> method because it has the ability to <strong>stack</strong> properties found in the element's inline styling, mostly from previous tween animation, and use them as start values for the next tween. It also transfers unchanged values to values end for that same reason. OK now, let's see a side by side comparison with 3 elements:</p>
<h4>Chained Transformations</h4>
<p>KUTE.js has the ability to stack transform properties as they come in chained tweens because when we run animations one after another we are kinda expecting a certain degree of continuity. As explained before, the best solution is the <code>.to()</code> method because it has the ability to <strong>stack</strong> properties found in the element's inline styling, mostly from previous tween animation, and use them as start values for the next tween. It also transfers unchanged values to values end for that same reason. OK now, let's see a side by side comparison with 3 elements:</p>
<div id="chainedTweens" class="featurettes">
<div class="example-item example-box bg-gray" style="font-size: 30px">FROMTO</div>
<div class="example-item example-box bg-olive" style="font-size: 30px">FROMTO</div>
@ -208,40 +234,14 @@ var tween2 = KUTE.fromTo(
<li>2D and 3D translations would work best in if you provide a value at all times; eg. <code>translate:[x,y]</code> and <code>translate3d:[x,y,z]</code>; for instance using <code>translate:150</code> or <code>translateX:150</code> would mean that all other axis are 0;</li>
<li>on larger amount of elements animating chains, the <code>.fromTo()</code> method is fastest, so you will have more work, but can potentially minimize or eliminate any syncronization issues that may occur, as explained in the <a href="features.html">features page</a>;</li>
<li>download this example <a href='http://codepen.io/thednp/share/zip/PPWZRL/'>here</a>.</li>
</ul>
<h2>Border Radius</h2>
<p>In the example below we are doing some animation on the <code>border-radius</code> property. The first box animates all corners, while the other boxes animate each corner at a time. A quick reminder, for radius properties KUTE.js supports <code>px</code>, <code>%</code> and text properties' units such as <code>em</code> or <code>rem</code>.</p>
<pre><code class="language-javascript">KUTE.to('selector1',{borderRadius:'100%'}).start();
KUTE.to('selector2',{borderTopLeftRadius:'100%'}).start();
KUTE.to('selector3',{borderTopRightRadius:'100%'}).start();
KUTE.to('selector4',{borderBottomLeftRadius:'100%'}).start();
KUTE.to('selector5',{borderBottomRightRadius:'100%'}).start();
</code></pre>
<p>And here is how it looks like:</p>
<div class="featurettes">
<div data-property-border-radius="80" class="example-item example-box bg-red">ALL</div>
<div data-property-border-top-left-radius="150" class="example-item example-box bg-pink">TL</div>
<div data-property-border-top-right-radius="150" data-option-perspective="200" class="example-item example-box bg-olive">TR</div>
<div data-property-border-bottom-left-radius="150" class="example-item example-box bg-indigo">BL</div>
<div data-property-border-bottom-right-radius="150" class="example-item example-box bg-blue">BR</div>
<div class="example-buttons">
<a class="btn btn-green" href="#">Start</a>
</div>
</div>
<p>A quick important reminder here is that KUTE.js does not support shorthands for radius properties. Also early implementations by Mozilla's Firefox browser like <code>-moz-border-radius-topleft</code> are not supported because they were depracated with later versions. Download this example <a href='http://codepen.io/thednp/share/zip/VvpypW/'>here</a>.</p>
</ul>
<h2>Box Model Properties</h2>
<p>While KUTE.js supports almost all the box model properties, the next example will animate most common properties, we will focus mostly on size, spacing and position. Other properties such as <code>minWidth</code> or <code>maxHeight</code> require a more complex context and we won't insist on them.</p>
<h3>Box Model Properties</h3>
<p>KUTE.js core engine supports most used box model properties, and almost all the box model properties via the <a href="css.html">CSS Plugin</a>, so the next example will only animate <code>width</code>, <code>height</code>, <code>top</code> and <code>left</code>.</p>
<pre><code class="language-javascript">var tween1 = KUTE.to('selector1',{width:200});
var tween2 = KUTE.to('selector1',{height:300});
var tween3 = KUTE.to('selector1',{left:250});
var tween4 = KUTE.to('selector1',{top:100});
var tween5 = KUTE.to('selector1',{padding:'5%'});
</code></pre>
<p>We're gonna chain these tweens and start the animation. You can download this example <a href='http://codepen.io/thednp/share/zip/xwqYbX/'>here</a>.</p>
<div id="boxModel" class="featurettes">
@ -255,38 +255,16 @@ var tween5 = KUTE.to('selector1',{padding:'5%'});
<p>TIP: the <code>width</code> and <code>height</code> properties used together can be great for <code>scale</code> animation fallback on images for legacy browsers.</p>
<h2>Text Properties</h2>
<p>OK here we're gonna do a cool example for text properties. Basically the below code would work:</p>
<pre><code class="language-javascript">var tween1 = KUTE.to('selector1',{fontSize:'200%'});
var tween2 = KUTE.to('selector1',{line-height:24});
var tween3 = KUTE.to('selector1',{letter-spacing:50});
</code></pre>
<p>But our example will feature some more than just that. We're gonna animate each character of a given string, with a small delay. The heading will animate <code>fontSize</code> and <code>letterSpacing</code> properties for each character while the button will animate <code>fontSize</code> and <code>lineHeight</code> properties. Watch this:</p>
<div id="textProperties" class="featurettes" style="min-height: 150px">
<h1 class="example-item">Howdy!</h1>
<a href="javascript:void(0)" class="example-item btn btn-red">Button</a>
<div class="example-buttons">
<a class="btn btn-pink" href="javascript:void(0)">Start</a>
</div>
</div>
<p>TIP: this should also work in IE8 as a fallback for scale animation for text. It's not perfect, can be improved for sure, but if it's a must, this would do. Download this example <a href='http://codepen.io/thednp/share/zip/bVqLpb/'>here</a>.</p>
<h2>Color Properties</h2>
<p>The next example is about animating color properties. As for example, check these lines for reference.</p>
<pre><code class="language-javascript">KUTE.to('selector1',{color:'#069'}).start();
<h3>Color Properties</h3>
<p>The next example is about animating color properties. As for example, check these lines for reference. Additional color properties such as <code>borderColor</code> or <code>borderLeftColor</code> are supported via the <a href="css.html">CSS Plugin</a>.</p>
<pre><code class="language-javascript">KUTE.to('selector1',{color:'rgb(0,66,99)'}).start();
KUTE.to('selector1',{backgroundColor:'#069'}).start();
KUTE.to('selector1',{borderColor:'rgb(25,25,25)'}).start();
KUTE.to('selector1',{borderTopColor:'#069'}).start();
KUTE.to('selector1',{borderRightColor:'rgba(25,25,25,0.25)'}).start();
KUTE.to('selector1',{borderBottomColor:'#069'}).start();
KUTE.to('selector1',{borderLeftColor:'#069'}).start();
KUTE.to('selector1',{backgroundColor:'turquoise'}).start(); // IE9+ only
</code></pre>
<p>Let's get some animation going. Download the example <a href='http://codepen.io/thednp/share/zip/OypvNR/'>here</a>.</p>
<div id="colBox" class="featurettes">
<div class="example-item example-box bg-olive" style="width: 135px; height: 135px; border:15px solid #9C27B0; line-height: 105px; font-size:30px">Colors</div>
<div class="example-item example-box bg-olive">Colors</div>
<div class="example-buttons">
<a class="btn btn-blue" href="#">Start</a>
@ -294,36 +272,8 @@ KUTE.to('selector1',{borderLeftColor:'#069'}).start();
</div>
<p>A quick reminder: you can also use <code>RGB</code> or <code>RGBA</code>, but the last one is not supported on IE8 and it will fallback to <code>RGB</code>.</p>
<h2>Clip Property</h2>
<p>This property allows you to animate the rectangular shape of an element that is set to <code>position:absolute</code>. In CSS this property works like this <code>clip: rect(top,right,bottom,left)</code> forming a rectangular shape that masks an element making parts of it invisible.</p>
<pre><code class="language-javascript">KUTE.to('selector',{clip:[0,150,100,0]}).start();</code></pre>
<p>A quick example here could look like this:</p>
<div id="clip" class="featurettes" style="min-height: 190px">
<div class="example-item example-box bg-red" style="position: absolute; background: url('http://img.dummy-image-generator.com/people/dummy-250x250-Eye.jpg') center center no-repeat;"></div>
<div class="example-buttons">
<a class="btn btn-olive" href="#">Start</a>
</div>
</div>
<p><strong>Note</strong> that this would produce no effect for elements that have <code>overflow:visible</code> style rule. Download this example <a href='http://codepen.io/thednp/pen/NGpYmM/'>here</a>.</p>
<h2>Background Position</h2>
<p>Another property we can animate with KUTE.js is <code>backgroundPosition</code>. Quick example:</p>
<pre><code class="language-javascript">KUTE.to('selector1',{backgroundPosition:[0,50]}).start();</code></pre>
<p>A working example would look like this:</p>
<div id="bgPos" class="featurettes">
<div class="example-item example-box" style="background: url('http://img.dummy-image-generator.com/abstract/dummy-400x300-Rope.jpg') center center no-repeat;"></div>
<div class="example-buttons">
<a class="btn btn-lime" href="#">Start</a>
</div>
</div>
<p>Download this example <a href='http://codepen.io/thednp/share/zip/EVWEwJ/'>here</a>.</p>
<h2>Vertical Scrolling</h2>
<h3>Vertical Scrolling</h3>
<p>Another property we can animate with KUTE.js is <code>scrollTop</code>. I works for both the window and any scrollable object. Quick example:</p>
<pre><code class="language-javascript">KUTE.to('selector',{scroll:450}).start(); // for a scrollable element
KUTE.to('window',{scroll:450}).start(); // for the window
@ -331,10 +281,10 @@ KUTE.to('window',{scroll:450}).start(); // for the window
<p>A working example would work like <a href="http://codepen.io/thednp/pen/bVqKmp/" target="_blank">this</a>. Scroll works with IE8+ and is a unitless property even if these scroll distances are measured in pixels.</p>
<h2 id="crossbrowser">Cross Browser Animation Example</h2>
<h3 id="crossbrowser">Cross Browser Animation Example</h3>
<p>Unlike the examples <a href="http://codepen.io/thednp/pens/public/" target="_blank">hosted on Codepen</a>, most examples here should be supported on legacy browsers. The next example is going to explain more details about how to target browsers according to their supported properties, so stick around. So, if your target audience uses legacy browsers in a significant percent, check to have the proper polyfills and also make sure you target your browsers, here's a <a href="http://browserhacks.com/" target="_blank">complete reference</a>. Now we are ready:</li>
</ul>
<h3>Collect Information And Cache It</h3>
<h4>Collect Information And Cache It</h4>
<pre><code class="language-javascript">// grab an HTML element to build a tween object for it
var element = document.getElementById("myElement");
@ -348,7 +298,7 @@ var isIE9 = isIE === 9;
// you include all you need for your target audience
</code></pre>
<h3>Define Properties And Options Objects</h3>
<h4>Define Properties And Options Objects</h4>
<pre><code class="language-javascript">// create values and options objects
var startValues = {};
var endValues = {};
@ -390,7 +340,7 @@ options.yoyo = true;
options.repeat = 1;
</code></pre>
<h3>Build Tween Object And Tween Controls</h3>
<h4>Build Tween Object And Tween Controls</h4>
<pre><code class="language-javascript">// the cached object
var myTween = KUTE.fromTo(element, startValues, endValues, options);
@ -418,7 +368,7 @@ playPauseButton.addEventListener('click', function(e){
}
}, false);
</code></pre>
<h3>Live Demo</h3>
<h4>Live Demo</h4>
<div class="featurettes" id="crossBrowser">
<div id="myElement" class="example-item example-box bg-yellow">
@ -438,8 +388,8 @@ playPauseButton.addEventListener('click', function(e){
<li>make sure you work with the conditions properly when you want to pause an animation you MUST check both <code>!myTween.playing</code> and <code>myTween.paused</code> conditions because you could end up with errors.</li>
</ul>
<h2>Tween Object Collections</h2>
<p>With KUTE.js 1.0.1 we introduced new tween object constructor methods, they allow you to create a tween object for each element in a collection, a very handy way to ease and speed up the animation programing workflow. Let's have a little fun.</p>
<h3>Tween Object Collections</h3>
<p>With KUTE.js 1.5.0 new tween object constructor methods were introduced, and they allow you to create a tween object for each element in a collection, a very handy way to ease and speed up the animation programing workflow. Let's have a little fun.</p>
<pre><code class="language-javascript">// a simple .to() for a collection of elements would look like this
var myMultiTween1 = KUTE.allTo('selector1',{translate:[0,150]});
@ -450,7 +400,6 @@ var myMultiTween2 = KUTE.allFromTo(
{translate:[0,150], rotate: 360},
{transformOrigin: '10% 10%', offset: 200 }
);
</code></pre>
<p>And should looks like this:</p>
<div class="featurettes">
@ -460,7 +409,7 @@ var myMultiTween2 = KUTE.allFromTo(
<div class="example-item example-box example-multi bg-red">E</div>
<div class="example-buttons">
<a class="btn btn-green" onclick="startMultiTween();" href="#">Start</a>
<a class="btn btn-green" onclick="startMultiTween();" href="javascript:void(0)">Start</a>
</div>
</div>
<p>As you can see, we also used the new tween options <code>offset</code> and <code>transformOrigin</code> and they make it so much more easy.</p>
@ -469,14 +418,106 @@ var myMultiTween2 = KUTE.allFromTo(
<li class="hidden-xs"><a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Facebook"><span class="ion-social-facebook-outline icon"></span></a></li>
<li class="hidden-xs"><a target="_blank" href="https://twitter.com/home?status=Spread the word about @kute.js animation engine by @thednp and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter"><span class="icon ion-social-twitter-outline"></span></a></a></li>
<li class="hidden-xs"><a target="_blank" href="https://plus.google.com/share?url=http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Google+"><span class="icon ion-social-googleplus-outline"></span></a></li>
</ul>
</ul>
<h3>Easing Functions</h3>
<p>We've talked about KUTE.js featuring many easing functions, so let's go ahead and create some examples. The first box below will animate with <code>linear</code> easing function and the second will use another function you choose. The example also features some predefined easing functions from the additional plugins: cubic bezier easing and physics based easing functions.</p>
<div class="featurettes">
<div class="example-item easing-example example-box bg-green">Linear</div>
<div class="example-item easing-example example-box bg-pink"></div>
<div class="example-buttons">
<div class="btn-group">
<a id="easingSelectButton" class="btn btn-red" data-function="toggle" href="#">Select</a>
<ul id="easings">
<li class="titlef">Core Functions</li>
<li>easingSinusoidalIn</li>
<li>easingSinusoidalOut</li>
<li>easingSinusoidalInOut</li>
<li>easingQuadraticIn</li>
<li>easingQuadraticOut</li>
<li>easingQuadraticInOut</li>
<li>easingCubicIn</li>
<li>easingCubicOut</li>
<li>easingCubicInOut</li>
<li>easingQuarticIn</li>
<li>easingQuarticOut</li>
<li>easingQuarticInOut</li>
<li>easingQuinticIn</li>
<li>easingQuinticOut</li>
<li>easingQuinticInOut</li>
<li>easingCircularIn</li>
<li>easingCircularOut</li>
<li>easingCircularInOut</li>
<li>easingExponentialIn</li>
<li>easingExponentialOut</li>
<li>easingExponentialInOut</li>
<li>easingBackIn</li>
<li>easingBackOut</li>
<li>easingBackInOut</li>
<li>easingElasticIn</li>
<li>easingElasticOut</li>
<li>easingElasticInOut</li>
<li class="titlef">Bezier Functions</li>
<li>bezier(0.15, 0.7, 0.2, 0.9)</li>
<li>bezier(0.25, 0.5, 0.6, 0.7)</li>
<li>bezier(0.35, 0.2, 0.9, 0.2)</li>
<li>easeIn</li>
<li>easeOut</li>
<li>easeInOut</li>
<li>easeInSine</li>
<li>easeOutSine</li>
<li>easeInOutSine</li>
<li>easeInQuad</li>
<li>easeOutQuad</li>
<li>easeInOutQuad</li>
<li>easeInCubic</li>
<li>easeOutCubic</li>
<li>easeInOutCubic</li>
<li>easeInQuart</li>
<li>easeOutQuart</li>
<li>easeInOutQuart</li>
<li>easeInQuint</li>
<li>easeOutQuint</li>
<li>easeInOutQuint</li>
<li>easeInExpo</li>
<li>easeOutExpo</li>
<li>easeInOutExpo</li>
<li>easeInCirc</li>
<li>easeOutCirc</li>
<li>easeInOutCirc</li>
<li>easeInBack</li>
<li>easeOutBack</li>
<li>easeInOutBack</li>
<li>slowMo</li>
<li>slowMo1</li>
<li>slowMo2</li>
<li class="titlef">Physics Functions</li>
<li>physicsIn</li>
<li>physicsOut</li>
<li>physicsInOut</li>
<li>physicsBackIn</li>
<li>physicsBackOut</li>
<li>physicsBackInOut</li>
<li>spring</li>
<li>bounce</li>
<li>gravity</li>
<li>forceWithGravity</li>
<li>bezier</li>
<li>multiPointBezier</li>
</ul>
</div>
<a id="startEasingTween" class="btn btn-blue" href="#">Start</a>
</div>
</div>
<p>As you can see, the cubic-bezier easing functions can be used with both presets and as well as strings such as <code>bezier(0.15, 0.7, 0.2, 0.9)</code>. The physics based easing functions have their own presets, but the last 6 are all the examples shown in the <a href="easing.html">API documentation</a>, so make sure to check.</p>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2007 - 2015 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
<p>&copy; 2007 - 2016 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
</div>
</footer>
@ -492,7 +533,9 @@ var myMultiTween2 = KUTE.allFromTo(
<script src="./assets/js/prism.js" type="text/javascript"></script>
<!--<script src="http://cdn.jsdelivr.net/kute.js/0.9.2/kute.full.min.js"></script> KUTE CDN -->
<script src="./src/kute.js"></script> <!-- some stuff -->
<script src="./src/kute.js"></script> <!-- KUTE.js core -->
<script src="./src/kute-bezier.js"></script> <!-- KUTE.js Bezier Easing -->
<script src="./src/kute-physics.js"></script> <!-- KUTE.js Physics Easing -->
<script src="./assets/js/scripts.js"></script> <!-- global scripts stuff -->
<script src="./assets/js/examples.js"></script> <!-- examples stuff -->
</body>

View file

@ -9,7 +9,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="KUTE.js is a minimal Javascript animation engine">
<meta name="description" content="The KUTE.js features overview.">
<meta name="keywords" content="kute,kute.js,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.png"> <!-- TO DO -->
@ -25,6 +25,9 @@
<!-- Ion Icons -->
<link type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
<!-- Polyfill -->
<script src="./assets/js/minifill.js"> </script>
<!-- legacy browsers support via polyfill
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,getComputedStyle|gated"> </script> -->
<!--[if IE]>
@ -43,16 +46,38 @@
<div class="content-wrap">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<ul class="nav">
<li class="active"><a href="features.html">Features</a></li>
<li><a href="examples.html">Examples</a></li>
<li><a href="api.html">API</a></li>
<li class="btn-group active"><a href="#" data-function="toggle">Features <span class="caret"></span></a>
<ul class="subnav">
<li class="active"><a href="features.html">Feature Overview</a></li>
<li><a href="properties.html">Supported Properties</a></li>
</ul>
</li>
<li class="btn-group">
<a href="#" data-function="toggle">Examples <span class="caret"></span></a>
<ul class="subnav">
<li><a href="examples.html">Core Engine</a></li>
<li><a href="css.html">CSS Plugin </a></li>
<li><a href="svg.html">SVG Plugin </a></li>
<li><a href="attr.html">Attributes Plugin </a></li>
</ul>
</li>
<li class="btn-group">
<a href="#" data-function="toggle">API <span class="caret"></span></a>
<ul class="subnav">
<li><a href="start.html">Getting Started</a></li>
<li><a href="api.html">Public Methods</a></li>
<li><a href="easing.html">Easing Functions</a></li>
<li><a href="extend.html">Extend Guide</a></li>
</ul>
</li>
<li><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div class="content-wrap">
<h2 id="performance">Badass Performance</h2>
<h2>Features Overview</h2>
<h3 id="performance">Badass Performance</h3>
<p>KUTE.js was developed with best practices in mind for <strong>fastest code execution</strong> and <strong>memory efficiency</strong>, but performance varies from case to case, as well as for all the other Javascript based animation engines. As a quick note on <a href="about.html#how">how it works</a>, well for the most part values are cached for the entire duration of the animation so that the repetitive tasks run smoothly, uninterruptible and avoid layout thrashing. We all know the more properties used or the more elements to animate at the same time, the more power is required.</p>
<p><span class="ion-ios-cog media"></span>Of course some would argue on many aspects, but we all trade something for the sake of something else, such as convenience and/or flexibility or fork a project that's already great to make it.. better. For the sake of performance or simply willing to provide a feature, some trade/neglect other elements such as syncronisation (check this <a href="https://www.youtube.com/watch?v=1ZWugkJV5Ks" target="_blank">video</a>), code simplicity (lots of CSS for a <a href="https://daneden.github.io/animate.css/" target="_blank">custom animation</a>) and more other.</p>
@ -60,24 +85,31 @@
</div>
<div class="content-wrap">
<h2 id="prefix">Browser Prefixes Free</h2>
<h3 id="extensible">Extensible Prototype</h3>
<p>KUTE.js already packs quite alot of features, and that is thanks to its flexible nature that allows you to easily extend to your heart's desire. Whether you like to extend with CSS properties, easing functions, HTML presentation attributes or anything that Javascript can touch, even if it's not possible with CSS transitions or other Javascript libraries, KUTE.js makes it super easy. </p>
<p>For instance if you want to be able to animate the <code>filter</code> property, you only need three functions: one for preparing the property values needed for tween object build-up, a second function to read current value and the last one for the DOM update callback, everything else is nicely taken care of. KUTE.js also provides very useful utilities for processing strings, HEX/RGBA colors and other tools you can use for your own plugin's processing.</p>
<p>You may want to head over to the <a href="extend.html">extend</a> page for an indepth guide on how to write your own plugin/extension.</p>
</div>
<div class="content-wrap">
<h3 id="prefix">Auto Browser Prefix</h3>
<p>KUTE.js uses a simple function to determine the vendor prefix and checks if the prefix is required. In any case it caches the prefixed/unprefixed property name in a variable to make it available when needed. This applies to the following CSS3 properties: <code>transform</code>, <code>perspective</code>, <code>perspective-origin</code>, <code>border-radius</code> and the <code>requestAnimationFrame</code> Javascript method.</p>
<p><span class="ion-paper-airplane media"></span>We aren't only targeting properly browsers for CSS3 styling, but also increase performance because we don't need to update the styling on every frame for all browsers (and their versions) at once, just the right and only one; <strong>less</strong> string concatenation = <strong>more</strong> performance. This asumes you are NOT styling the above CSS3 properties using your stylesheets to avoid glitches with legacy browsers.</p>
<p>This feature is useful mostly for Safari, older Firefox and Opera versions and Internet Explorer 9.</p>
</div>
<div class="content-wrap">
<h2 id="compatibiity">Browser Compatibility</h2>
<p>KUTE.js covers all <strong>modern</strong> browsers but also provides fallback options for legacy browsers. The <strong>prefix free</strong> feature mentioned above is one way to enable smooth Javascript based animations on older versions Gecko/Webkit/IE browsers for <code>transform</code> and <code>border-radius</code>. Generally, KUTE.js is built around most used properties, so I highly recommend checking the <a href="http://caniuse.com" target="_blank">can I use</a> website for a very detailed properties support list on many browsers and versions. For instance legacy browsers may support <a href="http://caniuse.com/#feat=transforms2d">2D transforms</a> or <a href="http://caniuse.com/#feat=transforms3d">3D transforms</a> so make sure you know what browsers support and <a href="http://browserhacks.com/" target="_blank">how to target them</a> before you get to work with a complete browser supported animation setup.</p>
<h3 id="compatibility">Browser Compatibility</h3>
<p>KUTE.js covers all <strong>modern</strong> browsers but also provides fallback options for legacy browsers. The <strong>prefix free</strong> feature mentioned above is one way to enable smooth Javascript based animations on older versions Gecko/Webkit/IE browsers for <code>transform</code> and <code>border-radius</code>. Generally, KUTE.js is built around most used properties, so I highly recommend checking the <a href="http://caniuse.com" target="_blank">can I use</a> website for a very detailed properties support list on many browsers and versions. For instance, some legacy browsers may support <a href="http://caniuse.com/#feat=transforms2d">2D transforms</a> or <a href="http://caniuse.com/#feat=transforms3d">3D transforms</a> so make sure you know what browsers support and <a href="http://browserhacks.com/" target="_blank">how to target them</a> before you get to work with a complete browser supported animation setup.</p>
<p><span class="ion-android-globe media"></span>I've put a lot of work in making KUTE.js work with all Internet Explorer versions starting with IE8 and it really works with the help of <a href="https://polyfill.io/" target="_blank">polyfills</a> and the appropriate code to detect them. All you need to do is to let the browser breathe, espectially IE8 needs to have resize handlers as minimal as possible. On the other side, IE9 really shines with 2D transforms animation, something that's impossible with CSS <code>transition</code>.</p>
<p>Speaking of polyfills, KUTE.js requires <code>window.requestAnimationFrame()</code> for the main thread, <code>window.performance.now()</code> for checking the current time, <code>.indexOf()</code> for array checks, <code>window.getComputedStyle()</code> for the <code>.to()</code> method and <code>.addEventListener()</code> for scroll. Unlike other developers I didn't include these polyfills in the code to keep it clean, so that YOU decide whether your project need them or not. Also know that when using the recommended <a href="https://polyfill.io/"target="_blank">polyfill service</a> some <strong>browser detection will not work</strong> because they fill the gap and your code won't work as expected. For instance this would check for IE8 browser <code>var isIE = document.all && !document.addEventListener;</code> but the polyfill covers <code>.addEventListener()</code> so you will never succeed. The provided <strong>ideal HTML template</strong> is the best solution for targeting Microsoft's legacy browsers.</p>
<p>Speaking of polyfills, KUTE.js no longer requires <code>window.requestAnimationFrame()</code> for the main thread, but it does require the <code>window.performance.now()</code> for checking the current time, <code>.indexOf()</code> for array/string checks, <code>window.getComputedStyle()</code> for the <code>.to()</code> method and <code>.addEventListener()</code> for scroll animation. Unlike other developers I didn't include these polyfills in the code to keep it clean, so that YOU decide whether your project need them or not. Also know that when using the recommended <a href="https://polyfill.io/"target="_blank">polyfill service</a> some <strong>browser detection will not work</strong> because they fill the gap and your code won't work as expected. For instance this would check for IE8 browser <code>var isIE = document.all && !document.addEventListener;</code> but the polyfill covers <code>.addEventListener()</code> so you will never succeed. This very demo is a great solution for targeting Microsoft's legacy browsers.</p>
<p>As of Safari, we did some tests there too, KUTE.js does it really well.</p>
</div>
<div class="content-wrap">
<h2 id="methods">Methods, Tools and Options</h2>
<h3>Building Tween Objects</h3>
<p>KUTE.js allows you to create tween objects with the help of <code>.to()</code> and <code>.fromTo()</code> public methods for a single element, with distinctive functionalities, and the other <code>.allTo()</code> and <code>.allFromTo()</code> that use the first two for collections of elements.</p>
<h3 id="methods">Methods, Tools and Options</h3>
<h4>Building Tween Objects</h4>
<p>KUTE.js allows you to create tween objects with the help of <code>.to()</code> and <code>.fromTo()</code> methods for a single element, with distinctive functionalities, and the other <code>.allTo()</code> and <code>.allFromTo()</code> that use the first two for collections of elements.</p>
<p><kbd>KUTE.to('selector', toValues, options)</kbd> method is super simple and straightforward and requires a polyfill for <code>window.getComputedStyle()</code> Javascript method on IE8 and more other legacy browsers in order to read the current property value. If no value is set in the stylesheets or inline style, a property specific value will be used. It also computes the value on animation start, delaying the actual animation and potentially creating sync issues on large amounts of elements, but it has the great ability to stack <code>transform</code> properties as they come in chained tweens. However fixing the sync issues is not that hard, see the example at <a href="api.html#start">start()</a> method API.</p>
@ -85,109 +117,25 @@
<p>It doesn't stack <code>transform</code> properties for chained tweens but you can set all properties to be used in all tweens if you want (end values from previous tween become start values for the next AND unchanged start values become end values), and make sure nothing is left unchecked, to avoid animation glitches. Still, this method is the fastest and bestest for super performance and super control.</p>
<p><kbd>KUTE.allTo('selector', toValues, options)</kbd> inherits all functionality from the <code>.to()</code> method but is applied to collections of elements.</p>
<p><kbd>KUTE.allFromTo('selector', fromValues, toValues, options)</kbd> is the same as <code>.fromTo()</code> and is applied to collections of elements.</p>
<p><kbd>KUTE.allTo('selector', toValues, options)</kbd> and <kbd>KUTE.allFromTo('selector', fromValues, toValues, options)</kbd> inherit all functionality from the <code>.to()</code> and <code>.fromTo()</code> method respectively, but they apply to collections of elements. Unlike the first two methods that create single element tween objects, these two create collections of tween objects. Be sure to check the <a href="api.html">API</a> documentation on all the methods.</p>
<h3>Tween Control</h3>
<p>Unlike previous versions where animations started right away, starting with version 0.9.5 KUTE.js gives you great animation control methods such as: <code>.start()</code>, <code>.stop()</code>, <code>.pause()</code> and <code>.resume()</code>. These public methods work either when animation is running or is paused. You need to see the <a href="api.html">documentation</a> to learn how these work.</p>
<h4>Tween Control</h4>
<p>Unlike previous versions where animations started right away, starting with version 0.9.5 KUTE.js gives you great animation control methods such as: <code>.start()</code>, <code>.stop()</code>, <code>.pause()</code> and <code>.resume()</code>. These public methods work either when animation is not running, running or is paused. You need to see the <a href="api.html">documentation</a> to learn how these work.</p>
<h3>Tween Options</h3>
<h4>Tween Options</h4>
<p>Aside from the usual options such as duration, delay, easing, repeat or yoyo, it also comes with specific tween options for <code>transform</code>. For instance 3D rotations require a <code>perspective</code> or a <code>perspective-origin</code>, right?</p>
<h3>Callback System</h3>
<h4>Callback System</h4>
<p>Another important KUTE.js feature is the solid callback system. This allows you to schedule functions to run on animation start, on each frame, on pause / resume, on stop and on complete. The functions bound at start or resume will delay the animation, while the functions running on each frame can potentially influence performance on large amounts of elements so you must use them wisely.</p>
<h3>Addons</h3>
<p>KUTE.js sports some fine tuned addons: jQuery Plugin, cubic bezier easing functions and also physics based easing functions. I am also considering to feature an attributes plugin as well as SVG library and maybe other tools in the future.</p>
<h4>Addons</h4>
<p>KUTE.js sports some fine tuned addons: jQuery Plugin, cubic bezier easing functions and also physics based easing functions. It also features an attributes plugin as well as a SVG plugin for various awesome stuff, but I'm open for more features in the future.</p>
<p>Check the <a href="api.html">documentation</a> on these methods and the <a href="examples.html">examples page</a> for more.</p>
</div>
<div class="content-wrap">
<h2>Support For Plenty Of Properties</h2>
<p>KUTE.js covers all animation needs such as most <code>transform</code> properties, <code>scroll</code> for window or a given element, colors, <code>border-radius</code>, and almost the full box model. Due to it's modular coding, KUTE.js is very flexible and makes it very easy to add support for more properties, but I'm considering removing unnecessary properties in the future (mostly from the box model category). Note: not all browsers support <a href="http://caniuse.com/#feat=transforms2d" target="_blank">2D transforms</a> or <a href="http://caniuse.com/#feat=transforms3d" target="_blank">3D transforms</a>.</p>
<p>All common measurement units are supported: <code>px</code> and <code>%</code> for translations and box-model properties, or <code>deg</code> and <code>rad</code> for rotations and skews, while <code>clip</code> only supports <code>px</code>. Other properties such as <code>opacity</code>, <code>scale</code> or <code>scroll</code> are unitless, and <code>background-position</code> always uses <code>%</code> as measurement unit. As for the text properties you can use <code>px</code>, <code>em</code>, <code>rem</code>, <code>vh</code> and <code>vw</code>. Be sure to <a href="http://caniuse.com/#feat=viewport-units" target="_blank">check</a> what your browsers support in terms of measurement unit.</p>
<h3>Opacity</h3>
<p>In most cases, the best animation possible is the <code>opacity</code>, for performance, aesthetics and maybe more other reasons such as avoiding unwanted layout changes. KUTE.js also covers IE8 here with the help of proprietary synthax <code>filter: alpha(opacity=0)</code> but requires that you use the provided HTML template in order to detect the browser. Also, opacity can be used for instance on legacy browsers that don't support <code>RGBA</code> colors. Eg. <code>opacity:0.5</code> will make an element semitransparent.</p>
<h3>2D Transform Properties</h3>
<ul>
<li><kbd>translate</kbd> property can be used for horizontal and / or vertical movement. EG. <code>translate:150</code> to translate an element 150px to the right or <code>translate:[-150,200]</code> to move the element to the left by 150px and to bottom by 200px. Supported on IE9.</li>
<li><kbd>rotate</kbd> is a property used to rotate an element on the Z axis or the plain document. Eg. <code>rotate:250</code> will rotate an element clockwise by 250 degrees. Supported on IE9.</li>
<li><kbd>skewX</kbd> is a property used to apply a skew transformation on the X axis. Eg. <code>skewX:25</code> will skew an element by 25 degrees. Supported on IE9.</li>
<li><kbd>skewY</kbd> is a property used to apply a skew transformation on the Y axis. Eg. <code>skewY:25</code> will skew an element by 25 degrees. Supported on IE9.</li>
<li><kbd>scale</kbd> is a property used to apply a size transformation. Eg. <code>scale:2</code> will enlarge an element by a degree of 2. Supported on IE9.</li>
<li><kbd>matrix</kbd> property is not supported.</li>
</ul>
<h3>3D Transform Properties</h3>
<ul>
<li><kbd>translateX</kbd> property is for horizontal movement. EG. <code>translateX:150</code> to translate an element 150px to the right. Modern browsers only.</li>
<li><kbd>translateY</kbd> property is for vertical movement. EG. <code>translateY:-250</code> to translate an element 250px towards the top. Modern browsers only.</li>
<li><kbd>translateZ</kbd> property is for movement on the Z axis in a given 3D field. EG. <code>translateZ:-250</code> to translate an element 250px to it's back, making it smaller. Modern browsers only and requires a <code>perspective</code> tween option to be used; the smaller perspective value, the deeper translation.</li>
<li><kbd>translate3d</kbd> property is for movement on all the axis in a given 3D field. EG. <code>translate3d:[-150,200,150]</code> to translate an element 150px to the left, 200px to the bottom and 150px closer to the viewer, making it larger. Modern browsers only and also requires using a <code>perspective</code> tween option.</li>
<li><kbd>rotateX</kbd> property rotates an element on the X axis in a given 3D field. Eg. <code>rotateX:250</code> will rotate an element clockwise by 250 degrees. Modern browsers only and requires perspective.</li>
<li><kbd>rotateY</kbd> property rotates an element on the Y axis in a given 3D field. Eg. <code>rotateY:-150</code> will rotate an element counter-clockwise by 150 degrees. Modern browsers only and also requires perspective.</li>
<li><kbd>rotateZ</kbd> property rotates an element on the Z axis and is the equivalent of the 2D rotation. Eg. <code>rotateZ:-150</code> will rotate an element counter-clockwise by 150 degrees. Modern browsers only and doesn't require perspective.</li>
<li><kbd>rotate3d</kbd> and <kbd>matrix3d</kbd> properties are not supported.</li>
</ul>
<h3>Box Model Properties</h3>
<ul>
<li><kbd>left</kbd>, <kbd>top</kbd>, <kbd>right</kbd> and <kbd>bottom</kbd> are <code>position</code> based properties for movement on vertical and / or horizontal axis. These properties require that the element to animate uses <code>position: absolute/relative</code> styling as well as it's parent element requires <code>position:relative</code>. These properties can be used as fallback for browsers with no support for <code>translate</code> properties such as IE8.</li>
<li><kbd>width</kbd>, <kbd>height</kbd>, <kbd>minWidth</kbd>, <kbd>minHeight</kbd>, <kbd>maxWidth</kbd>, <kbd>maxHeight</kbd> are properties that allow you to animate the size of an element on horizontal and / or vertical axis. These properties can be used on images as fallback for <code>scale</code> on IE8 again, as well as for other purposes.</li>
<li><kbd>padding</kbd>, <kbd>margin</kbd>, <kbd>paddingTop</kbd>, <kbd>paddingBottom</kbd>, <kbd>paddingLeft</kbd>, <kbd>paddingRight</kbd>, <kbd>marginTop</kbd>, <kbd>marginBottom</kbd>, <kbd>marginLeft</kbd> and <kbd>marginRight</kbd> are properties that allow you to animate the spacing of an element inside (via padding) and outside (via margin). Shorthand notations such as <code>margin: "20px 50px"</code> or any other type are not supported.</li>
<li><kbd>borderWidth</kbd>, <kbd>borderTopWidth</kbd>, <kbd>borderRightWidth</kbd>, <kbd>borderBottomWidth</kbd> are <kbd>borderLeftWidth</kbd> are properties that allow you to animate the border of an element either on all sides at once or each side separatelly. Shorthand notations are not supported.</li>
</ul>
<p><strong>Remember</strong>: these properties are <strong>layout modifiers</strong> that may force repaint of the entire DOM, drastically affecting performance on lower end and mobile devices. They also trigger <code>resize</code> event that may cause crashes on old browsers such as IE8 when using handlers bound on <code>resize</code>, so use with caution.</p>
<h3>Border Radius</h3>
<ul>
<li><kbd>borderRadius</kbd> allows you to animate the <code>border-radius</code> on all corners for a given element.</li>
<li><kbd>borderTopLeftRadius</kbd> allows you to animate the <code>border-top-left-radius</code> for a given element.</li>
<li><kbd>borderTopRightRadius</kbd> allows you to animate the <code>border-top-right-radius</code> for a given element.</li>
<li><kbd>borderBottomLeftRadius</kbd> allows you to animate the <code>border-bottom-left-radius</code>for a given element.</li>
<li><kbd>borderBottomRightRadius</kbd> allows you to animate the <code>border-bottom-right-radius</code>for a given element.</li>
</ul>
<p>For all radius properties above <code>borderRadius:20</code> or <code>borderTopLeftRadius:'25%'</code> will do. In the first case <code>px</code> is the default measurement unit used, while in the second we require using <code>%</code> unit which is relative to the element's size.</p>
<p><strong>Remember</strong>: shorthands for <code>border-radius</code> are not supported. Also KUTE.js does not cover early implementations by Mozilla Firefox (Eg. <code>-moz-border-radius-topleft</code>) as they were deprecated with later versions.</p>
<h3>Color Properties</h3>
<p>KUTE.js currently supports values such as <code>HEX</code>, <code>RGB</code> and <code>RGBA</code> for all color properties, but IE8 does not support <code>RGBA</code> and always uses <code>RGB</code> when detected, otherwise will produce no effect. There is also a tween option <code>keepHex:true</code> to convert the color format. Eg. <code>color: '#ff0000'</code> or <code>backgroundColor: 'rgb(202,150,20)'</code> or <code>borderColor: 'rgba(250,100,20,0.5)'</code></p>
<ul>
<li><kbd>color</kbd> allows you to animate the color for a given text element.</li>
<li><kbd>backgroundColor</kbd> allows you to animate the <code>background-color</code> for a given element.</li>
<li><kbd>borderColor</kbd> allows you to animate the <code>border-color</code> on all sides for a given element.</li>
<li><kbd>borderTopColor</kbd>, <kbd>borderRightColor</kbd>, <kbd>borderBottomColor</kbd> and <kbd>borderLeftColor</kbd> properties allow you to animate the color of the border on each side of a given element.</li>
</ul>
<p><strong>Remember</strong>: shorthands for <code>border-color</code> property as well as web color names (Eg. red, green, olive, etc.) are not supported.</p>
<h3>Text Properties</h3>
<p> These properties can be combinated with each other when applied to text elements (paragraphs, headings) as animation fallback for <code>scale</code> on browsers that don't support <code>transform</code> at all. Yes, IE8 and other legacy browsers.</p>
<ul>
<li><kbd>fontSize</kbd> allows you to animate the <code>font-size</code> for a given element.</li>
<li><kbd>lineHeight</kbd> allows you to animate the <code>line-height</code> for a given element.</li>
<li><kbd>letterSpacing</kbd> allows you to animate the <code>letter-spacing</code> for a given element.</li>
</ul>
<p><strong>Remember</strong>: these properties are also <strong>layout modifiers</strong>.</p>
<h3>Scroll Animation</h3>
<p>KUTE.js currently supports only vertical scroll for both the window and a given element that's scrollable. Both <code>scroll: 150</code> or <code>scrollTop: 150</code> notations will do. When animating scroll, KUTE.js will disable all scroll and swipe handlers to prevent animation bubbles.</p>
<h3>Other properties</h3>
<ul>
<li><kbd>clip</kbd> allows you to animate the <code>clip</code> property for a given element. Only rect is supported. Eg. <code>clip:[250,200,300,0]</code>. See <a href="http://www.w3.org/TR/CSS2/visufx.html#propdef-clip" target="_blank">spec</a> for details.</li>
<li><kbd>backgroundPosition</kbd> allows you to animate the <code>background-position</code> for a given element that uses a background image. It only uses % as measurement unit. Eg. <code>backgroundPosition:[50,20]</code></li>
</ul>
<h3>Did We Miss Any Important Property?</h3>
<p>Make sure you go to <a href="https://github.com/thednp/kute.js/issues" target="_blank">the issues tracker</a> and report the missing property ASAP.</p>
</div>
<div class="content-wrap">
<h2>Developer Friendly</h2>
<h3>Developer Friendly</h3>
<p><span class="ion-happy media"></span>You can develop with KUTE.js for free thanks to the <a href="https://github.com/thednp/kute.js/blob/master/LICENSE" target="_blank">MIT License</a> terms. The terms in short allow you to use the script <strong>for free</strong> in both <strong>personal</strong> and <strong>commercial application</strong> as long as you give <strong>proper credits</strong> to the original author. Also a link back would be appreciated.</p>
<p>Also KUTE.js is <a href="api.html">super documented</a>, all features and options are showcased with detailed <a href="examples.html">examples</a> so you can get your hands really dirty.</p>
@ -203,7 +151,7 @@
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2007 - 2015 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
<p>&copy; 2007 - 2016 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
</div>
</footer>
@ -217,7 +165,7 @@
<!--<script src="http://cdn.jsdelivr.net/kute.js/0.9.2/kute.full.min.js"></script> KUTE CDN -->
<script src="./src/kute.js"></script> <!-- some stuff -->
<script src="./src/kute.js"></script> <!-- KUTE.js core -->
<script src="./assets/js/scripts.js"></script> <!-- some stuff -->
</body>
</html>

View file

@ -24,7 +24,10 @@
<!-- Ion Icons -->
<link type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
<!-- Polyfill -->
<script src="./assets/js/minifill.js"> </script>
<!-- legacy browsers support via polyfill
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,getComputedStyle|gated"> </script> -->
<!--[if IE]>
@ -43,9 +46,30 @@
<div class="content-wrap">
<a href="index.html"><h1 class="active">KUTE.<span>js</span></h1></a>
<ul class="nav">
<li><a href="features.html">Features</a></li>
<li><a href="examples.html">Examples</a></li>
<li><a href="api.html">API</a></li>
<li class="btn-group"><a href="#" data-function="toggle">Features <span class="caret"></span></a>
<ul class="subnav">
<li><a href="features.html">Feature Overview</a></li>
<li><a href="properties.html">Supported Properties</a></li>
</ul>
</li>
<li class="btn-group">
<a href="#" data-function="toggle">Examples <span class="caret"></span></a>
<ul class="subnav">
<li><a href="examples.html">Core Engine</a></li>
<li><a href="css.html">CSS Plugin </a></li>
<li><a href="svg.html">SVG Plugin </a></li>
<li><a href="attr.html">Attributes Plugin </a></li>
</ul>
</li>
<li class="btn-group">
<a href="#" data-function="toggle">API <span class="caret"></span></a>
<ul class="subnav">
<li><a href="start.html">Getting Started</a></li>
<li><a href="api.html">Public Methods</a></li>
<li><a href="easing.html">Easing Functions</a></li>
<li><a href="extend.html">Extend Guide</a></li>
</ul>
</li>
<li><a href="about.html">About</a></li>
</ul>
</div>
@ -93,8 +117,8 @@
<h2 class="nomarginlarge">At A Glance</h2>
<div class="columns hiddenoverflow">
<div class="col2">
<h3>Killer Performance</h3>
<p>KUTE.js is crazy fast with it's <a href="features.html#performance">outstanding performance</a>, with super fast code execution, it's also memory efficient. I made a <a href="performance.html">cool demo</a> to showcase how KUTE.js really scales on performance. </p>
<h3>Badass Performance</h3>
<p>KUTE.js is crazy fast with it's <a href="features.html#performance">outstanding performance</a> and super fast code execution, it's also memory efficient. I made a <a href="performance.html">cool demo</a> to showcase how KUTE.js really scales on performance. </p>
</div>
<div class="col2">
<h3>Prefix Free</h3>
@ -104,21 +128,21 @@
<div class="columns hiddenoverflow">
<div class="col2">
<h3>All Browsers Compatible</h3>
<p>KUTE.js covers <a href="features.html#compatibiity">all modern browsers</a> with fallback options for legacy browsers. When using <a href="https://polyfill.io/">polyfills</a> and the right <a href="http://browserhacks.com" target="_blank">browser detection</a> you can manage all kinds of <a href="examples.html#crossbrowser">fallback animations</a> for legacy browsers.</p>
<p>KUTE.js covers <a href="features.html#compatibility">all modern browsers</a> with fallback options for legacy browsers. When using <a href="https://polyfill.io/">polyfills</a> and the right <a href="http://browserhacks.com" target="_blank">browser detection</a> you can manage all kinds of <a href="examples.html#crossbrowser">fallback animations</a> for legacy browsers.</p>
</div>
<div class="col2">
<h3>Powerful Methods</h3>
<p>KUTE.js allows you to create tweens and chainable tweens, gives you tween control methods (stop/pause/resume/restart) and comes with full <a href="features.html#methods">spectrum tween options</a>.</p>
<p>KUTE.js allows you to <a href="features.html#methods">create tweens</a> and chainable tweens, gives you tween control methods (start/stop/pause/resume) and comes with full spectrum <a href="api.html#tweenoptions">tween options</a>.</p>
</div>
</div>
<div class="columns hiddenoverflow">
<div class="col2">
<h3>Packed With Tools</h3>
<p>KUTE.js comes with tools to help you configure awesome animations: jQuery plugin, cubic-bezier and physics easing functions, color convertors, and a lot of options to play with.</p>
<p>KUTE.js comes with tools to help you configure awesome animations: SVG Plugin, jQuery plugin, cubic-bezier and physics easing functions, color convertors, and you can even <a href="features.html#extensible">extend</a> it yourself.</p>
</div>
<div class="col2">
<h3>Plenty Of Properties</h3>
<p>KUTE.js covers all animation needs such as <code>transform</code>, <code>scroll</code> (window or other elements), colors (border, background and text), <code>border-radius</code>, almost the full box model and also text properties.</p>
<p>KUTE.js covers all animation needs such as SVG morph and other specific CSS properties, then <code>transform</code>, <code>scroll</code>, <code>border-radius</code>, and almost the full box model and also text properties.</p>
</div>
</div>
<div class="columns hiddenoverflow">
@ -168,7 +192,7 @@
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2007 - 2015 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
<p>&copy; 2007 - 2016 &middot; <a href="http://themeforest.net/user/dnp_theme?ref=dnp_theme">dnp_theme</a>.</p>
</div>
</footer>
@ -182,8 +206,9 @@
<!-- Placed at the end of the document so the pages load faster -->
<!--<script src="http://cdn.jsdelivr.net/kute.js/0.9.5/kute.min.js"></script> KUTE CDN -->
<script src="./src/kute.js"></script> <!-- KUTE local -->
<script src="./assets/js/home.js"></script> <!-- some stuff -->
<script src="./src/kute.js"></script> <!-- KUTE.js core -->
<script src="./src/kute-css.js"></script> <!-- KUTE.js CSS Plugin -->
<script src="./assets/js/scripts.js"></script> <!-- some stuff -->
<script src="./assets/js/home.js"></script> <!-- some stuff -->
</body>
</html>

View file

@ -5,39 +5,38 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="KUTE.js is a minimal Javascript animation engine">
<meta name="description" content="KUTE.js performance testing page, in comparison with GSAP and Tween.js">
<meta name="keywords" content="kute,kute.js,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.png"> <!-- TO DO -->
<title>KUTE.js | Performance Testing Page</title>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<style>
body {background-color: #2e2e2e; color: #999; font-size: 12px; font-family: Helvetica, Arial, Helvetica, sans-serif;}
a {color:#ffd626; text-decoration: none}
a:hover,a:focus {color:#fff;}
#container {
width: 200px; /*height: 200px;*/
margin: 0 auto;
position: relative;
display: block;
}
.line {
width: 200px;
height: 2px;
position: absolute;
transform: translate3d(0px, 0px, 0px);
}
<style>
body {background-color: #2e2e2e; color: #999; font-size: 12px; font-family: Helvetica, Arial, Helvetica, sans-serif;}
a {color:#ffd626; text-decoration: none}
a:hover,a:focus {color:#fff;}
#container {
width: 200px; /*height: 200px;*/
margin: 0 auto;
position: relative;
display: block;
}
iframe {width: 100%; height: 100%; border:0}
.line {
width: 200px;
height: 2px;
position: absolute;
}
.box { height: 200px }
#info {position: absolute; top: 0; left: 0; width: 400px;}
.hack { transform: translate3d(0px,0px,0px); }
.padding {padding: 20px}
.btn-group { margin-bottom: 15px; }
.btn {font-size: 13px; }
</style>
.text-danger {font-weight: bold}
</style>
<!-- Polyfill -->
<script src="./assets/js/minifill.js"> </script>
</head>
<body>
@ -90,18 +89,11 @@
<li><a id="800" href="#">800</a></li>
<li><a id="900" href="#">900</a></li>
<li><a id="1000" href="#">1000</a></li>
<!--<li><a id="1500" href="#">1500</a></li>
<li><a id="2000" href="#">2000</a></li>-->
</ul>
</span>
<div id="hack" style="display: none">
<p>When left is used, try the hack: </p>
<span class="btn-group" data-toggle="buttons">
<label class="btn btn-info">
<input type="checkbox" autocomplete="off"><span class="state">Hack OFF</span>
</label>
</span>
</div>
<hr>
@ -112,11 +104,11 @@
<!--[if IE]><p class="text-danger">The test page is not intended for legacy browsers.</p><![endif]-->
<!--[if !IE ]><!-->
<p>These tests are only for modern browsers. In Google Chrome you can enable the FPS metter in developer tools, <a href="https://developer.chrome.com/devtools/docs/rendering-settings" target="_blank">here's how</a>.</p>
<p>The hack refers to adding a blank transform <code>translate3d(0px,0px,0px);</code> for the elements to promote them into separate layers, as described <a href="https://developers.google.com/web/fundamentals/performance/rendering/simplify-paint-complexity-and-reduce-paint-areas#promote-elements-that-move-or-fade" target="_blank">here</a>.</p>
<p class="text-danger">Do not try this test on lower end or mobile devices.</p>
<!--<![endif]-->
</div>
<div id="container"></div>
@ -128,9 +120,9 @@
<!--<script src="http://cdn.jsdelivr.net/kute.js/0.9.5/kute.min.js"></script> KUTE CDN -->
<!--[if !IE ]><!-->
<script type="text/javascript" src="https://cdn.jsdelivr.net/bootstrap.native/0.9.9/bootstrap-native.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/bootstrap.native/1.0.1/bootstrap-native.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/TweenMax.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.2/TweenMax.min.js"></script>
<script src="./assets/js/tween.min.js"></script>
<script src="./src/kute.js"></script>
<script src="./assets/js/perf.js"></script>

File diff suppressed because it is too large Load diff

2
dist/kute.min.js vendored

File diff suppressed because one or more lines are too long

713
kute.js

File diff suppressed because it is too large Load diff