Added some more features, a changelog will come with the tagged release.

This commit is contained in:
thednp 2015-10-18 09:40:11 +03:00
parent 2a15904963
commit 6860924799
30 changed files with 4434 additions and 2477 deletions

22
LICENSE
View file

@ -1,22 +0,0 @@
The MIT License (MIT)
Copyright (c) 2015 thednp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,90 +0,0 @@
# kute.js
A minimal Native Javascript tweening engine forked from <a href="https://github.com/tweenjs/tween.js">tween.js</a>. Since most of web developers don't actually use yoyo, repeat, play/pause/resume/timeline/whatever or tweening array values (processed with array interpolation functions), I've removed them. kute.js is like a merge of my own <a href="https://github.com/thednp/jQueryTween">jQueryTween</a> with tween.js, but generally it's a much more smarter build. You link the script at your ending <code>&lt;body&gt;</code> tag and write one line to do just about any animation you can think of.
# CDN
Thanks to jsdelivr, we have CDN link <a href="http://www.jsdelivr.com/#!kute.js">here</a>.
# Basic Usage
At a glance, you can write one line and you're done.
<pre>
//vanilla js
new KUTE.Animate(el,options);
//with jQuery plugin
$('selector').Kute(options);
</pre>
# Advanced Usage
Quite easily, you can write 'bit more lines and you're making the earth go round.
<pre>
//vanilla js
new KUTE.Animate(el, {
//options
from : {},
to : {},
duration: 500,
delay : 0,
easing : 'exponentialInOut',
start : functionOne, // run function when tween starts
finish : functionTwo, // run function when tween finishes
special : functionThree // run function while tween runing
}
);
//with jQuery plugin
$('selector'). Kute({
//options
from : {},
to : {},
duration: 500,
delay : 0,
easing : 'exponentialInOut',
start : functionOne, // run function when tween starts
finish : functionTwo, // run function when tween finishes
special : functionThree // run function while tween runing
}
);
</pre>
# Full distribution (12Kb min)
It does most of the animation work you need.
* size: width and height
* colors: text color and background-color (values )
* transform: translate3D, scale, rotateX, rotateY, rotateZ
* position: top, left (ideal for IE9- translate3D(left,top,0) fallback)
* zoom: for scale on IE8 fallback
* backgroundPosition
* window scroll
# Base Distribution (9Kb min)
This distribution is much lighter and more suitable for most projects:
* size: width and height
* transform: translate3D, scale, rotateX, rotateY, rotateZ
* position: top, left (ideal for IE9- translate3D(left,top,0) fallback)
* zoom: for scale on IE8 fallback
* window scroll
#jQuery Plugin
That's right, there you have it, just a few bits of code to bridge the awesome kute.js to your jQuery projects.
# What else it does
* computes option values properly according to their measurement unit (px,%,deg,etc)
* properly handles IE10+ 3D transforms when elements have a perspective
* it converts RGBA & HEX colors to RGB and tweens the inner values, then ALWAYS updates color via HEX
* properly replaces top, centered or any other background position with proper value to be able to tween
* for most supported properties it reads the current element style property value as initial value (via currentStyle || getComputedStyle)
* allows you to add 3 different callbacks: start, update, finish, and they can be set as tween options (so no more nested functions needed)
* since <code>translate3D</code> is best for performance, kute.js will always uses it
* accepts "nice & easy string" easing functions, like 'linear' or 'exponentialOut' (removes the use of the evil <code>eval</code>, making development easier and closer to fast development standards :)
* uses 31 easing functions, all Robert Penner's easing equations
* like mentioned above, for IE8 <code>zoom</code> is used for <code>transform: scale(0.5)</code>, it's not perfect as the object moves from it's floating point to the middle, and some left & top adjustments can be done, but to keep it simple and performance driven, I leave it as is, it's better than nothing.
# Browser Support
Since most modern browsers can handle pretty much everything, legacy browsers need some help, so give them <a href="https://cdn.polyfill.io/v1/docs/">polyfills.io</a>. Also kute.js needs to know when doing stuff for IE9- like my other scripts here, I highy recommend <a href="http://www.paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">Paul Irish's conditional stylesheets</a> guides to add <code>ie ie[version]</code> to your site's HTML tag.
# Demo
coming soon..
# License
<a href="https://github.com/thednp/kute.js/blob/master/LICENSE">MIT License</a>

148
about.html Normal file
View file

@ -0,0 +1,148 @@
<!DOCTYPE html>
<!--[if IE 7]><html class="ie ie7" lang="en"><![endif]-->
<!--[if IE 8]><html class="ie ie8" lang="en"><![endif]-->
<!--[if IE 9]><html class="ie ie9" lang="en"><![endif]-->
<!--[if gte IE 9 | !IE ]><!--> <html lang="en"> <!--<![endif]-->
<head>
<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="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>About KUTE.js | Javascript Animation Engine</title>
<!-- RESET CSS -->
<link type="text/css" href="./assets/css/reset.css" rel="stylesheet">
<!-- DEMO KUTE CSS -->
<link type="text/css" href="./assets/css/kute.css" rel="stylesheet">
<!-- Ion Icons -->
<link type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
</head>
<body>
<div class="fill overlay"></div>
<div class="site-wrapper">
<div class="navbar-wrapper">
<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="active"><a href="about.html">About</a></li>
</ul>
</div>
</div>
<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 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>
<p><strong>JANK</strong> is a term used when browsers miss frames due to long script execution and/or long layout recomposition. JANK is the phenomenon reffering to severe frame drops. Luckily there are people who <a href="http://www.html5rocks.com/en/tutorials/speed/rendering/" target="_blank">explain all about it</a>, so you don't have to stay in the dark.</p>
<p><strong>Methods</strong> are functions that create <strong>tween objects</strong> or control the animation for KUTE.js, so we will encounter mostly <em>main methods</em> and <em>tween control methods</em>. Once a main method is used, then the control methods apply in a specific order.</p>
<h2 id="how">How Does It Work?</h2>
<p>Well, first things first: it's smart built. Let's briefly explain the phases:</p>
<ol>
<li>On first initialization KUTE.js creates some variables such as supported properties and their default values, the user's browser prefix, the true scroll container (some browsers actually scroll the body, while others prefer the HTML tag), a boolean variable that makes KUTE.js aware it's working with IE8, as well as other variables required during the main thread. This phase is very important for the performance on the next phases.</li>
<li>In the next phase it's going to build the tween object with the chosen method according to it's distinct functionalities. If the chosen method is <code>.to()</code> KUTE.js will look for the current values of the properties used or assign the default values built in the previous phase. For both methods, KUTE.js collects all the data, processes values and options (for instance easing functions need to be processed if you use a string like 'easingElasticOut', right?) and builds the tween object, with all properties' values start and values end, measurement units, tween options and callback functions.</li>
<li>In the third phase KUTE.js is ready to start the animation, but the animation starts only after the <code>.start()</code> function, if used, has finished. When animation starts, KUTE.js will start <em>ticking</em> on the frequency decided by <code>requestAnimationFrame</code> or <code>setInterval</code> for legacy browsers, quickly updating the style for the properties and execute the <code>update:function</code> callback if any. Also while animating, KUTE.js will begin <em>listening</em> for your tween control input such as <code>.pause()</code> or <code>.stop()</code> or any other. Also, when a certain tween control method is used, KUTE.js will execute it's specific callback, if used.</li>
<li>When tween animation is finished, the <code>complete:function</code> callback function is executed and then KUTE.js starts the animation for any chained tween, or else will stop ticking with <code>cancelAnimationFrame</code> to save power.</li>
</ol>
<p>Basically, this is it!</p>
<h2 id="performance">A Word On Performance</h2>
<p>As said before, performance varies from case to case; this chapter aims to explain what you should expect working with animation engines in these various scenarios at maximum stress, usually when your CPU cooler starts to work really hard, and how scalable performance can really be on various machines, operating systems or mobile devices.</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>
<p><span class="ion-android-plane media"></span>I would stress on this a bit: even faster performance for translation can be achieved by using an improved version of the tiny <a href="https://github.com/tweenjs/tween.js">tween.js</a>, as it only <em>tweens</em> the values and allows you to concatenate strings as you please. On large amounts of elements translating on vertical or horizontal axis, tween.js would be the <strong>best</strong> of them all, but well, we'll see about that in the <a href="performance.html">performance testing page</a>. </p>
<p>To put it short <code>left</code> executes faster but requires repaint on every frame while <code>translateX</code> or <code>translate3d</code> execute slower but require no repaint on each animation frame. The <strong>winner</strong> is <kbd>left</kbd>, when it comes to code execution, but if we also count the elements' size, the larger size the more favor the translation so the <strong>overall winner</strong> is <kbd>translate</kbd>. With other words the more pixels to recompose in the layout, the more time spent on each frame, and this is why translation is better in most cases, and animated positioning is best to be used as fallback animation for legacy browsers.</p>
<h3>Translate, TranslateX and Translate3D</h3>
<p>While running a 2D <code>translate:150</code> animation could score similar performance as <code>translateX:150</code>, interestingly, <code>translate3d:[150,0,0]</code> is slightly faster than the other translations. Some performance <a href="http://jsperf.com/translate3d-vs-xy/28">tests</a> confirm that <code>translate3d</code> is the prefered property for hardware acceleration. For this reason, <kbd>translate3d</kbd> is the <strong>winner</strong> and KUTE.js always uses it even if you only use <code>translateX</code> or <code>translateY</code> for instance.<p>
<p>Similarly, if you animate the 2D <code>translate</code> this always goes <code>translate(x,y)</code> even if you use <code>translate:150</code> (only for the X axis) or <code>translate:[150,0]</code> (both X and Y axis), for better performance as well. And by the way, this works great on IE9 and other legacy browsers.</p>
<h3>Box Model</h3>
<p><span class="ion-nuclear media"></span>We compared position with transition above, but now we are going to talk about other issues related to <strong>resizers</strong>: <code>width</code>, <code>height</code>, <code>margin</code>, <code>padding</code> and <code>borderWidth</code> or any of their variations. The code execution is super fast, but when resizing the window while animations are running, the browser is also computing the resize handlers, the animation performance is very very low on <strong>all</strong> browsers, especially when you animate these resize properties. When this <strong>toxic combination</strong> occurs animating a large amount of elements to animate could crash any browser, no exception, and I think any developer should know about this.</p>
<p>The <code>resize</code> event triggered by these resizer properties can cause some <strong>severe issues with legacy browsers</strong> such as IE8. These good old browsers don't understand much about Javascript driven layout changes and thus skip/fail to execute any handlers attached to window resize event bubbles.</p>
<p>A workaound the resizers effect on the layout would be to use them only for absolute positioned elements, this way the layout will not need to be repainted and the recomposition is limited to the element itself. If not, and you are required to provide legacy support, you must DISABLE any resize handlers for IE8 and any other browser that runs slow or crashes. You should also consider not using any resize animation for legacy browsers especially when usability and larger reach is expected.</p>
<h3>RGB and HEX</h3>
<p><span class="ion-android-color-palette media"></span>When animating any color property such as (text) <code>color</code> or <code>background-color</code>, KUTE.js always uses/converts to RGB/RGBA, but there is a <code>keepHex:true</code> tween option that overrides that. Still some browsers such as Chrome will still show you the computed style for your color as RGB no matter what. The conversion process will decrease performance, making <kbd>RGB</kbd> the <strong>winner</strong>.</p>
<h3>TO and FROMTO</h3>
<p>The two main methods for creating animation setups (tween objects) that are coming with KUTE.js are <code>.to()</code> and <code>.fromTo()</code>. While <code>.to()</code> is much more simple and convenient to use, very useful for tween chaining, it has to process the starting values on every <code>.start()</code> delaying the animation for a few miliseconds depending on the browser and hardware, making <kbd>.fromTo()</kbd> the <strong>winner</strong>. On a large amount of elements animating at the same time, these scripting based delays can produce some serious syncronization issues, so caution is advised. In that case you should use <code>.fromTo()</code> properly.</p>
<h3>Easing Functions</h3>
<p>KUTE.js comes with 3 packs of easing functions: the popular <a href="http://robertpenner.com/easing/" target="_blank">easing functions</a> by Robert Penner, <a href="http://dynamicsjs.com/" target="_blank">dynamics physics</a> easing functions by Michael Villar and <a href="https://github.com/gre/bezier-easing" target="_blank">bezier-easing</a> by Gaëtan Renaudeau. I've worked very hard to optimize the last 2 as much as possible, but they will never beat Robert Penner's functions in any performance test, that's an all time <strong>winner</strong>.</p>
<p><span class="ion-shuffle media"></span>The point here is that the more accuracy a function offers, the more power needed, and the result is less performance. For instance the <code>cubic-bezier</code> based functions have a 0.0000001 error margin, while the <code>Exponential</code> easing functions by Robert Penner are somewhat glitchy on long page scrolls or translations. Interestingly, some physics based functions perform exceedingly well, and generally the difference in performance is fairly negligible even for large amounts of elements, and have no impact on very few elements.</p>
<h3>Garbage Collection And Repeat</h3>
<p><span class="ion-trash-a media"></span>The goal of the development strategy is to be able to execute the script, update layout and repaint, all under 16 miliseconds, so that the animation runs constantly at 60fps. However running some repeatable animations for a large amount of elements would really give garbage collectors a lot of work and thus some frames take more than 16 miliseconds. The more properties and/or elements, the more work.</p>
<p>While garbage collection is a great way modern browsers use to clean the memory, sometimes the garbage collector can jump in anytime, cousing drops in the order of miliseconds. Still, if it's the case, there are ways to help composing the layout faster, but we will see that in the performance testing <a href="performance">page</a>.</p>
<h3>OSs, Desktops and Mobiles</h3>
<p><span class="ion-social-tux media"></span>The performance tests have been performed mainly on Microsoft Windows 8.1 and Ubuntu Linux 14.04 Trusty Tahr with latest nVidia graphics drivers on both OSs, all set up for maximum performance. The browsers are obviously Firefox (both OSs), Google Chrome (both OSs), Opera (both OSs) and IE11 (Win8).</p>
<p><span class="ion-social-windows media"></span>The results show <strong>Windows</strong> based browsers came better than Ubuntu based ones, mainly because of DirectX and better drivers that greatly improve hardware accelerated graphics, while Linux still faces some noticeable issues with vertical sync among many others, but hey it's a work in progress and it's open source!</p>
<p><span class="ion-social-chrome media"></span>The browsers' performance goes like this (from best to poorest): <strong>Google Chrome</strong>, Opera, Internet Explorer, Firefox. Yes, Firefox is the slowest on Windows OS. I never tested anything on iOS or MAC-OS but I believe Safari performs very well with transforms. <a href="http://venturebeat.com/2014/05/12/apple-upgrades-safaris-webkit-to-challenge-googles-chrome-browser/" target="_blank">Some argue</a> that Safari outperforms Google Chrome due to the latest Webkit upgrade.</p>
<p>Also know that legacy browsers don't support <code>requestAnimationFrame</code> and pollyfills usually replace it with <code>setInterval</code>, a clasic Javascript method that's <a href="https://jsperf.com/requestanimationframe-vs-setinterval-loop/7" target="_blank">significantly</a> affecting performance, because it's one of the main causes for <a href="http://www.html5rocks.com/en/tutorials/speed/rendering/" target="_blank">lots of JANK</a>.</p>
<p>Another important aspect as far as performance goes, the power saving profiles on Windows OS drops performance for desktop computers and especally laptops. Also when a laptop is unplugged, Windows automatically changes power profile drastically decreasing performance. </p>
<p>As for the mobiles, you must know that even if you have an octacore CPU powered phone or tablet is never going to match a desktop and not even a laptop. For a mobile device <a href="https://www.youtube.com/watch?v=YyQYhhy1dZI" target="_blank">these guys</a> recommend to keep everything under 7 miliseconds for the smooth experience that most users expect and that the animation performance of a phone is actually up to 5 times lower than a desktop or laptop. I would stress that having 2 or 3 simoultaneous animations on a phone at a certain point is just about enough.</p>
<p><span class="ion-android-phone-portrait media"></span>Another thing to keep in mind is that scrollling on a mobile device is actually hardware accelerated animation and thus compete for power drastically reducing performance for any other CSS or Javascript driven animations. To understand how critical performance is on a mobile device, I highly recommend checking the <a href="https://youtu.be/WrA85a4ZIaM?t=16m6s" target="_blank">Google I/O 2014 presentation</a>. Now you understand how much performance really matters.</p>
<p><strong>Remember</strong>: do not open any Javascript animation engine performance test with your phone, you may burn your battery, espectially if it's unpluggable.</p>
<h2>KUTE.js Project</h2>
<p>KUTE.js continues what was started with <a href="https://github.com/thednp/jQueryTween" target="_blank">jQueryTween</a> and the main goal is to improve usability, compatibility, code quality and performance. KUTE.js includes a jQuery plugin to help you easily implement it in your jQuery applications, and also packs a set of tools such as bezier and physics based easing functions, all elegantly packed for convenience and distributed via CDN.</p>
<p>It all started with a fork of the popular <a href="https://github.com/tweenjs/tween.js" target="_blank">tween.js</a> and ended up having a KUTE.js version 0.9.5 that's almost as good as the boss, <a href="https://greensock.com" target="_blank">GSAP</a>, at least in terms of performance and browser support. TweenMax have been an outstanding source of wonderful coding practices, a true inspiration for the entire developers' community, not to mention the huge contribution and knowledge sharing.</p>
<p>In the hystory of the making there were consistent contributions of <a href="https://github.com/dalisoft" target="_blank">Dav</a> aka @dalisoft for features such as play &amp; pause, as well as for performance related issues. Generally I would stress that the code is a joint work of me and Dav. Big thanks Dav, well done.</p>
<p>Also I would like to thank <a href="http://ingwie.me/" target="_blank">Ingwie Phoenix</a> for the npm/Bower and UMD implementations.</p>
<ul id="share" class="nav">
<li>Share </li>
<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>
</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>
</div>
</footer>
</div><!-- /.site-wrapper -->
<!-- JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
</body>
</html>

363
api.html Normal file
View file

@ -0,0 +1,363 @@
<!DOCTYPE html>
<!--[if IE 7]><html class="ie ie7" lang="en"><![endif]-->
<!--[if IE 8]><html class="ie ie8" lang="en"><![endif]-->
<!--[if IE 9]><html class="ie ie9" lang="en"><![endif]-->
<!--[if !IE ]><!--> <html lang="en"> <!--<![endif]-->
<head>
<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="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 Developer API | Javascript Animation Engine</title>
<!-- RESET CSS -->
<link type="text/css" href="./assets/css/reset.css" rel="stylesheet">
<!-- DEMO KUTE CSS -->
<link type="text/css" href="./assets/css/kute.css" rel="stylesheet">
<!-- Ion Icons -->
<link type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<!-- legacy browsers support via polyfill
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,getComputedStyle|gated"> </script> -->
<!--[if IE]>
<script src="./assets/js/minifill.js"> </script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="fill overlay"></div>
<div class="site-wrapper">
<div class="navbar-wrapper">
<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><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/0.9.5/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/0.9.5/kute-jquery.min.js">&lt;/script> &lt;!-- jQuery Plugin -->
&lt;script src="https://cdn.jsdelivr.net/kute.js/0.9.5/kute-easing.min.js">&lt;/script> &lt;!-- Bezier Easing Functions -->
&lt;script src="https://cdn.jsdelivr.net/kute.js/0.9.5/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>Ideal HTML Template</h3>
<p>You need to know when users' browser is a legacy one in order to use KUTE.js only for what browsers can actually do. 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 we can actually do is use the Microsoft's synthax for it's own legacy browsers, so here's how a very basic <code>HTML</code> template for your websites would look like:</p>
<pre><code class="language-markup">&lt;!DOCTYPE html&gt;
&lt;!--[if lt IE 8]&gt;&lt;html class="ie prehistory" lang="en"&gt;&lt;![endif]--&gt;
&lt;!--[if IE 8]&gt;&lt;html class="ie ie8" lang="en"&gt;&lt;![endif]--&gt;
&lt;!--[if IE 9]&gt;&lt;html class="ie ie9" lang="en"&gt;&lt;![endif]--&gt;
&lt;!--[if !IE]&gt;&lt;!--&gt; &lt;html lang="en"&gt; &lt;!--&lt;![endif]--&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
&lt;!-- SEO meta here --&gt;
&lt;!-- add your CSS here --&gt;
&lt;!-- add polyfills --&gt;
&lt;script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,getComputedStyle|gated"&gt; &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!-- site content here --&gt;
&lt;!-- scripts go here --&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>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>
<p>These methods allow you to create <strong>tween objects</strong>; here a tween object is essentially like an animation setup for a given HTML element, defining CSS properties, animation duration or repeat. The methods have different uses and performance scores while making it easy to work with.</p>
<p><kbd>.to()</kbd> method is the most simple method which allows you to create tween objects for animating CSS properties from a specific default value OR from current/computed value TO a desired value.
It's performance is not the same as for the next two because it has to compute the default/current value on tween <code>.start()</code> and thus delays the animation for a cuple of miliseconds, but this feature is great for simple animations AND it has the ability to stack transform properties as they go, making smooth transform animations on chained tweens. See the <a href="#start">.start()</a> method for the solution for sync/delay issue.</p>
<p>Considering a given <em>div</em> element is already transparent, a super quick example would be:</p>
<pre><code class="language-javascript">KUTE.to(div,{opacity:1}).start()</code></pre>
<p><kbd>.fromTo()</kbd> method is the best way to build animations for BEST performance and absolute control. The tests prove this method to be the fastest methods but unlike the <code>.to()</code> method, it does not stack transform properties on chained tweens. Also, another advantage is the fact that you can set measurement units for both starting and end values, to avoid glitches. We've talked about this in the <a href="features.html">features page</a>. So here's a quick example:</p>
<pre><code class="language-javascript">KUTE.fromTo(div,{opacity:1},{opacity:0}).start()</code></pre>
<p><kbd>.Animate()</kbd> method is only a fallback for the older KUTE.js versions and works as the <code>.fromTo()</code> method. It will be deprecated with later versions.</p>
</div>
<div class="content-wrap">
<h2>Tween Control Methods</h2>
<p>These methods allows you to control when the animation starts or stops. Let's write a basic tween object to work with the methods:</p>
<pre><code class="language-javascript">var tween = KUTE.fromTo(div,{opacity:1},{opacity:0});</code></pre>
<p>This tween object is now ready to work with the methods.</p>
<h3 id="start">Starting Animations</h3>
<p><kbd>.start()</kbd> method starts animation for a given tween object. It can start the animation for both cached and non-cached objects. Unlike previous versions of KUTE.js, where animation started immediately after tween object creation, now you have to manually start them.</p>
<pre><code class="language-javascript">//cached object defined above
tween.start();
//non-cached object are created on the fly and garbage collected after animation has finised
KUTE.fromTo(div,{opacity:1},{opacity:0}).start();
//also start the tween at a certain time
tween.start(now); // where now must be the current or future time as number, see below
</code></pre>
<p>As you can see, you can also set a time for the animation to start, example: <code>tween.start(myTimeValue)</code>. Having access to the method is useful when starting animation for large amounts of elements with same properties at the same time because using it properly <strong>eliminates any syncronization issue that may occur</strong>, even if you are using the <code>.to()</code> method. This applies to our performance test page as well, and the trick is super duper simple:</p>
<pre><code class="language-javascript">// step 1 - create an empty array and grab the elements to animate
var tweens = [], myElements = document.querySelector('.myManyElements');
// step 2 - define tween objects for each element
for (var i = 0; i < numberOfElements; i++) {
var tween = KUTE.fromTo(myElements[i], fromValues, toValues, options);
//now we populate the tweens array
tweens.push(tween);
}
// step 3 - calculate the right time to start
// first we need the exact current time
var now = window.performance.now(); // this returns the exact current time in numeric format
// also we estimate/calculate an adjustment lag
// depending on the number of the elements AND hardware capability
// maybe (numberOfElements / 16) would be an accurate value for PCs
var lag = 100; // number of miliseconds for the script to built tween objects for all elements
// step4 - we just start the animation for all elements at once
for (var i = 0; i < numberOfElements; i++) {
tweens[i].start(now+lag);
}
</code></pre>
<p>If you care to see the actual working code, check it in the <a href="./assets/js/perf.js" target="_blank">perf.js</a> file.</p>
<h3>Stopping Animation</h3>
<p><kbd>.stop()</kbd> method stops animation for a given tween object while animating. You cannot stop the animation for tween objects created on the fly, only for cached objects. Let's assume that for the given tween we decide to stop the animation via <code>click</code> action:</p>
<pre><code class="language-javascript">stopButton.addEventListener('click', function(){
tween.stop();
}, false);
</code></pre>
<h3>Pausing Animation</h3>
<p><kbd>.pause()</kbd> method freezez the animation at any given time for a given tween object, and unlike the <code>.stop()</code> method, this one allows resuming the animation on a later use of the next method <code>.play()</code>.</p>
<pre><code class="language-javascript">pauseButton.addEventListener('click', function(){
tween.pause();
}, false);
</code></pre>
<h3>Resuming Paused Animation</h3>
<p><kbd>.play()</kbd> or <kbd>.resume()</kbd> methods allows you to resume an animation for a given tween object only if it was paused or else will produce no effect.</p>
<pre><code class="language-javascript">playButton.addEventListener('click', function(){
tween.play(); // or tween.resume();
}, false);
</code></pre>
<h3>Chaining Tweens</h3>
<p><kbd>.chain()</kbd> method can be used to chain tweens together. When the animation finishes for a given tween, it triggers the animation start for another tween.</p>
<pre><code class="language-javascript">var tween2 = KUTE.fromTo(div,{left:50},{left:0});
//the first tween chains the new tween
tween.chain(tween2);
//the new tween chains the first one creating a loop
tween2.chain(tween);
</code></pre>
<p>It's also possible to chain multiple tweens, just as shown in the below example, but the one that finishes last (has longest delay and duration together) should be used last in the <code>.chain()</code> method arguments list. Why? Because when a tween is finished it triggers <code>cancelAnimationFrame()</code> and KUTE.js will stop "ticking" causing all other chained tweens to stop prematurelly.</p>
<pre><code class="language-javascript">//chain multiple tweens
tween.chain(tween1,tween2);
</code></pre>
</div>
<div class="content-wrap">
<h2>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>
<p><kbd>repeat: 20</kbd> option allows you to run the animation of given tween multiple times. The default value is <strong>0</strong>.</p>
<p><kbd>delay: 500</kbd> option allows you to schedule the tween animation after a certain number of miliseconds. The default value is <strong>0</strong>.</p>
<p><kbd>repeatDelay: 500</kbd> option allows you to set a number of miliseconds delay between repeatable animations. If <code>repeat</code> option is set to <strong>0</strong>, will produce no effect. The default value is <strong>0</strong>.</p>
<p><kbd>yoyo: true/false</kbd> option makes use of the internal reverse functionality to also animate from <b>end</b> to <b>start</b> for a given tween. This option requires that you use the <code>repeat</code> option with at least value <b>1</b>. The default value is <strong>false</strong>.</p>
<p><kbd>easing: 'easingCubicInOut'</kbd> option allows you to use a custom easing function for your animation. For more info on the easing functions, you need to see the example pages. The default value is <strong>linear</strong>.</p>
<h3>Transform Options</h3>
<p>These options only affect animation involving any property from CSS3 <code>transform</code> specs and have no effect on other CSS properties. While you can set <code>perspective</code> or <code>perspective origin</code> via CSS, these options are here to help, especially with full browser support and preffix free handling.</p>
<p><kbd>perspective: 500</kbd> option allows you to set a 3D transformation <code>perspective</code> for a given HTML element that is subject to transform animation. No default value.</p>
<p><kbd>perspectiveOrigin: "50% 50%"</kbd> option allows you to set a <code>perspectiveOrigin</code> for a given HTML. This option has no default value and only accepts valid CSS values according to it's specs.</p>
<p><kbd>parentPerspective: 500</kbd> option allows you to set a 3D <code>perspective</code> for the <strong>parent</strong> of the HTML element subject to the transform animation.</p>
<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>
<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>
<p><kbd>update: function</kbd> option allows you to set a function to run on every frame.</p>
<p><kbd>pause: function</kbd> option allows you to set a function to run when animation is paused.</p>
<p><kbd>resume: function</kbd> option allows you to set a function to run when animation is resumed.</p>
<p><kbd>stop: function</kbd> option allows you to set a function to run when animation is stopped.</p>
<p><kbd>complete: function</kbd> option allows you to set a function to run when animation is finished.</p>
<p>A quick example would look like this:</p>
<pre><code class="language-javascript">//define a function
var callback = function(){
//do some foo
}
//create object and start animating already
KUTE.fromTo(div,{left:150},{left:0},{complete: callback}).start();
</code></pre>
<h3>Other</h3>
<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>
<ul id="share" class="nav">
<li>Share </li>
<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>
</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>
</div>
</footer>
</div><!-- /.site-wrapper -->
<!-- JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- highlighter -->
<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="./assets/js/scripts.js"></script> <!-- some stuff -->
</body>
</html>

345
assets/css/kute.css Normal file
View file

@ -0,0 +1,345 @@
/*!
* KUTE.js | https://github.com/thednp/kute.js/
* Licensed under MIT (https://github.com/thednp/kute.js/blob/master/LICENSE)
*/
/* GLOBAL STYLES
-------------------------------------------------- */
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 2; /* ~25px */
color: #ddd;
background-color: #999;
position: relative
}
body > .fill {
position: fixed; top: 0; left:0; right: 0; bottom:0;
}
.fill {
background-size: cover;
background-position: 50% 50%;
background-repeat: no-repeat;
width: 100%; height: 100%;
}
.ie8 .fill {background-size: auto 100%}
.overlay {
background-color: #000;
opacity: 0.7
}
.ie8 .overlay { filter: alpha(opacity=70) }
footer {
clear: both; overflow: hidden; margin-top: 60px
}
footer .content-wrap {
padding-top: 5px;
border-top: 1px solid rgb(120,120,120); border-top: 1px solid rgba(255,255,255,0.2);
}
footer p {margin: 0 0 10px}
/* site-wrapper */
.site-wrapper { position: relative; overflow: hidden}
/* navbar */
.navbar-wrapper { position: relative; clear: both }
.navbar-wrapper .content-wrap { height: 64px; padding: 20px 0 0; }
.navbar-wrapper h1 { color: #fff; font-size: 32px; line-height: 25px; letter-spacing: -2px; float: left; padding-right: 25px; margin-right: 25px; border-right: 1px solid rgb(120,120,120); border-right: 1px solid rgba(255,255,255,0.2) }
.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 }
.ie8 .nav li { margin-right: 12px }
.nav li.active a { color: #ffd626 }
.nav li a { color: #ccc }
@media (max-width: 768px){
.navbar-wrapper .content-wrap { height: 94px}
.navbar-wrapper h1 {border: 0}
.navbar-wrapper .nav,
.navbar-wrapper h1 { float: none; }
.navbar-wrapper .nav { height: 30px }
}
.ie8 .btn.top-right { top:55px }
/* featurettes */
.featurettes {
background: #222;
padding: 60px 0;
width: 100%;
clear: both;
margin: 60px 0;
float: left;
}
.content-wrap .featurettes { margin: 0 0 20px; padding: 20px 0 0 20px; display: inline-block; border-radius: 10px; position: relative }
/* example box */
.example-box {
font-size: 40px; line-height: 150px; text-align:center; font-weight: bold;
width: 150px; height: 150px; float: left; position:relative;
border-radius: 5px; margin: 0 20px 20px 0;
/* 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-buttons {position: absolute; top: 18px; right:0}
/* text properties example */
h1.example-item {
font-size: 50px;
line-height:50px;
color: #fff;
}
h1.example-item span {
line-height: inherit;
opacity: 0; display: inline;
vertical-align: top;
}
.btn.example-item {opacity: 0}
.ie8 h1.example-item span,
.ie8 .btn.example-item {filter: alpha(opacity=0)}
/*.ie8 .btn.example-item * {filter: inherit}*/
/* UTILITY STYLES
-------------------------------------------------- */
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.center-block {
display: block;
margin-left: auto;
margin-right: auto;
}
.pull-right {
float: right !important;
}
.pull-left {
float: left !important;
}
.hide {
display: none !important;
}
.show {
display: block !important;
}
.invisible {
visibility: hidden;
}
.text-hide {
font: 0/0 a;
color: transparent;
text-shadow: none;
background-color: transparent;
border: 0;
}
.hidden {
display: none !important;
visibility: hidden !important;
}
.hiddenoverflow { overflow: hidden }
.media {float: left; margin: 5px 20px 0 0; height: auto; font-size: 64px; line-height: 64px; width: 64px; text-align: center}
/* WRAPPER STYLES
-------------------------------------------------- */
.content-wrap { position: relative; width: 980px; margin: 0 auto; max-width: 100%; clear: both; }
@media (max-width: 1200px){
.content-wrap { width: 100%; max-width: 80%; }
}
/* check div consistency
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 { 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; }
h4 { font-size: 16px; letter-spacing:0px; line-height: 1.14; font-weight: normal; }
h1, h3, [class*="col"] > h4 {margin: 0 0 20px}
.lead { font-size: 16px }
.nomargin { margin-top: 0px !important }
@media (min-width: 768px){
.nomarginlarge { margin-top: 0 !important }
}
/* COLUMN STYLES
-------------------------------------------------- */
.columns { position: relative; width: auto; margin: 0 -20px; clear: both }
.columns > [class*="col"] { padding: 0 20px; float:left; position: relative }
.col2 { width: 50% }
.col3 { width: 33.3% }
.col4 { width: 25% }
.col8 { width: 75% }
@media (min-width: 480px) and (max-width: 768px){
/*.columns:not(#blocks) .col3:last-child{width: 100%;}*/
.col3,
.col4 { width: 50% }
.col8 { width: 100% }
}
@media (max-width: 479px){
.columns > [class*="col"] { float:none; width: 100%; }
}
.table { display: table; height: 480px }
.cell { display: table-cell; vertical-align: middle }
@media (max-width: 479px){
.table { height: 320px }
}
/* welcome */
.col3.bg { /*min-height: 120px;*/ width: 32%; margin: 1.3% 1.3% 0 0; float: left; padding: 0; opacity:0 }
.ie8 .col3.bg { filter: alpha(opacity=0); }
.col3.bg:nth-child(3),
.col3.bg:nth-child(6),
.col3.bg:nth-child(9) { margin: 1.3% 0 0 }
.welcome > .table > .cell {perspective: 600px; -webkit-perspective: 600px; }
#blocks {
transform: rotateY(-10deg); -webkit-transform: rotateY(-10deg); width: 90%;
}
/*.replay { display: none; }*/
@media (max-width: 768px){
.columns.welcome .col2.table { width: 100% !important; float: left }
.columns.welcome .col2:nth-child(2) { position: absolute; top: 0; z-index: -1 }
#blocks { width: auto }
}
/* STYLING CONTENT
-------------------------------------------------- */
/* images */
img { max-width: 100% }
img.circle { border-radius: 50% }
/* links */
a {
color: #ffd626;
text-decoration: none;
}
a:hover,
a:focus {
color: #4CAF50;
text-decoration: underline;
}
a:focus {
outline: none;
}
hr {
border: 1px solid #444;
margin: 10px 0;
}
/* share */
#share {position: fixed; top: 20px;right: 20px;}
#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; }
.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 }
.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 }
.icon-large.fa-rocket:before { color: #673AB7 }
.icon-large.fa-code-fork:before { color: #9C27B0 }
.btn span {
font-size: 150%;
vertical-align: middle;
}
.btn span.right { margin: 0 0 0 10px }
.btn span.left { margin: 0 10px 0 0 }
/* STYLE CODE WRAPPING
-------------------------------------------------- */
code, kbd, pre {
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
}
pre {
display: block;
padding: 10px 15px !important;
margin: 0 0 20px !important;
line-height: 2.08;
color: #999;
word-break: break-all;
background-color: rgb(33,33,33);
background-color: rgba(11,11,11,0.5);
/*border: 1px solid rgb(22,22,22);
border: 1px solid rgba(11,11,11,0.8);*/
border-radius: 4px;
text-align: left;
position: relative;
}
pre.language-javascript:after,
pre.language-clike:after,
pre.language-markup:after {
position: absolute; top:0; right:0; padding: 2px 5px;
background: #000;
border-radius: 0px 0px 0px 5px;
font-family: Helvetica, Arial, sans-serif;
font-size: 12px; color: #999;
}
pre.language-javascript:after {content: 'Javascript';}
pre.language-clike:after {content: 'node';}
pre.language-markup:after {content: 'HTML';}
pre code {background: none;padding: 0; font-weight: normal; font-size: 100%;}
code {
padding: 2px 4px;
font-size: 90%;
color: #999;
background-color: #111;
border-radius: 4px;
white-space: pre;
font-weight: bold
}
kbd {
padding: 2px 4px;
font-size: 90%;
color: #333;
background-color: #eee;
border-radius: 3px;
font-weight: bold
}

3
assets/css/prism.css Normal file
View file

@ -0,0 +1,3 @@
/* prism okaidia | ocodia */
code[class*=language-],pre[class*=language-]{color:#f8f8f2;text-shadow:0 1px rgba(0,0,0,.3);font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#f8f8f2}.namespace{opacity:.7}.token.constant,.token.deleted,.token.property,.token.symbol,.token.tag{color:#f92672}.token.boolean,.token.number{color:#ae81ff}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#a6e22e}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url,.token.variable{color:#f8f8f2}.token.atrule,.token.attr-value,.token.function{color:#e6db74}.token.keyword{color:#66d9ef}.token.important,.token.regex{color:#fd971f}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}

209
assets/css/reset.css Normal file
View file

@ -0,0 +1,209 @@
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section,
summary {
display: block;
}
audio,
canvas,
progress,
video {
display: inline-block;
vertical-align: baseline;
}
audio:not([controls]) {
display: none;
height: 0;
}
[hidden],
template {
display: none;
}
a {
background: transparent;
}
a:active,
a:hover {
outline: 0;
}
abbr[title] {
border-bottom: 1px dotted;
}
b,
strong {
font-weight: bold;
}
dfn {
font-style: italic;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
mark {
background: #ff0;
color: #000;
}
small {
font-size: 80%;
}
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
img {
border: 0;
}
svg:not(:root) {
overflow: hidden;
}
figure {
margin: 1em 40px;
}
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
pre {
overflow: auto;
}
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
button,
input,
optgroup,
select,
textarea {
color: inherit;
font: inherit;
margin: 0;
}
button {
overflow: visible;
}
button,
select {
text-transform: none;
}
button,
html input[type="button"],
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button;
cursor: pointer;
}
button[disabled],
html input[disabled] {
cursor: default;
}
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
input {
line-height: normal;
}
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box;
padding: 0;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto;
}
input[type="search"] {
-webkit-appearance: textfield;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
legend {
border: 0;
padding: 0;
}
textarea {
overflow: auto;
}
optgroup {
font-weight: bold;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
td,
th {
padding: 0;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html {
font-size: 10px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
input,
button,
select,
textarea {
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
figure {
margin: 0;
}
img {
/*vertical-align: middle;*/
}

BIN
assets/img/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets/img/img-blank.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
assets/img/loader.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

343
assets/js/examples.js Normal file
View file

@ -0,0 +1,343 @@
// some regular checking
var isIE = /ie/.test(document.documentElement.className),
isIE8 = /ie8/.test(document.documentElement.className),
isIE9 = /ie9/.test(document.documentElement.className);
/* TRANSFORMS EXAMPLES */
var featurettes = document.querySelectorAll('.featurettes'), fl = featurettes.length;
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);
}
}
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 */
/* CHAINED TWEENS EXAMPLE */
var chainedTweens = document.getElementById('chainedTweens'),
el1 = chainedTweens.querySelectorAll('.example-item')[0],
el2 = chainedTweens.querySelectorAll('.example-item')[1],
el3 = chainedTweens.querySelectorAll('.example-item')[2],
ctb = chainedTweens.querySelector('.btn');
// built the tween objects for element1
var tween11 = KUTE.fromTo(el1, {translateX:0, rotateX: 0}, {translateX:100, rotateX: 25}, {perspective:100, duration: 2000});
var tween12 = KUTE.fromTo(el1, {translateY:0, rotateY: 0}, {translateY:20, rotateY: 15}, {perspective:100, duration: 2000});
var tween13 = KUTE.fromTo(el1, {translate3d:[100,20,0], rotateX: 25, rotateY:15}, {translate3d:[0,0,0], rotateX: 0, rotateY:0}, {perspective:100, duration: 2000});
// chain tweens
tween11.chain(tween12);
tween12.chain(tween13);
// built the tween objects for element2
var tween21 = KUTE.fromTo(el2, {translateX:0, translateY:0, rotateX: 0, rotateY:0 }, {translateX:150, translateY:0, rotateX: 25, rotateY:0}, {perspective:100, duration: 2000});
var tween22 = KUTE.fromTo(el2, {translateX:150, translateY:0, rotateX: 25, rotateY: 0}, {translateX:150, translateY:20, rotateX: 25, rotateY: 15}, {perspective:100, duration: 2000});
var tween23 = KUTE.fromTo(el2, {translate3d:[150,20,0], rotateX: 25, rotateY:15}, {translate3d:[0,0,0], rotateX: 0, rotateY:0}, {perspective:100, duration: 2000});
// chain tweens
tween21.chain(tween22);
tween22.chain(tween23);
// built the tween objects for element3
var tween31 = KUTE.to(el3,{translateX:200, rotateX: 25}, {perspective:100, duration: 2000});
var tween32 = KUTE.to(el3,{translate3d:[200,20,0], rotateY: 15}, {perspective:100, duration: 2000});
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);
ctb.addEventListener('click',function(e){
e.preventDefault();
tween11.start(); tween21.start(); tween31.start();
},false);
/* CHAINED TWEENS EXAMPLE */
/* BOX MODEL EXAMPLE */
var boxModel = document.getElementById('boxModel'),
btb = boxModel.querySelector('.btn'),
box = boxModel.querySelector('.example-box');
// built the tween objects
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});
// 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'; }
btb.addEventListener('click', function(e){
e.preventDefault();
bm1.start();
btb.style.display='none';
},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'),
colbtn = colBox.querySelector('.btn');
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});
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();
},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");
// create values and options objects
var startValues = {}, endValues = {}, options = {};
// here we define properties that are commonly supported
startValues.opacity = 1; endValues.opacity = 0.5;
startValues.backgroundColor = '#ffd626'; endValues.backgroundColor = '#ec1e71';
// here we define the properties according to the target browsers
if (isIE8) { // or any other browser that doesn"t support transforms
startValues.left = 0; endValues.left = 250;
} else if (isIE9) { // or any other browser that only support 2d transforms
startValues.translate = 0; endValues.translate = 250; // 2d translate on X axis
startValues.rotate = 0; endValues.rotate = 180; // 2d rotation on Z axis
startValues.scale = 1; endValues.scale = 1.5; // 2d scale
} else { // most modern browsers
startValues.translate3d = [0,0,0]; endValues.translate3d = [250,0,0]; //3d translation on X axis
startValues.rotateZ = 0; endValues.rotateZ = 180; // 3d rotation on Z axis
startValues.rotateX = 0; endValues.rotateX = -70; // 3d rotation on X axis
startValues.scale = 1; endValues.scale = 1.5; // 2d scale
options.perspective = 600; // 3d transform option
}
// common tween options
options.easing = "easingSinusoidalInOut";
options.yoyo = true;
options.repeat = 1;
options.duration = 2500;
// the cached object
var myTween = KUTE.fromTo(element, startValues, endValues, options);
// trigger buttons
var startButton = document.getElementById('startButton'),
stopButton = document.getElementById('stopButton'),
playPauseButton = document.getElementById('playPauseButton');
// add handlers for the trigger buttons
startButton.addEventListener('click', function(e){
e.preventDefault();
if (!myTween.playing) { myTween.start(); }
}, false);
stopButton.addEventListener('click', function(e){
e.preventDefault();
if (myTween.playing) { myTween.stop(); }
}, false);
playPauseButton.addEventListener('click', function(e){
e.preventDefault();
if (!myTween.paused && myTween.playing) {
myTween.pause(); playPauseButton.innerHTML = 'Resume';
playPauseButton.className = playPauseButton.className.replace('btn-orange','btn-olive');
} else {
myTween.resume();
playPauseButton.innerHTML = 'Pause';
playPauseButton.className = playPauseButton.className.replace('btn-olive','btn-orange');
}
}, false);
/* CROSS BROWSER EXAMPLE */

97
assets/js/home.js Normal file
View file

@ -0,0 +1,97 @@
// vars
var block = document.getElementById('blocks'),
bs = block.querySelectorAll('.bg'),
b = block.querySelector('.bg'),
isIE = /ie/.test(document.documentElement.className),
isIE8 = /ie8/.test(document.documentElement.className),
isIE10 = /MSIE|10.0/.test(navigator.userAgent),
replay = document.querySelector('.btn.replay');
// resize and show the blocks
window.addEventListener('load',resizeHandler,false);
window.addEventListener('load',showBlocks,false);
window.addEventListener('resize',resizeHandler,false);
replay.addEventListener('click',runOnClick,false);
function resizeHandler(e) {
var css = window.getComputedStyle(b),
bw = parseInt(css.width), i = 0;
for (i;i<9;i++){
bs[i].style.minHeight = bw+'px';
if (e.type==='load'){
bs[i].style.left = -bw+'px';
}
}
}
function showBlocks() {
var i = 0, dl, css = window.getComputedStyle(b),
bw = parseInt(css.width), d = isIE || (/%/.test(css.width)) ? 300 : bw*3, ra, fn;
for (i;i<9;i++){
if ( i === 0 || i === 3 || i === 6 ) {
dl = 200 + i*bw;
} else if ( i === 1 || i === 4 || i === 7 ) {
dl = 400 + i*bw;
} else if ( i === 2 || i === 5 || i === 8 ) {
dl = 600 + i*bw;
}
fn = i === 0 ? openTheAnimations : null;
ra = i === 8 ? runAnimations : null;
KUTE.to(bs[i], {opacity:1,left:0}, {duration: d, delay: dl, complete: ra, easing: 'easingQuadraticOut', start: fn}).start();
}
}
function runOnClick() {
if ( !/animating/.test(block.className) ) {
runAnimations();
}
}
function doBlockAnimations() {
var i = 0;
for (i;i<9;i++){
var rd = getRandomInt(-300,300), rs = getRandomInt(0.1,5), sc = parseFloat(rs*0.5),
fn = i===8 ? closeTheAnimations : null,
t1 = KUTE.to(bs[i], { translate:rd}, { duration:1500, easing: 'easingQuadraticInOut', delay: 1500 }),
t2 = KUTE.to(bs[i], { rotate:720}, { duration:1500, easing: 'easingQuadraticOut' }),
t3 = KUTE.fromTo(bs[i], { translate:rd, borderRadius: '0%', scale:1, rotate:720}, { borderRadius: '100%', translate:rd, scale:rs, rotate:0}, { duration:1000, easing: 'easingQuadraticOut' }),
t4 = KUTE.to(bs[i], { scale: sc}, { duration:1000, easing: 'easingQuadraticIn' }),
t5 = KUTE.fromTo(bs[i], { translate:rd, borderRadius: '100%', scale:sc }, { translate:0, borderRadius: '0%', scale:1 }, { delay: 100, duration:1500, easing: 'easingBounceOut' }),
t6 = KUTE.to(bs[i], { backgroundColor: '#fff'}, { easing: 'easingCircularOut', delay: 550+i*50, duration:450, yoyo: true, repeat: 1, complete: fn });
// t6.start();
t1.start();
t1.chain(t2);
t2.chain(t3);
t3.chain(t4);
t4.chain(t5);
t5.chain(t6);
}
}
function openTheAnimations() {
if (!/animating/.test(block.className)){
replay.style.display = 'none';
block.className += ' animating';
}
}
function closeTheAnimations() {
if (/animating/.test(block.className)){
replay.style.display = 'inline';
block.className = block.className.replace( ' animating', '');
}
}
function runAnimations() {
var t1 = KUTE.fromTo(block,{left:0},{left:150},{duration:1000, easing: 'easingCubicIn', start: openTheAnimations}).start(),
t2 = KUTE.fromTo(block,{left:150},{left:0},{duration:2500, easing: 'easingElasticOut', start: openTheAnimations}),
t3 = KUTE.fromTo(block,{rotateZ:0,rotateY:-10},{rotateZ:-20,rotateY:25},{duration:2500, easing: 'easingQuadraticInOut'}).start(),
t4 = KUTE.fromTo(block,{rotateZ:-20,rotateY:385},{rotateZ:0,rotateY:-10},{duration:3500, delay: 3600, easing: 'easingQuadraticInOut'});
t1.chain(t2);
t3.chain(t4);
doBlockAnimations();
}

376
assets/js/minifill.js Normal file
View file

@ -0,0 +1,376 @@
// Document
if (!this.Document){this.Document = this.HTMLDocument; }
// Element
if (!window.HTMLElement) { window.HTMLElement = window.Element; }
// Date.now
if(!Date.now){ Date.now = function now() { return new Date().getTime(); }; }
// performance.now
(function(){
if ("performance" in window == false) { window.performance = {}; }
if ("now" in window.performance == false){
var nowOffset = Date.now();
window.performance.now = function now(){
return Date.now() - nowOffset;
}
}
})();
// Object.keys
if (!Object.keys) {
Object.keys = function(obj) {
var keys = [];
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
keys.push(i);
}
}
return keys;
};
}
// Array.prototype.indexOf
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function indexOf(searchElement) {
if (this === undefined || this === null) {
throw new TypeError(this + 'is not an object');
}
var arraylike = this instanceof String ? this.split('') : this,
length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
index = Number(arguments[1]) || 0;
index = (index < 0 ? Math.max(length + index, 0) : index) - 1;
while (++index < length) {
if (index in arraylike && arraylike[index] === searchElement) {
return index;
}
}
return -1;
};
}
// getComputedStyle
if (!('getComputedStyle' in window)) {
(function(){
function getComputedStylePixel(element, property, fontSize) {
// Internet Explorer sometimes struggles to read currentStyle until the element's document is accessed.
var value = element.document && element.currentStyle[property].match(/([\d\.]+)(%|cm|em|in|mm|pc|pt|)/) || [0, 0, ''],
size = value[1],
suffix = value[2],
rootSize;
fontSize = !fontSize ? fontSize : /%|em/.test(suffix) && element.parentElement ? getComputedStylePixel(element.parentElement, 'fontSize', null) : 16;
rootSize = property == 'fontSize' ? fontSize : /width/i.test(property) ? element.clientWidth : element.clientHeight;
return suffix == '%' ? size / 100 * rootSize :
suffix == 'cm' ? size * 0.3937 * 96 :
suffix == 'em' ? size * fontSize :
suffix == 'in' ? size * 96 :
suffix == 'mm' ? size * 0.3937 * 96 / 10 :
suffix == 'pc' ? size * 12 * 96 / 72 :
suffix == 'pt' ? size * 96 / 72 :
size;
}
function setShortStyleProperty(style, property) {
var borderSuffix = property == 'border' ? 'Width' : '',
t = property + 'Top' + borderSuffix,
r = property + 'Right' + borderSuffix,
b = property + 'Bottom' + borderSuffix,
l = property + 'Left' + borderSuffix;
style[property] = (style[t] == style[r] && style[t] == style[b] && style[t] == style[l] ? [ style[t] ] :
style[t] == style[b] && style[l] == style[r] ? [ style[t], style[r] ] :
style[l] == style[r] ? [ style[t], style[r], style[b] ] :
[ style[t], style[r], style[b], style[l] ]).join(' ');
}
// <CSSStyleDeclaration>
function CSSStyleDeclaration(element) {
var style = this,
currentStyle = element.currentStyle,
fontSize = getComputedStylePixel(element, 'fontSize'),
unCamelCase = function (match) {
return '-' + match.toLowerCase();
},
property;
for (property in currentStyle) {
Array.prototype.push.call(style, property == 'styleFloat' ? 'float' : property.replace(/[A-Z]/, unCamelCase));
if (property == 'width') {
style[property] = element.offsetWidth + 'px';
} else if (property == 'height') {
style[property] = element.offsetHeight + 'px';
} else if (property == 'styleFloat') {
style.float = currentStyle[property];
} else if (/margin.|padding.|border.+W/.test(property) && style[property] != 'auto') {
style[property] = Math.round(getComputedStylePixel(element, property, fontSize)) + 'px';
} else if (/^outline/.test(property)) {
// errors on checking outline
try {
style[property] = currentStyle[property];
} catch (error) {
style.outlineColor = currentStyle.color;
style.outlineStyle = style.outlineStyle || 'none';
style.outlineWidth = style.outlineWidth || '0px';
style.outline = [style.outlineColor, style.outlineWidth, style.outlineStyle].join(' ');
}
} else {
style[property] = currentStyle[property];
}
}
setShortStyleProperty(style, 'margin');
setShortStyleProperty(style, 'padding');
setShortStyleProperty(style, 'border');
style.fontSize = Math.round(fontSize) + 'px';
}
CSSStyleDeclaration.prototype = {
constructor: CSSStyleDeclaration,
// <CSSStyleDeclaration>.getPropertyPriority
getPropertyPriority: function () {
throw new Error('NotSupportedError: DOM Exception 9');
},
// <CSSStyleDeclaration>.getPropertyValue
getPropertyValue: function (property) {
return this[property.replace(/-\w/g, function (match) {
return match[1].toUpperCase();
})];
},
// <CSSStyleDeclaration>.item
item: function (index) {
return this[index];
},
// <CSSStyleDeclaration>.removeProperty
removeProperty: function () {
throw new Error('NoModificationAllowedError: DOM Exception 7');
},
// <CSSStyleDeclaration>.setProperty
setProperty: function () {
throw new Error('NoModificationAllowedError: DOM Exception 7');
},
// <CSSStyleDeclaration>.getPropertyCSSValue
getPropertyCSSValue: function () {
throw new Error('NotSupportedError: DOM Exception 9');
}
};
// <Global>.getComputedStyle
window.getComputedStyle = function getComputedStyle(element) {
return new CSSStyleDeclaration(element);
};
})();
}
// 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;
if ( 'createEvent' in document ) {
ev = document.createEvent('Event');
ev.initEvent(t, b, c);
} else {
ev = document.createEventObject();
ev.type = t;
ev.bubbles = b;
ev.cancelable = c;
}
return ev;
};
})();
}
// 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) {
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;
};
})()
}
// addEventListener
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
if (!el._events) { el._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;
}
};
e.stopPropagation = function stopPropagation() {
e.cancelBubble = true;
};
e.stopImmediatePropagation = function stopImmediatePropagation() {
e.cancelBubble = true;
e.cancelImmediate = true;
};
e.currentTarget = el;
e.relatedTarget = e.fromElement || null;
e.target = e.target || e.srcElement || el;
e.timeStamp = new Date().getTime();
if (e.clientX) {
e.pageX = e.clientX + document.documentElement.scrollLeft;
e.pageY = e.clientY + document.documentElement.scrollTop;
}
while (++i < lg && !e.cancelImmediate) {
if (i in evs) {
eE = evs[i];
if (ls.indexOf(eE) !== -1 && typeof eE === 'function') {
eE.call(el, e);
}
}
}
};
el._events[t].list = [];
if (el.attachEvent) {
el.attachEvent('on' + t, el._events[t]);
}
}
el._events[t].list.push(l);
};
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);
if (i !== -1) {
el._events[t].list.splice(i, 1);
if (!el._events[t].list.length) {
if (el.detachEvent) {
el.detachEvent('on' + t, el._events[t]);
}
delete el._events[t];
}
}
}
};
})();
}
// 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) {
if (!arguments.length) {
throw new Error('Not enough arguments');
}
if (!e || typeof e.type !== 'string') {
throw new Error('DOM Events Exception 0');
}
var el = this, t = e.type; // element | event type
try {
if (!e.bubbles) {
e.cancelBubble = true;
var cancelBubbleEvent = function (event) {
event.cancelBubble = true;
(el || window).detachEvent('on' + t, cancelBubbleEvent);
};
this.attachEvent('on' + t, cancelBubbleEvent);
}
this.fireEvent('on' + t, e);
} catch (error) {
e.target = el;
do {
e.currentTarget = el;
if ('_events' in el && typeof el._events[t] === 'function') {
el._events[t].call(el, e);
}
if (typeof el['on' + t] === 'function') {
el['on' + t].call(el, e);
}
el = el.nodeType === 9 ? el.parentWindow : el.parentNode;
} while (el && !e.cancelBubble);
}
return true;
};
})();
}

178
assets/js/perf.js Normal file
View file

@ -0,0 +1,178 @@
//returns browser prefix
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'];
for (i; i < pl; i++) { if (s[i] in div.style) { return pf[i]; } }
div = null;
}
// generate a random number within a given range
function random(min, max) {
return Math.random() * (max - min) + min;
}
// vendor prefix handle
var prefix = getPrefix(), // prefix
prefixRequired = (!('transform' in document.getElementsByTagName('div')[0].style)) ? true : false, // is prefix required for transform
transformProperty = prefixRequired ? prefix + 'Transform' : 'transform';
// the variables
var container = document.getElementById('container'),
easing = 'easingQuadraticInOut',
tweens = [];
function createTest(count, property, engine, repeat, hack) {
for (var i = 0; i < count; i++) {
var tween,
div = document.createElement('div'),
windowHeight = document.documentElement.clientHeight - 10,
left = random(-200, 200),
toLeft = random(-200, 200),
top = Math.round(Math.random() * parseInt(windowHeight)),
background = 'rgb('+parseInt(random(0, 255))+','+parseInt(random(0, 255))+','+parseInt(random(0, 255))+')',
fromValues, toValues, fn = i===count-1 ? complete : null;
repeat = parseInt(repeat);
div.className = 'line';
div.style.top = top + 'px';
div.style.backgroundColor = background;
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 {
div.style[transformProperty] = 'translate3d('+left + 'px,0px,0px)';
if (engine==="kute"){
fromValues = { translateX: left }
toValues = { translateX: toLeft }
} else if ((engine==="gsap") || (engine==="tween")) {
fromValues = engine==='gsap' ? { x: left } : { x: left, div : div }
toValues = { x: toLeft }
}
}
container.appendChild(div);
// 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);
} 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 });
} else {
tween = 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';
}
} else if (property==="translateX"){
update = function(){
this.div.style[transformProperty] = 'translate3d('+this.x + 'px,0px,0px)';
}
}
tween = new TWEEN.Tween(fromValues)
.to(toValues,1000)
.easing( TWEEN.Easing.Quadratic.InOut )
.onComplete( complete )
.onUpdate( update)
.repeat(repeat)
.yoyo(true);
tweens.push(tween);
}
}
if (engine==='tween') {
animate();
function animate( time ) {
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)
}
}
}
function complete(){
document.getElementById('info').style.display = 'block';
container.innerHTML = '';
tweens = [];
}
//some button toggle
var btnGroups = document.querySelectorAll('.btn-group'), l = btnGroups.length;
for (var i=0; i<l; i++) {
var g = btnGroups[i], links = g.querySelectorAll('a'), ll = links.length;
for (var j=0; j<ll; j++) {
links[j].onclick = function() {
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(){
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';
createTest(count,property,engine,repeat,hack);
} else {
if (!count && !property && !repeat && !engine){
warning.innerHTML = 'We are missing all the settings here.';
} else {
warning.innerHTML = 'Now missing<br>';
warning.innerHTML += !engine ? '- engine<br>' : '';
warning.innerHTML += !property ? '- property<br>' : '';
warning.innerHTML += !repeat ? '- repeat<br>' : '';
warning.innerHTML += !count ? '- count<br>' : '';
}
container.appendChild(warning);
}
}

6
assets/js/prism.js Normal file
View file

@ -0,0 +1,6 @@
/* http://prismjs.com/download.html?themes=prism-okaidia&languages=markup+css+clike+javascript */
var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var a={};for(var r in e)e.hasOwnProperty(r)&&(a[r]=t.util.clone(e[r]));return a;case"Array":return e.map&&e.map(function(e){return t.util.clone(e)})}return e}},languages:{extend:function(e,n){var a=t.util.clone(t.languages[e]);for(var r in n)a[r]=n[r];return a},insertBefore:function(e,n,a,r){r=r||t.languages;var l=r[e];if(2==arguments.length){a=arguments[1];for(var i in a)a.hasOwnProperty(i)&&(l[i]=a[i]);return l}var o={};for(var s in l)if(l.hasOwnProperty(s)){if(s==n)for(var i in a)a.hasOwnProperty(i)&&(o[i]=a[i]);o[s]=l[s]}return t.languages.DFS(t.languages,function(t,n){n===r[e]&&t!=e&&(this[t]=o)}),r[e]=o},DFS:function(e,n,a){for(var r in e)e.hasOwnProperty(r)&&(n.call(e,r,e[r],a||r),"Object"===t.util.type(e[r])?t.languages.DFS(e[r],n):"Array"===t.util.type(e[r])&&t.languages.DFS(e[r],n,r))}},plugins:{},highlightAll:function(e,n){for(var a,r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),l=0;a=r[l++];)t.highlightElement(a,e===!0,n)},highlightElement:function(n,a,r){for(var l,i,o=n;o&&!e.test(o.className);)o=o.parentNode;o&&(l=(o.className.match(e)||[,""])[1],i=t.languages[l]),n.className=n.className.replace(e,"").replace(/\s+/g," ")+" language-"+l,o=n.parentNode,/pre/i.test(o.nodeName)&&(o.className=o.className.replace(e,"").replace(/\s+/g," ")+" language-"+l);var s=n.textContent,u={element:n,language:l,grammar:i,code:s};if(!s||!i)return t.hooks.run("complete",u),void 0;if(t.hooks.run("before-highlight",u),a&&_self.Worker){var g=new Worker(t.filename);g.onmessage=function(e){u.highlightedCode=e.data,t.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,r&&r.call(u.element),t.hooks.run("after-highlight",u),t.hooks.run("complete",u)},g.postMessage(JSON.stringify({language:u.language,code:u.code,immediateClose:!0}))}else u.highlightedCode=t.highlight(u.code,u.grammar,u.language),t.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,r&&r.call(n),t.hooks.run("after-highlight",u),t.hooks.run("complete",u)},highlight:function(e,a,r){var l=t.tokenize(e,a);return n.stringify(t.util.encode(l),r)},tokenize:function(e,n){var a=t.Token,r=[e],l=n.rest;if(l){for(var i in l)n[i]=l[i];delete n.rest}e:for(var i in n)if(n.hasOwnProperty(i)&&n[i]){var o=n[i];o="Array"===t.util.type(o)?o:[o];for(var s=0;s<o.length;++s){var u=o[s],g=u.inside,c=!!u.lookbehind,f=0,h=u.alias;u=u.pattern||u;for(var p=0;p<r.length;p++){var d=r[p];if(r.length>e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),P=[p,1];b&&P.push(b);var A=new a(i,g?t.tokenize(m,g):m,h);P.push(A),w&&P.push(w),Array.prototype.splice.apply(r,P)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,l=0;r=a[l++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var l={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==l.type&&(l.attributes.spellcheck="true"),e.alias){var i="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(l.classes,i)}t.hooks.run("wrap",l);var o="";for(var s in l.attributes)o+=(o?" ":"")+s+'="'+(l.attributes[s]||"")+'"';return"<"+l.tag+' class="'+l.classes.join(" ")+'" '+o+">"+l.content+"</"+l.tag+">"},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code,l=n.immediateClose;_self.postMessage(t.highlight(r,t.languages[a],a)),l&&_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism);
Prism.languages.markup={comment:/<!--[\w\W]*?-->/,prolog:/<\?[\w\W]+?\?>/,doctype:/<!DOCTYPE[\w\W]+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[^\s>\/=.]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&amp;/,"&"))}),Prism.languages.xml=Prism.languages.markup,Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup;
Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},Prism.languages.css.atrule.inside.rest=Prism.util.clone(Prism.languages.css),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/(<style[\w\W]*?>)[\w\W]*?(?=<\/style>)/i,lookbehind:!0,inside:Prism.languages.css,alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag));
Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/};
Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","class-name",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<script[\w\W]*?>)[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:Prism.languages.javascript,alias:"language-javascript"}}),Prism.languages.js=Prism.languages.javascript;

14
assets/js/scripts.js Normal file
View file

@ -0,0 +1,14 @@
// common demo JS
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
//scroll top?
var toTop = document.getElementById('toTop');
toTop.addEventListener('click',topHandler,false);
function topHandler(e){
e.preventDefault();
KUTE.to( 'window', { scroll: 0 }, {easing: 'easingQuarticOut', duration : 1500 } ).start();
}

2
assets/js/tween.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

10
dist/kute.jquery.js vendored
View file

@ -1,10 +0,0 @@
// KUTE jQuery Plugin for kute.js | by dnp_theme | License - MIT
// $('selector').Kute(options);
(function($) {
$.fn.Kute = function( options ) {
return this.each(function(){
new KUTE.Animate( this, options );
});
};
})(jQuery);

2
dist/kute.min.js vendored

File diff suppressed because one or more lines are too long

470
examples.html Normal file
View file

@ -0,0 +1,470 @@
<!DOCTYPE html>
<!--[if IE 7]><html class="ie ie7" lang="en"><![endif]-->
<!--[if IE 8]><html class="ie ie8" lang="en"><![endif]-->
<!--[if IE 9]><html class="ie ie9" lang="en"><![endif]-->
<!--[if gte IE 10 | !IE ]><!--> <html lang="en"> <!--<![endif]-->
<head>
<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="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 Examples | Javascript Animation Engine</title>
<!-- RESET CSS -->
<link type="text/css" href="./assets/css/reset.css" rel="stylesheet">
<!-- DEMO KUTE CSS -->
<link type="text/css" href="./assets/css/kute.css" rel="stylesheet">
<!-- Ion Icons -->
<link type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<!-- legacy browsers support via polyfill
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,getComputedStyle|gated"> </script> -->
<!--[if IE]>
<script src="./assets/js/minifill.js"> </script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="fill overlay"></div>
<div class="site-wrapper">
<div class="navbar-wrapper">
<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><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>
<h3>Basic Native Javascript Example</h3>
<p>When developing with native Javascript, a very basic syntax goes like this:</p>
<pre>
<code class="language-javascript">// this is the tween object, basically KUTE.method(element, from, to, options);
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>
<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>
<p>KUTE.js includes a jQuery plugin to help you easily implement KUTE.js in your jQuery applications. When using jQuery, the syntax is familiar but works a bit different than plain Javascript due to jQuery's specific code standards. Let's have a look:</p>
<pre><code class="language-javascript">// this is the tween object, basically $('selector').KUTE(method, from, to, options);
var tween = $('selector').KUTE('fromTo', {top: 20}, {top: 100}, {yoyo: true});
</code></pre>
<p>We mentioned that the KUTE jQuery plugin is different, and here's why: the above code creates an <code>Array</code> of objects for each <code>HTML</code> element of chosen selector, while the Native Javascript creates a single object. For these objects we can now apply the tween control methods as follows:</p>
<pre><code class="language-javascript">$(tween).KUTE('start'); // starts the animation
$(tween).KUTE('stop'); // stops current tween and all chained tweens animating
$(tween).KUTE('pause'); // pauses current tween animation
$(tween).KUTE('play'); // or $(myTween).KUTE('resume'); resumes current tween animation
$(tween).KUTE('chain',myTween2); // 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/dYXLyj" target="_blank">here</a>.</p>
<h2>Transform Properties Examples</h2>
<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>
<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});
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 class="example-buttons">
<a class="btn btn-blue" href="#">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>
<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>
<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 class="example-buttons">
<a class="btn btn-green" href="#">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>
<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>
<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 class="example-buttons">
<a class="btn btn-yellow" href="#">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>
<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();
var tween2 = KUTE.fromTo('selector1',{skewY:0},{skewY:45}).start();
</code></pre>
<p>If you check the <a href="http://codepen.io/thednp/pen/avZrYo" target="_blank">test here</a>, you will notice that only the <code>skewY</code> is going to work and no rotation. Now let's do this properly.</p>
<pre><code class="language-javascript">var tween1 = KUTE.fromTo(
'selector1', // element
{translateX:0, rotateX:0, rotateY:0, rotateZ:0}, // from
{translateX:250, rotateX:360, rotateY:15, rotateZ:5}, // to
{perspective:400, perspectiveOrigin: 'center top'} // trasform options
);
var tween2 = KUTE.fromTo(
'selector2', // element
{translateX:0, rotateX:0, rotateY:0, rotateZ:0}, // from values
{translateX:-250, rotateX:360, rotateY:15, rotateZ:5}, // to values
{parentPerspective:400, parentPerspectiveOrigin: 'center top'} // trasform options
);
</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 class="example-buttons">
<a class="btn btn-olive" href="#">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>
<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>
<div class="example-item example-box bg-indigo" style="font-size: 30px">TO</div>
<div class="example-buttons">
<a class="btn btn-blue" href="#">Start</a>
</div>
</div>
<p>What's this all about?</p>
<ul>
<li>the first box uses a regular <code class="bg-gray">.fromTo()</code> object, we are doing things normally, we would expect them to work properly but due to the nature of the transforms, this is what it does</li>
<li>the second box is also using <code class="bg-olive">.fromTo()</code> object, but using proper values for all tweens at all times, so we fixed that glitch</li>
<li>and the last box uses the <code class="bg-indigo">.to()</code> method, and does the chaining easier for most properties, especially for <code>transform</code></li>
</ul>
<p>When coding transformation chains I would highly recommend:</p>
<ul>
<li>keep the same order of the transform properties, best would be: translation, rotation, skew and scale; an example of the difference shown <a href="http://jsfiddle.net/nvy26bgb/" target="_blank">here</a> for rotations and <a href="http://jsfiddle.net/nvy26bgb/1/" target="_blank">here</a> for rotations and skew;</li>
<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>
<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>
<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">
<div class="example-item example-box bg-lime" style="line-height: 75px; font-size:30px">BOX MODEL</div>
<div class="example-buttons">
<a class="btn btn-orange" href="#">Start</a>
</div>
</div>
<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();
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();
</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-buttons">
<a class="btn btn-blue" href="#">Start</a>
</div>
</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>
<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
</code></pre>
<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>
<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, first check your HTML template to have the browser detection for IE8-IE9, then check to have the 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>
<pre><code class="language-javascript">// grab an HTML element to build a tween object for it
var element = document.getElementById("myElement");
// check for IE legacy browsers
var isIE8 = /ie8/.test(document.documentElement.className);
var isIE9 = /ie9/.test(document.documentElement.className);
// most browsers have specific checks, so make sure
// you include all you need for your target audience
</code></pre>
<h3>Define Properties And Options Objects</h3>
<pre><code class="language-javascript">// create values and options objects
var startValues = {};
var endValues = {};
var options = {};
// here we define properties that are commonly supported
startValues.opacity = 1;
endValues.opacity = 0.5;
startValues.backgroundColor = '#CDDC39';
endValues.backgroundColor = '#ec1e71';
// here we define the properties according to the target browsers
if (isIE8) { // or any other browser that doesn"t support transforms
startValues.left = 0;
endValues.left = 250;
} else if (isIE9) { // or any other browser that only support 2d transforms
startValues.translate = 0; // 2d translate on X axis
endValues.translate = 250;
startValues.rotate = -180; // 2d rotation on Z axis
endValues.rotate = 0;
startValues.scale = 1; // 2d scale
endValues.scale = 1.5;
} else { // most modern browsers
startValues.translate3d = [0,0,0]; //3d translation on X axis
endValues.translate3d = [250,0,0];
startValues.rotateZ = -180; // 3d rotation on Z axis
endValues.rotateZ = 0;
startValues.rotateX = -20; // 3d rotation on X axis
endValues.rotateX = 0;
startValues.scale = 1; // 2d scale
endValues.scale = 1.5;
options.perspective = 400; // 3d transform option
}
// common tween options
options.easing = "easingCubicOut";
options.duration = 2500;
</code></pre>
<h3>Build Tween Object And Tween Controls</h3>
<pre><code class="language-javascript">// the cached object
var myTween = KUTE.fromTo(element, startValues, endValues, options);
// trigger buttons
var startButton = document.getElementById('startButton'),
stopButton = document.getElementById('stopButton'),
playPauseButton = document.getElementById('playPauseButton');
// add handlers for the trigger buttons
startButton.addEventListener('click', function(e){
e.preventDefault();
if (!myTween.playing) { myTween.start(); } // only start the animation if hasn't started yet
}, false);
stopButton.addEventListener('click', function(e){
e.preventDefault();
if (myTween.playing) { myTween.stop(); } // only stop the animation if there is any
}, false);
playPauseButton.addEventListener('click', function(e){
e.preventDefault();
if (!myTween.paused && myTween.playing) {
myTween.pause(); playPauseButton.innerHTML = 'Resume';
} else {
myTween.resume();
playPauseButton.innerHTML = 'Pause';
}
}, false);
</code></pre>
<h3>Live Demo</h3>
<div class="featurettes" id="crossBrowser">
<div id="myElement" class="example-item example-box bg-yellow">
</div>
<div class="example-buttons">
<a id="playPauseButton" class="btn btn-orange" href="#">Pause</a>
<a id="startButton" class="btn btn-blue" href="#">Start</a>
<a id="stopButton" class="btn btn-red" href="#">Stop</a>
</div>
</div>
<p>Let's explain this code a bit. KUTE.js comes gives you the internal variables <code>myTween.playing</code> and <code>myTween.paused</code> (both true/false) to help you easily manage the tween control methods all together as in this example here. As said before, KUTE.js version 0.9.5 doesn't stat animating by default, for all the examples on this page you have to start it yourself, unlike their versions hosted on Codepen.</p>
<ul>
<li>the <code class="bg-blue">START</code> button will use the <code>.start()</code> method and the animation starts;</li>
<li>the <code class="bg-red">STOP</code> button will use the <code>.stop()</code> method and stops the animation; after this the, animation can only be started again</li>
<li>the <code class="bg-orange">PAUSE</code> button will use the <code>.pause()</code> method and pauses the animation; this also changes the button's text and functionality;</li>
<li>the <code class="bg-olive">RESUME</code> button will use the <code>.resume()</code> method and resumes the animation; this reverses the button's initial state;</li>
<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>
<ul id="share" class="nav">
<li>Share </li>
<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>
</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>
</div>
</footer>
</div><!-- /.site-wrapper -->
<!-- JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- highlighter -->
<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-keys.js"></script> some stuff -->
<script src="./assets/js/scripts.js"></script> <!-- global scripts stuff -->
<script src="./assets/js/examples.js"></script> <!-- examples stuff -->
</body>
</html>

217
features.html Normal file
View file

@ -0,0 +1,217 @@
<!DOCTYPE html>
<!--[if IE 7]><html class="ie ie7" lang="en"><![endif]-->
<!--[if IE 8]><html class="ie ie8" lang="en"><![endif]-->
<!--[if IE 9]><html class="ie ie9" lang="en"><![endif]-->
<!--[if gte IE 9 | !IE ]><!--> <html lang="en"> <!--<![endif]-->
<head>
<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="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 Features | Javascript Animation Engine</title>
<!-- RESET CSS -->
<link type="text/css" href="./assets/css/reset.css" rel="stylesheet">
<!-- DEMO KUTE CSS -->
<link type="text/css" href="./assets/css/kute.css" rel="stylesheet">
<!-- Ion Icons -->
<link type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
<!-- legacy browsers support via polyfill
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,getComputedStyle|gated"> </script> -->
<!--[if IE]>
<script src="./assets/js/minifill.js"> </script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="fill overlay"></div>
<div class="site-wrapper">
<div class="navbar-wrapper">
<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><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div class="content-wrap">
<h2 id="performance">Delivering Killer Performance</h2>
<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>
<p>To learn more about how performance can vary from case to case, check out <a href="about.html#performance">this secion</a>, it's very informative.</p>
</div>
<div class="content-wrap">
<h2 id="prefix">Break Free Of Browser Prefixes</h2>
<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>
<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 an appropriate <code>HTML</code> template. 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>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, with distinctive functionalities.</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>
<p><kbd>KUTE.fromTo('selector', fromValues, toValues, options)</kbd> is the other method that's most powerful in terms of performance, flexibility and control on the animation. As an example, while the first method may not process properties' measurement units properly, this method will never fail in that regard, because you can set for both starting values and end values the exact values with the right unit you need.</p>
<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>
<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>
<h3>Tween Options</h3>
<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>
<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>
<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>
<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>
<ul id="share" class="nav">
<li>Share </li>
<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>
</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>
</div>
</footer>
</div><!-- /.site-wrapper -->
<!-- JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!--<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="./assets/js/scripts.js"></script> <!-- some stuff -->
</body>
</html>

189
index.html Normal file
View file

@ -0,0 +1,189 @@
<!DOCTYPE html>
<!--[if IE 7]><html class="ie ie7" lang="en"><![endif]-->
<!--[if IE 8]><html class="ie ie8" lang="en"><![endif]-->
<!--[if IE 9]><html class="ie ie9" lang="en"><![endif]-->
<!--[if gte IE 9 | !IE ]><!--> <html lang="en"> <!--<![endif]-->
<head>
<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="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 | Javascript Animation Engine</title>
<!-- RESET CSS -->
<link type="text/css" href="./assets/css/reset.css" rel="stylesheet">
<!-- DEMO KUTE CSS -->
<link type="text/css" href="./assets/css/kute.css" rel="stylesheet">
<!-- Ion Icons -->
<link type="text/css" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet">
<!-- legacy browsers support via polyfill
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=default,getComputedStyle|gated"> </script> -->
<!--[if IE]>
<script src="./assets/js/minifill.js"> </script>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<div class="fill overlay"></div>
<div class="site-wrapper">
<div class="navbar-wrapper">
<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><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div class="content-wrap">
<div class="columns welcome">
<div class="col2 table">
<div class="cell">
<h2 class="nomargin">Welcome Developers!</h2>
<p class="lead">KUTE.js is a Javascript animation engine with top performance, memory efficient &amp; modular code. It delivers a whole bunch of tools to help you create great custom animations.</p>
<p>
<a class="btn btn-blue" href="https://github.com/thednp/kute.js/archive/master.zip">Download</a>
<a class="btn" href="https://github.com/thednp/kute.js">Github</a>
<a class="btn" href="http://www.jsdelivr.com/#!kute.js">CDN</a>
<a class="btn btn-green replay" href="#">Replay</a>
</p>
</div>
</div>
<div class="col2 table">
<div class="cell">
<div id="blocks" class="columns nomargin">
<div class="col3 bg bg-yellow"></div>
<div class="col3 bg bg-orange"></div>
<div class="col3 bg bg-red"></div>
<div class="col3 bg bg-blue"></div>
<div class="col3 bg bg-olive"></div>
<div class="col3 bg bg-indigo"></div>
<div class="col3 bg bg-lime"></div>
<div class="col3 bg bg-green"></div>
<div class="col3 bg bg-teal"></div>
</div>
</div>
</div>
</div>
</div>
<div class="featurettes">
<div class="content-wrap">
<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>
</div>
<div class="col2">
<h3>Prefix Free</h3>
<p>KUTE.js can detect if the user's browser requires prefix and <a href="features.html#prefix">uses it accordingly</a> for <code>requestAnimationFrame</code>, <code>transform</code> and <code>border-radius</code>, hustle free for older Gecko/Webkit/IE browsers.</p>
</div>
</div>
<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 provided demo <code>HTML</code> templates 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>
</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>
</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>
</div>
</div>
<div class="columns hiddenoverflow">
<div class="col2">
<h3>MIT License</h3>
<p>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.</p>
</div>
<div class="col2">
<h3>Top Notch Documentation</h3>
<p>All examples, code, tips &amp; tricks are very well documented.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h2>Getting Started</h2>
<div class="columns hiddenoverflow">
<div class="col3">
<span class="ion-ios-game-controller-b media"></span>
<h3>Examples</h3>
<p>See <a href="examples.html">KUTE.js in action</a> with all it's functions, options and features.</p>
</div>
<div class="col3">
<span class="ion-ios-paper media"></span>
<h3>Documentation</h3>
<p>The <a href="api.html">API documentation</a> is here for you to get you started.</p>
</div>
<div class="col3">
<span class="ion-ios-pulse-strong media"></span>
<h3>Performance</h3>
<p class="marginbottom">Head over to the <a href="performance.html">performance</a> test page right away.</p>
</div>
</div>
<ul id="share" class="nav">
<li>Share </li>
<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>
</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>
</div>
</footer>
</div><!-- /.site-wrapper -->
<!-- JavaScript
================================================== -->
<!-- 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-keys.js"></script> <!-- KUTE local -->
<script src="./assets/js/home.js"></script> <!-- some stuff -->
<script src="./assets/js/scripts.js"></script> <!-- some stuff -->
</body>
</html>

View file

@ -1,811 +0,0 @@
// kute.full.js - The Light Tweening Engine | by dnp_theme
// http://themeforest.net/user/dnp_theme
// License - MIT
// KUTE MAIN OBJECT
var KUTE = KUTE || ( function () {
var _tweens = [];
return {
getAll: function () {
return _tweens;
},
removeAll: function () {
_tweens = [];
},
add: function ( tween ) {
_tweens.push( tween );
},
remove: function ( tween ) {
var i = _tweens.indexOf( tween );
if ( i !== -1 ) {
_tweens.splice( i, 1 );
}
},
update: function ( time ) {
if ( _tweens.length === 0 ) return false;
var i = 0;
time = time !== undefined ? time : window.performance.now();
while ( i < _tweens.length ) {
if ( _tweens[ i ].update( time ) ) {
i++;
} else {
_tweens.splice( i, 1 );
}
}
return true;
}
};
} )();
KUTE.Animate = function( object, options ) {
//element to animate
var el = typeof object === 'object' ? object : document.querySelector(object);
//get true scroll container and current scroll
var bd = document.body,
htm = document.getElementsByTagName('HTML')[0],
sct = /webkit/i.test(navigator.userAgent) || document.compatMode == 'BackCompat' ? bd : htm,
crs = window.pageYOffset || sct.scrollTop;
//determine if we're on IE or IE8
var isIE = document.documentElement.classList.contains('ie');
var isIE8 = document.documentElement.classList.contains('ie8');
//get element current style
var css = el.currentStyle || window.getComputedStyle(el);
// default values
var ops = {
from : {
opacity : 1, // integer
width : '', // integer/px/%
height : '', // integer/px/%
color : '', //hex/rgb
backgroundColor : '', //hex/rgb
position : {top:'',right:'',bottom:'',left:''}, // integer/%
backgroundPosition: {x:'',y:''}, // integer/%/string[left,center,bottom,etc]
translate : {x:0, y:0, z:0}, // integer only
rotate : {x:0, y:0, z:0}, // integer only
scale : 1, // integer only
scroll : crs, // integer only
},
to : {
opacity : '',
width : '',
height : '',
color : '',
backgroundColor : '',
position : {top:'',right:'',bottom:'',left:''},
backgroundPosition: {x: '', y: ''},
translate : {x:'', y:'', z:''},
rotate : {x:'', y:'', z:''},
scale : '',
scroll : '',
},
easing : KUTE.Easing.Linear.None, //pe('linear')
delay : 0,
duration : 500,
start : null, // run function when tween starts
finish : null, // run function when tween finishes
special : null // run function while tween runing
};
//override the default values with option values
for (var x in options) {
if(typeof(options[x]) === 'object'){
for (var y in options[x]){
ops[x][y] = options[x][y];
}
}else{
ops[x] = options[x];
}
}
//create shorthand for all properties
var ofo = ops.from.opacity;
var ofw = ops.from.width;
var ofh = ops.from.height;
var ofc = ops.from.color;
var ofbc = ops.from.backgroundColor;
var oft = ops.from.position.top;
var ofr = ops.from.position.right;
var ofb = ops.from.position.bottom;
var ofl = ops.from.position.left;
var ofbx = ops.from.backgroundPosition.x;
var ofby = ops.from.backgroundPosition.y;
var oftx = ops.from.translate.x;
var ofty = ops.from.translate.y;
var oftz = ops.from.translate.z;
var ofrx = ops.from.rotate.x;
var ofry = ops.from.rotate.y;
var ofrz = ops.from.rotate.z;
var ofs = ops.from.scale;
var ofsc = ops.from.scroll;
var oto = ops.to.opacity;
var otw = ops.to.width;
var oth = ops.to.height;
var otc = ops.to.color;
var otbc = ops.to.backgroundColor;
var ott = ops.to.position.top;
var otr = ops.to.position.right;
var otb = ops.to.position.bottom;
var otl = ops.to.position.left;
var otbx = ops.to.backgroundPosition.x;
var otby = ops.to.backgroundPosition.y;
var ottx = ops.to.translate.x;
var otty = ops.to.translate.y;
var ottz = ops.to.translate.z;
var otrx = ops.to.rotate.x;
var otry = ops.to.rotate.y;
var otrz = ops.to.rotate.z;
var ots = ops.to.scale;
var otsc = ops.to.scroll;
//process easing
var pes = typeof ops.easing === 'string' ? pe(ops.easing) : ops.easing;
//from/initial values
var icor = (cv(ofc) ? parseInt(pc(ofc)[0]) : '') || parseInt(pc(truC(css.color))[0]);
var icog = (cv(ofc) ? parseInt(pc(ofc)[1]) : '') || parseInt(pc(truC(css.color))[1]);
var icob = (cv(ofc) ? parseInt(pc(ofc)[2]) : '') || parseInt(pc(truC(css.color))[2]);
var ibcr = (cv(ofbc) ? parseInt(pc(ofbc)[0]) : '') || parseInt(pc(truC(css.backgroundColor))[0]);
var ibcg = (cv(ofbc) ? parseInt(pc(ofbc)[1]) : '') || parseInt(pc(truC(css.backgroundColor))[1]);
var ibcb = (cv(ofbc) ? parseInt(pc(ofbc)[2]) : '') || parseInt(pc(truC(css.backgroundColor))[2]);
var iwi = cv(ofw) ? truD(ofw)[0] : truD( css.width )[0];
var ihe = cv(ofh) ? truD(ofh)[0] : truD( css.height )[0];
var ito = cv(oft) ? truD(oft)[0] : '';
var iri = cv(ofr) ? truD(ofr)[0] : '';
var ibo = cv(ofb) ? truD(ofb)[0] : '';
var ile = cv(ofl) ? truD(ofl)[0] : '';
var ibx, iby, bx, by;
if ( cv( otbx ) || cv( otby ) ) {
ibx = cv( ofbx ) ? truX(ofbx) : bPos(el)[0];
iby = cv( ofby ) ? truY(ofby) : bPos(el)[1];
} else {
ibx = '';
iby = '';
}
var tr3d,tx,ty,tz,itx,ity,itz;
if ( cv( ottx ) || cv( otty ) || cv( ottz ) ) {
itx = cv(oftx) ? truD(oftx)[0] : 0;
ity = cv(ofty) ? truD(ofty)[0] : 0;
itz = cv(oftz) ? truD(oftz)[0] : 0;
} else {
itx = ''; ity = ''; itz = '';
}
var irx = cv(ofrx) ? parseInt(ofrx) :''; //always deg
var iry = cv(ofry) ? parseInt(ofry) :'';
var irz = cv(ofrz) ? parseInt(ofrz) :'';
var isa = parseFloat(ofs); // scale can be float
var iop = parseFloat(ofo); // opacity
var isc = parseInt(ofsc); // scroll
//target values
var cor = cv(otc) ? parseInt(pc(otc)[0]) : '';
var cog = cv(otc) ? parseInt(pc(otc)[1]) : '';
var cob = cv(otc) ? parseInt(pc(otc)[2]) : '';
var bcr = cv(otbc) ? parseInt(pc(otbc)[0]) : '';
var bcg = cv(otbc) ? parseInt(pc(otbc)[1]) : '';
var bcb = cv(otbc) ? parseInt(pc(otbc)[2]) : '';
var wi = cv( otw ) ? truD(otw)[0] : '';
var he = cv( oth ) ? truD(oth)[0] : '';
var top = cv(ott) ? truD(ott)[0] : '';
var ri = cv(otr) ? truD(otr)[0] : '';
var bo = cv(otb) ? truD(otb)[0] : '';
var le = cv(otl) ? truD(otl)[0] : '';
if ( cv( otbx ) || cv( otby ) ) {
bx = cv( otbx ) ? truX(otbx) : ibx;
by = cv( otby ) ? truY(otby) : iby;
} else {
bx = '';
by = '';
}
if ( cv( ottx ) || cv( otty ) || cv( ottz ) ) { // translate 3d
tx = cv( ottx ) ? truD(ottx)[0] : 0;
ty = cv( otty ) ? truD(otty)[0] : 0;
tz = cv( ottz ) ? truD(ottz)[0] : 0;
} else {
tx = ''; ty = ''; tz = '';
}
var rx = cv( otrx ) ? parseInt(otrx) : ''; // rotate
var ry = cv( otry ) ? parseInt(otry) : '';
var rz = cv( otrz ) ? parseInt(otrz) : '';
var sa = cv( ots ) ? parseFloat(ots) : ''; // scale values below 1 need to be reformated
var op = cv( oto ) ? parseFloat(oto) : ''; // opacity
var sc = cv( otsc ) ? parseInt(otsc) : ''; // scroll
//check unit
var wiu = cv( wi ) ? truD(otw)[1] : '';
var heu = cv( he ) ? truD(oth)[1] : '';
var tou = cv( ott ) ? truD(ott)[1] : '';
var riu = cv( otr ) ? truD(otr)[1] : '';
var bou = cv( otb ) ? truD(otb)[1] : '';
var leu = cv( otl ) ? truD(otl)[1] : '';
var txu = cv( tx ) ? truD(ottx)[1] : '';
var tyu = cv( ty ) ? truD(otty)[1] : '';
var tzu = cv( tz ) ? truD(ottz)[1] : '';
animateTween();
var from = { w: iwi, h: ihe, t: ito, r: iri, b: ibo, l: ile, colr: icor, colg: icog, colb: icob, bgr: ibcr, bgg: ibcg, bgb: ibcb, bgX: ibx, bgY: iby, scale: isa, trX: itx, trY: ity, trZ: itz, roX: irx, roY: iry, roZ: irz, opacity: iop, scroll: isc };
var target = { w: wi, h: he, t: top, r: ri, b: bo, l: le, colr: cor, colg: cog, colb: cob, bgr: bcr, bgg: bcg, bgb: bcb, bgX: bx, bgY: by, scale: sa, trX: tx, trY: ty, trZ: tz, roX: rx, roY: ry, roZ: rz, opacity: op, scroll: sc };
return new KUTE.Tween( from )
.to( target, ops.duration )
.delay( ops.delay )
.easing( pes )
.onStart( runStart )
.onUpdate(
function () {
//color and background-color
if ( cv(cor) ) { el.style.color = rth( parseInt(this.colr),parseInt(this.colg),parseInt(this.colb) ); }
if ( cv(bcr) ) { el.style.backgroundColor = rth( parseInt(this.bgr),parseInt(this.bgg),parseInt(this.bgb)); }
//translate3d
if ( cv(tx) || cv(ty) || cv(tz) ) {
tr3d = 'translate3d(' + ((this.trX + txu) || 0) + ',' + ((this.trY + tyu) || 0) + ',' + ((this.trZ + tzu) || 0) + ')';
} else { tr3d = ''; }
var roxt = cv(rx) ? ' rotateX(' + this.roX + 'deg)' : '';
var royt = cv(ry) ? ' rotateY(' + this.roY + 'deg)' : '';
var rozt = cv(rz) ? ' rotateZ(' + this.roZ + 'deg)' : '';
//scale
var sca = cv(sa) ? ' scale(' + this.scale + ')' : '';
//do a zoom for IE8
if (isIE8 && cv(sa)) {
el.style.zoom = this.scale;
}
//sum all transform
var transform = sca + tr3d + roxt + royt + rozt;
var perspective = parseInt(css.perspective)||'';
if ( cv(transform) ) { tr(transform,perspective) }
//dimensions
if ( cv(wi) ) { el.style.width = this.w + wiu; }
if ( cv(he) ) { el.style.height = this.h + heu; }
//positioning
if ( cv(top) ) { el.style.top = this.t + tou; }
if ( cv(ri ) ) { el.style.right = this.r + riu; }
if ( cv(bo ) ) { el.style.bottom = this.b + bou; }
if ( cv(le ) ) { el.style.left = this.l + leu; }
// scrolling
if ( cv(sc) ) { sct.scrollTop = this.scroll; }
//background position
if ( cv(bx) || cv(by) ) {
var bXX = this.bgX;
var bYY = this.bgY;
el.style.backgroundPosition = bXX.toString()+'% '+bYY.toString()+'%';
}
//opacity
if ( cv(op) ) { el.style.opacity = (this.opacity).toFixed(2); }
//do a filter opacity for IE8
if (isIE8 && cv(op)) {
el.style.filter = "alpha(opacity=" + parseInt(100 * this.opacity) + ")"
}
//run special function onUpdate
if ( ops.special && typeof ops.special === "function") { ops.special(); }
}
)
.onComplete( runFinished )
.start();
function animateTween(time) {
requestAnimationFrame( animateTween );
KUTE.update(time);
}
//callback when tween is finished
function runFinished() {
if ( ops.finish && typeof ops.finish === "function") {
ops.finish();
}
if ( cv(otsc) ) {
document.body.removeAttribute('data-tweening')
}
}
//callback when tween just started
function runStart() {
if ( ops.start && typeof ops.start === "function") {
ops.start();
}
//fix the scrolling being interrupted via mousewheel
if ( cv(otsc) ) {
if ( !document.body.getAttribute('data-tweening') && document.body.getAttribute('data-tweening') !== 'scroll' )
document.body.setAttribute('data-tweening','scroll');
}
}
/* Process values utils
----------------------------*/
//process easing 31
function pe(e) {
if ( e === 'linear' ) return KUTE.Easing.Linear.None;
if ( e === 'quadraticIn' ) return KUTE.Easing.Quadratic.In;
if ( e === 'quadraticOut' ) return KUTE.Easing.Quadratic.Out;
if ( e === 'quadraticInOut' ) return KUTE.Easing.Quadratic.InOut;
if ( e === 'cubicIn' ) return KUTE.Easing.Cubic.In;
if ( e === 'cubicOut' ) return KUTE.Easing.Cubic.Out;
if ( e === 'cubicInOut' ) return KUTE.Easing.Cubic.InOut;
if ( e === 'quarticIn' ) return KUTE.Easing.Quartic.In;
if ( e === 'quarticOut' ) return KUTE.Easing.Quartic.Out;
if ( e === 'quarticInOut' ) return KUTE.Easing.Quartic.InOut;
if ( e === 'quinticIn' ) return KUTE.Easing.Quintic.In;
if ( e === 'quinticOut' ) return KUTE.Easing.Quintic.Out;
if ( e === 'quinticInOut' ) return KUTE.Easing.Quintic.InOut;
if ( e === 'sinusoidalIn' ) return KUTE.Easing.Sinusoidal.In;
if ( e === 'sinusoidalOut' ) return KUTE.Easing.Sinusoidal.Out;
if ( e === 'sinusoidalInOut' ) return KUTE.Easing.Sinusoidal.InOut;
if ( e === 'exponentialIn' ) return KUTE.Easing.Exponential.In;
if ( e === 'exponentialOut' ) return KUTE.Easing.Exponential.Out;
if ( e === 'exponentialInOut' ) return KUTE.Easing.Exponential.InOut;
if ( e === 'circularIn' ) return KUTE.Easing.Circular.In;
if ( e === 'circularOut' ) return KUTE.Easing.Circular.Out;
if ( e === 'circularInOut' ) return KUTE.Easing.Circular.InOut;
if ( e === 'elasticIn' ) return KUTE.Easing.Elastic.In;
if ( e === 'elasticOut' ) return KUTE.Easing.Elastic.Out;
if ( e === 'elasticInOut' ) return KUTE.Easing.Elastic.InOut;
if ( e === 'backIn' ) return KUTE.Easing.Back.In;
if ( e === 'backOut' ) return KUTE.Easing.Back.Out;
if ( e === 'backInOut' ) return KUTE.Easing.Back.InOut;
if ( e === 'bounceIn' ) return KUTE.Easing.Bounce.In;
if ( e === 'bounceOut' ) return KUTE.Easing.Bounce.Out;
if ( e === 'bounceInOut' ) return KUTE.Easing.Bounce.InOut;
//default
return KUTE.Easing.Exponential.InOut;
}
// value checker
function cv(v) {
if ( v !== undefined && v !== '' && v !== 'NaN' ) return true;
}
// get true w/h
function truD(d){
var v,u;
if (/px/i.test(d)) {
u = 'px'; v = parseInt( d );
} else if (/%/i.test(d)) {
u = '%'; v = parseInt( d );
} else {
v = d; u = 'px';
}
return [v,u];
}
// get background position true values
function truX(x) {
if ( x == 'left' ) {
return 0;
} else if ( x == 'center' ) {
return 50;
} else if ( x == 'right' ) {
return 100;
} else {
return parseInt( x );
}
}
function truY(y) {
if ( y == 'top' ) {
return 0;
} else if ( y == 'center' ) {
return 50;
} else if ( y == 'bottom' ) {
return 100;
} else {
return parseInt( y );
}
}
// get current background position
function bPos(elem) {
var sty = css.backgroundPosition,x,y;
var pos = sty.split(" ");
x = truX(pos[0]);
if ( cv(pos[1]) ) {
y = truY(pos[1]);
} else {
y = 0;
}
return [ x, y ];
}
// convert transparent to rgba()
function truC(c) {
if ( c === 'transparent' ) {
return c.replace('transparent','rgba(0,0,0,0)');
} else if ( cv(c) ) {
return c;
}
}
// process color
function pc(c) {
if ( cv(c) && /#/i.test(c) ) { return [htr(c).r,htr(c).g,htr(c).b]; } else { return c.replace(/[^\d,]/g, '').split(','); }
}
// transform rgb to hex or vice-versa
function rth(r, g, b) {
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
function htr(hex) {
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
var shr = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shr, function(m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
// process transform
function tr(p,pp) {
el.style.webkitTransform = p;
el.style.MozTransform = p;
el.style.msTransform = (cv(pp)?'perspective('+pp+'px) ':'') + p;
el.style.Transform = p;
}
};
KUTE.Tween = function ( object ) {
var _object = object;
var _valuesStart = {};
var _valuesEnd = {};
var _valuesStartRepeat = {};
var _duration = 700;
var _isPlaying = false;
var _delayTime = 0;
var _startTime = null;
var _easingFunction = KUTE.Easing.Linear.None;
var _onStartCallback = null;
var _onStartCallbackFired = false;
var _onUpdateCallback = null;
var _onCompleteCallback = null;
var _onStopCallback = null;
// Set all starting values present on the target object
for ( var field in object ) {
_valuesStart[ field ] = parseFloat(object[field], 10);
}
this.to = function ( properties, duration ) {
if ( duration !== undefined ) {
_duration = duration;
}
_valuesEnd = properties;
return this;
};
this.start = function ( time ) {
KUTE.add( this );
_isPlaying = true;
_onStartCallbackFired = false;
_startTime = time !== undefined ? time : window.performance.now();
_startTime += _delayTime;
for ( var property in _valuesEnd ) {
// check if an Array was provided as property value
if ( _valuesEnd[ property ] instanceof Array ) {
if ( _valuesEnd[ property ].length === 0 ) {
continue;
}
// create a local copy of the Array with the start value at the front
_valuesEnd[ property ] = [ _object[ property ] ].concat( _valuesEnd[ property ] );
}
if( ( _valuesEnd[ property ] instanceof Array ) === false ) {
_valuesEnd[ property ] *= 1.0; // Ensures we're using numbers, not strings
}
_valuesStart[ property ] = _object[ property ];
if( ( _valuesStart[ property ] instanceof Array ) === false ) {
_valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings
}
}
return this;
};
this.stop = function () {
if ( !_isPlaying ) {
return this;
}
KUTE.remove( this );
_isPlaying = false;
if ( _onStopCallback !== null ) {
_onStopCallback.call( _object );
}
return this;
};
this.delay = function ( amount ) {
_delayTime = amount;
return this;
};
this.easing = function ( easing ) {
_easingFunction = easing;
return this;
};
this.onStart = function ( callback ) {
_onStartCallback = callback;
return this;
};
this.onUpdate = function ( callback ) {
_onUpdateCallback = callback;
return this;
};
this.onComplete = function ( callback ) {
_onCompleteCallback = callback;
return this;
};
this.onStop = function ( callback ) {
_onStopCallback = callback;
return this;
};
this.update = function ( time ) {
var property;
if ( time < _startTime ) {
return true;
}
if ( _onStartCallbackFired === false ) {
if ( _onStartCallback !== null ) {
_onStartCallback.call( _object );
}
_onStartCallbackFired = true;
}
var elapsed = ( time - _startTime ) / _duration;
elapsed = elapsed > 1 ? 1 : elapsed;
var value = _easingFunction( elapsed );
for ( property in _valuesEnd ) {
var start = _valuesStart[ property ] || 0;
var end = _valuesEnd[ property ];
// Parses relative end values with start as base (e.g.: +10, -3)
if ( typeof(end) === "string" ) {
end = start + parseFloat(end, 10);
}
// protect against non numeric properties.
if ( typeof(end) === "number" ) {
_object[ property ] = start + ( end - start ) * value;
}
}
if ( _onUpdateCallback !== null ) {
_onUpdateCallback.call( _object, value );
}
if ( elapsed == 1 ) {
if ( _onCompleteCallback !== null ) {
_onCompleteCallback.call( _object );
}
return false;
}
return true;
};
};
KUTE.Easing = {
Linear: {
None: function ( k ) {
return k;
}
},
Quadratic: {
In: function ( k ) {
return k * k;
},
Out: function ( k ) {
return k * ( 2 - k );
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1 ) return 0.5 * k * k;
return - 0.5 * ( --k * ( k - 2 ) - 1 );
}
},
Cubic: {
In: function ( k ) {
return k * k * k;
},
Out: function ( k ) {
return --k * k * k + 1;
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k;
return 0.5 * ( ( k -= 2 ) * k * k + 2 );
}
},
Quartic: {
In: function ( k ) {
return k * k * k * k;
},
Out: function ( k ) {
return 1 - ( --k * k * k * k );
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1) return 0.5 * k * k * k * k;
return - 0.5 * ( ( k -= 2 ) * k * k * k - 2 );
}
},
Quintic: {
In: function ( k ) {
return k * k * k * k * k;
},
Out: function ( k ) {
return --k * k * k * k * k + 1;
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k * k * k;
return 0.5 * ( ( k -= 2 ) * k * k * k * k + 2 );
}
},
Sinusoidal: {
In: function ( k ) {
return 1 - Math.cos( k * Math.PI / 2 );
},
Out: function ( k ) {
return Math.sin( k * Math.PI / 2 );
},
InOut: function ( k ) {
return 0.5 * ( 1 - Math.cos( Math.PI * k ) );
}
},
Exponential: {
In: function ( k ) {
return k === 0 ? 0 : Math.pow( 1024, k - 1 );
},
Out: function ( k ) {
return k === 1 ? 1 : 1 - Math.pow( 2, - 10 * k );
},
InOut: function ( k ) {
if ( k === 0 ) return 0;
if ( k === 1 ) return 1;
if ( ( k *= 2 ) < 1 ) return 0.5 * Math.pow( 1024, k - 1 );
return 0.5 * ( - Math.pow( 2, - 10 * ( k - 1 ) ) + 2 );
}
},
Circular: {
In: function ( k ) {
return 1 - Math.sqrt( 1 - k * k );
},
Out: function ( k ) {
return Math.sqrt( 1 - ( --k * k ) );
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1) return - 0.5 * ( Math.sqrt( 1 - k * k) - 1);
return 0.5 * ( Math.sqrt( 1 - ( k -= 2) * k) + 1);
}
},
Elastic: {
In: function ( k ) {
var s, a = 0.1, p = 0.4;
if ( k === 0 ) return 0;
if ( k === 1 ) return 1;
if ( !a || a < 1 ) { a = 1; s = p / 4; }
else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
return - ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) );
},
Out: function ( k ) {
var s, a = 0.1, p = 0.4;
if ( k === 0 ) return 0;
if ( k === 1 ) return 1;
if ( !a || a < 1 ) { a = 1; s = p / 4; }
else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
return ( a * Math.pow( 2, - 10 * k) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) + 1 );
},
InOut: function ( k ) {
var s, a = 0.1, p = 0.4;
if ( k === 0 ) return 0;
if ( k === 1 ) return 1;
if ( !a || a < 1 ) { a = 1; s = p / 4; }
else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
if ( ( k *= 2 ) < 1 ) return - 0.5 * ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) );
return a * Math.pow( 2, -10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) * 0.5 + 1;
}
},
Back: {
In: function ( k ) {
var s = 1.70158;
return k * k * ( ( s + 1 ) * k - s );
},
Out: function ( k ) {
var s = 1.70158;
return --k * k * ( ( s + 1 ) * k + s ) + 1;
},
InOut: function ( k ) {
var s = 1.70158 * 1.525;
if ( ( k *= 2 ) < 1 ) return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) );
return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 );
}
},
Bounce: {
In: function ( k ) {
return 1 - KUTE.Easing.Bounce.Out( 1 - k );
},
Out: function ( k ) {
if ( k < ( 1 / 2.75 ) ) {
return 7.5625 * k * k;
} else if ( k < ( 2 / 2.75 ) ) {
return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
} else if ( k < ( 2.5 / 2.75 ) ) {
return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
} else {
return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
}
},
InOut: function ( k ) {
if ( k < 0.5 ) return KUTE.Easing.Bounce.In( k * 2 ) * 0.5;
return KUTE.Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5;
}
}
};
// prevent mousewheel or touch events while tweening scroll
document.addEventListener('mousewheel', preventScroll, false);
document.addEventListener('touchstart', preventScroll, false);
function preventScroll(e){
var data = document.body.getAttribute('data-tweening');
if ( data && data === 'scroll' ) {
e.preventDefault();
}
};

676
kute.js
View file

@ -1,676 +0,0 @@
// kute.js - The Light Tweening Engine | by dnp_theme
// http://themeforest.net/user/dnp_theme
// License - MIT
// KUTE MAIN OBJECT
var KUTE = KUTE || ( function () {
var _tweens = [];
return {
getAll: function () {
return _tweens;
},
removeAll: function () {
_tweens = [];
},
add: function ( tween ) {
_tweens.push( tween );
},
remove: function ( tween ) {
var i = _tweens.indexOf( tween );
if ( i !== -1 ) {
_tweens.splice( i, 1 );
}
},
update: function ( time ) {
if ( _tweens.length === 0 ) return false;
var i = 0;
time = time !== undefined ? time : window.performance.now();
while ( i < _tweens.length ) {
if ( _tweens[ i ].update( time ) ) {
i++;
} else {
_tweens.splice( i, 1 );
}
}
return true;
}
};
} )();
KUTE.Animate = function( object, options ) {
//element to animate
var el = typeof object === 'object' ? object : document.querySelector(object);
//get true scroll container and current scroll
var bd = document.body,
htm = document.getElementsByTagName('HTML')[0],
sct = /webkit/i.test(navigator.userAgent) || document.compatMode == 'BackCompat' ? bd : htm,
crs = window.pageYOffset || sct.scrollTop;
//determine if we're on IE or IE8
var isIE = document.documentElement.classList.contains('ie');
var isIE8 = document.documentElement.classList.contains('ie8');
//get element current style
var css = el.currentStyle || window.getComputedStyle(el);
// default values
var ops = {
from : {
opacity : 1, // integer
width : '', // integer/px/%
height : '', // integer/px/%
position : {top:'', left:''}, // integer/%
translate : {x:0, y:0, z:0}, // integer only
rotate : {x:0, y:0, z:0}, // integer only
scale : 1, // integer only
scroll : crs, // integer only
},
to : {
opacity : '',
width : '',
height : '',
position : {top:'',left:''},
translate : {x:'', y:'', z:''},
rotate : {x:'', y:'', z:''},
scale : '',
scroll : '',
},
easing : KUTE.Easing.Linear.None, //pe('linear')
delay : 0,
duration : 500,
start : null, // run function when tween starts
finish : null, // run function when tween finishes
special : null // run function while tween runing
};
//override the default values with option values
for (var x in options) {
if(typeof(options[x]) === 'object'){
for (var y in options[x]){
ops[x][y] = options[x][y];
}
}else{
ops[x] = options[x];
}
}
//create shorthand for all properties
var ofo = ops.from.opacity;
var ofw = ops.from.width;
var ofh = ops.from.height;
var oft = ops.from.position.top;
var ofl = ops.from.position.left;
var oftx = ops.from.translate.x;
var ofty = ops.from.translate.y;
var oftz = ops.from.translate.z;
var ofrx = ops.from.rotate.x;
var ofry = ops.from.rotate.y;
var ofrz = ops.from.rotate.z;
var ofs = ops.from.scale;
var ofsc = ops.from.scroll;
var oto = ops.to.opacity;
var otw = ops.to.width;
var oth = ops.to.height;
var ott = ops.to.position.top;
var otl = ops.to.position.left;
var ottx = ops.to.translate.x;
var otty = ops.to.translate.y;
var ottz = ops.to.translate.z;
var otrx = ops.to.rotate.x;
var otry = ops.to.rotate.y;
var otrz = ops.to.rotate.z;
var ots = ops.to.scale;
var otsc = ops.to.scroll;
//process easing
var pes = typeof ops.easing === 'string' ? pe(ops.easing) : ops.easing;
//from/initial values
var iwi = cv(ofw) ? truD(ofw)[0] : truD( css.width )[0]; // width
var ihe = cv(ofh) ? truD(ofh)[0] : truD( css.height )[0]; // height
var ito = cv(oft) ? truD(oft)[0] : ''; // move
var ile = cv(ofl) ? truD(ofl)[0] : '';
var tr3d,tx,ty,tz,itx,ity,itz; // translate
if ( cv( ottx ) || cv( otty ) || cv( ottz ) ) {
itx = cv(oftx) ? truD(oftx)[0] : 0;
ity = cv(ofty) ? truD(ofty)[0] : 0;
itz = cv(oftz) ? truD(oftz)[0] : 0;
} else {
itx = ''; ity = ''; itz = '';
}
var irx = cv(ofrx) ? parseInt(ofrx) :''; //always deg
var iry = cv(ofry) ? parseInt(ofry) :'';
var irz = cv(ofrz) ? parseInt(ofrz) :'';
var isa = parseFloat(ofs); // scale can be float
var iop = parseFloat(ofo); // opacity
var isc = parseInt(ofsc); // scroll
//target values
var wi = cv( otw ) ? truD(otw)[0] : ''; // width
var he = cv( oth ) ? truD(oth)[0] : ''; // height
var top = cv(ott) ? truD(ott)[0] : ''; // pos top
var le = cv(otl) ? truD(otl)[0] : ''; //pos left
if ( cv( ottx ) || cv( otty ) || cv( ottz ) ) { // translate 3d
tx = cv( ottx ) ? truD(ottx)[0] : 0;
ty = cv( otty ) ? truD(otty)[0] : 0;
tz = cv( ottz ) ? truD(ottz)[0] : 0;
} else {
tx = ''; ty = ''; tz = '';
}
var rx = cv( otrx ) ? parseInt(otrx) : ''; // rotate
var ry = cv( otry ) ? parseInt(otry) : '';
var rz = cv( otrz ) ? parseInt(otrz) : '';
var sa = cv( ots ) ? parseFloat(ots) : ''; // scale values below 1 need to be reformated
var op = cv( oto ) ? parseFloat(oto) : ''; // opacity
var sc = cv( otsc ) ? parseInt(otsc) : ''; // scroll
//check measurement unit
var wiu = cv( wi ) ? truD(otw)[1] : ''; // width
var heu = cv( he ) ? truD(oth)[1] : ''; // height
var tou = cv( ott ) ? truD(ott)[1] : ''; // pos top
var leu = cv( otl ) ? truD(otl)[1] : ''; // pos left
var txu = cv( tx ) ? truD(ottx)[1] : ''; // translate
var tyu = cv( ty ) ? truD(otty)[1] : '';
var tzu = cv( tz ) ? truD(ottz)[1] : '';
animateTween();
var from = { w: iwi, h: ihe, t: ito, l: ile, scale: isa, trX: itx, trY: ity, trZ: itz, roX: irx, roY: iry, roZ: irz, opacity: iop, scroll: isc };
var target = { w: wi, h: he, t: top, l: le, scale: sa, trX: tx, trY: ty, trZ: tz, roX: rx, roY: ry, roZ: rz, opacity: op, scroll: sc };
return new KUTE.Tween( from )
.to( target, ops.duration )
.delay( ops.delay )
.easing( pes )
.onStart( runStart )
.onUpdate(
function () {
//translate3d
if ( cv(tx) || cv(ty) || cv(tz) ) {
tr3d = 'translate3d(' + ((this.trX + txu) || 0) + ',' + ( (this.trY + tyu) || 0) + ',' + ( (this.trZ + tzu) || 0) + ')';
} else { tr3d = ''; }
//rotate
var roxt = cv(rx) ? ' rotateX(' + this.roX + 'deg)' : '';
var royt = cv(ry) ? ' rotateY(' + this.roY + 'deg)' : '';
var rozt = cv(rz) ? ' rotateZ(' + this.roZ + 'deg)' : '';
//scale
var sca = cv(sa) ? ' scale(' + this.scale + ')' : '';
//do a zoom for IE8
if (isIE8 && cv(sa)) {
el.style.zoom = this.scale;
}
//sum all transform
var perspective = parseInt(css.perspective)||'';
var transform = sca + tr3d + roxt + royt + rozt;
if ( cv(transform) ) { tr(transform,perspective) }
//dimensions width / height
if ( cv(wi) ) { el.style.width = this.w + wiu; }
if ( cv(he) ) { el.style.height = this.h + heu; }
//position
if ( cv(top) ) { el.style.top = this.t + tou; }
if ( cv(le ) ) { el.style.left = this.l + leu; }
// scrolling
if ( cv(sc) ) { sct.scrollTop = this.scroll; }
//opacity
if ( cv(op) ) { el.style.opacity = (this.opacity).toFixed(2); }
//do a filter opacity for IE8
if (isIE8 && cv(op)) {
el.style.filter = "alpha(opacity=" + parseInt(100 * this.opacity) + ")"
}
//run special function onUpdate
if ( ops.special && typeof ops.special === "function") { ops.special(); }
}
)
.onComplete( runFinished )
.start();
function animateTween(time) {
requestAnimationFrame( animateTween );
KUTE.update(time);
}
//callback when tween is finished
function runFinished() {
if ( ops.finish && typeof ops.finish === "function") {
ops.finish();
}
if ( cv(otsc) ) {
document.body.removeAttribute('data-tweening')
}
}
//callback when tween just started
function runStart() {
if ( ops.start && typeof ops.start === "function") {
ops.start();
}
//fix the scrolling being interrupted via mousewheel
if ( cv(otsc) ) {
if ( !document.body.getAttribute('data-tweening') && document.body.getAttribute('data-tweening') !== 'scroll' )
document.body.setAttribute('data-tweening','scroll');
}
}
/* Process values utils
----------------------------*/
//process easing 31
function pe(e) {
if ( e === 'linear' ) return KUTE.Easing.Linear.None;
if ( e === 'quadraticIn' ) return KUTE.Easing.Quadratic.In;
if ( e === 'quadraticOut' ) return KUTE.Easing.Quadratic.Out;
if ( e === 'quadraticInOut' ) return KUTE.Easing.Quadratic.InOut;
if ( e === 'cubicIn' ) return KUTE.Easing.Cubic.In;
if ( e === 'cubicOut' ) return KUTE.Easing.Cubic.Out;
if ( e === 'cubicInOut' ) return KUTE.Easing.Cubic.InOut;
if ( e === 'quarticIn' ) return KUTE.Easing.Quartic.In;
if ( e === 'quarticOut' ) return KUTE.Easing.Quartic.Out;
if ( e === 'quarticInOut' ) return KUTE.Easing.Quartic.InOut;
if ( e === 'quinticIn' ) return KUTE.Easing.Quintic.In;
if ( e === 'quinticOut' ) return KUTE.Easing.Quintic.Out;
if ( e === 'quinticInOut' ) return KUTE.Easing.Quintic.InOut;
if ( e === 'sinusoidalIn' ) return KUTE.Easing.Sinusoidal.In;
if ( e === 'sinusoidalOut' ) return KUTE.Easing.Sinusoidal.Out;
if ( e === 'sinusoidalInOut' ) return KUTE.Easing.Sinusoidal.InOut;
if ( e === 'exponentialIn' ) return KUTE.Easing.Exponential.In;
if ( e === 'exponentialOut' ) return KUTE.Easing.Exponential.Out;
if ( e === 'exponentialInOut' ) return KUTE.Easing.Exponential.InOut;
if ( e === 'circularIn' ) return KUTE.Easing.Circular.In;
if ( e === 'circularOut' ) return KUTE.Easing.Circular.Out;
if ( e === 'circularInOut' ) return KUTE.Easing.Circular.InOut;
if ( e === 'elasticIn' ) return KUTE.Easing.Elastic.In;
if ( e === 'elasticOut' ) return KUTE.Easing.Elastic.Out;
if ( e === 'elasticInOut' ) return KUTE.Easing.Elastic.InOut;
if ( e === 'backIn' ) return KUTE.Easing.Back.In;
if ( e === 'backOut' ) return KUTE.Easing.Back.Out;
if ( e === 'backInOut' ) return KUTE.Easing.Back.InOut;
if ( e === 'bounceIn' ) return KUTE.Easing.Bounce.In;
if ( e === 'bounceOut' ) return KUTE.Easing.Bounce.Out;
if ( e === 'bounceInOut' ) return KUTE.Easing.Bounce.InOut;
//default
return KUTE.Easing.Exponential.InOut;
}
// value checker
function cv(v) {
if ( v !== undefined && v !== '' && v !== 'NaN' ) return true;
}
// get true w/h
function truD(d){
var v,u;
if (/px/i.test(d)) {
u = 'px'; v = parseInt( d );
} else if (/%/i.test(d)) {
u = '%'; v = parseInt( d );
} else {
v = d; u = 'px';
}
return [v,u];
}
// process transform
function tr(p,pp) {
el.style.webkitTransform = p;
el.style.MozTransform = p;
el.style.msTransform = (cv(pp)?'perspective('+pp+'px) ':'') + p;
el.style.Transform = p;
}
};
KUTE.Tween = function ( object ) {
var _object = object;
var _valuesStart = {};
var _valuesEnd = {};
var _valuesStartRepeat = {};
var _duration = 700;
var _isPlaying = false;
var _delayTime = 0;
var _startTime = null;
var _easingFunction = KUTE.Easing.Linear.None;
var _onStartCallback = null;
var _onStartCallbackFired = false;
var _onUpdateCallback = null;
var _onCompleteCallback = null;
var _onStopCallback = null;
// Set all starting values present on the target object
for ( var field in object ) {
_valuesStart[ field ] = parseFloat(object[field], 10);
}
this.to = function ( properties, duration ) {
if ( duration !== undefined ) {
_duration = duration;
}
_valuesEnd = properties;
return this;
};
this.start = function ( time ) {
KUTE.add( this );
_isPlaying = true;
_onStartCallbackFired = false;
_startTime = time !== undefined ? time : window.performance.now();
_startTime += _delayTime;
for ( var property in _valuesEnd ) {
// check if an Array was provided as property value
if ( _valuesEnd[ property ] instanceof Array ) {
if ( _valuesEnd[ property ].length === 0 ) {
continue;
}
// create a local copy of the Array with the start value at the front
_valuesEnd[ property ] = [ _object[ property ] ].concat( _valuesEnd[ property ] );
}
if( ( _valuesEnd[ property ] instanceof Array ) === false ) {
_valuesEnd[ property ] *= 1.0; // Ensures we're using numbers, not strings
}
_valuesStart[ property ] = _object[ property ];
if( ( _valuesStart[ property ] instanceof Array ) === false ) {
_valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings
}
}
return this;
};
this.stop = function () {
if ( !_isPlaying ) {
return this;
}
KUTE.remove( this );
_isPlaying = false;
if ( _onStopCallback !== null ) {
_onStopCallback.call( _object );
}
return this;
};
this.delay = function ( amount ) {
_delayTime = amount;
return this;
};
this.easing = function ( easing ) {
_easingFunction = easing;
return this;
};
this.onStart = function ( callback ) {
_onStartCallback = callback;
return this;
};
this.onUpdate = function ( callback ) {
_onUpdateCallback = callback;
return this;
};
this.onComplete = function ( callback ) {
_onCompleteCallback = callback;
return this;
};
this.onStop = function ( callback ) {
_onStopCallback = callback;
return this;
};
this.update = function ( time ) {
var property;
if ( time < _startTime ) {
return true;
}
if ( _onStartCallbackFired === false ) {
if ( _onStartCallback !== null ) {
_onStartCallback.call( _object );
}
_onStartCallbackFired = true;
}
var elapsed = ( time - _startTime ) / _duration;
elapsed = elapsed > 1 ? 1 : elapsed;
var value = _easingFunction( elapsed );
for ( property in _valuesEnd ) {
var start = _valuesStart[ property ] || 0;
var end = _valuesEnd[ property ];
// Parses relative end values with start as base (e.g.: +10, -3)
if ( typeof(end) === "string" ) {
end = start + parseFloat(end, 10);
}
// protect against non numeric properties.
if ( typeof(end) === "number" ) {
_object[ property ] = start + ( end - start ) * value;
}
}
if ( _onUpdateCallback !== null ) {
_onUpdateCallback.call( _object, value );
}
if ( elapsed == 1 ) {
if ( _onCompleteCallback !== null ) {
_onCompleteCallback.call( _object );
}
return false;
}
return true;
};
};
KUTE.Easing = {
Linear: {
None: function ( k ) {
return k;
}
},
Quadratic: {
In: function ( k ) {
return k * k;
},
Out: function ( k ) {
return k * ( 2 - k );
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1 ) return 0.5 * k * k;
return - 0.5 * ( --k * ( k - 2 ) - 1 );
}
},
Cubic: {
In: function ( k ) {
return k * k * k;
},
Out: function ( k ) {
return --k * k * k + 1;
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k;
return 0.5 * ( ( k -= 2 ) * k * k + 2 );
}
},
Quartic: {
In: function ( k ) {
return k * k * k * k;
},
Out: function ( k ) {
return 1 - ( --k * k * k * k );
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1) return 0.5 * k * k * k * k;
return - 0.5 * ( ( k -= 2 ) * k * k * k - 2 );
}
},
Quintic: {
In: function ( k ) {
return k * k * k * k * k;
},
Out: function ( k ) {
return --k * k * k * k * k + 1;
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k * k * k;
return 0.5 * ( ( k -= 2 ) * k * k * k * k + 2 );
}
},
Sinusoidal: {
In: function ( k ) {
return 1 - Math.cos( k * Math.PI / 2 );
},
Out: function ( k ) {
return Math.sin( k * Math.PI / 2 );
},
InOut: function ( k ) {
return 0.5 * ( 1 - Math.cos( Math.PI * k ) );
}
},
Exponential: {
In: function ( k ) {
return k === 0 ? 0 : Math.pow( 1024, k - 1 );
},
Out: function ( k ) {
return k === 1 ? 1 : 1 - Math.pow( 2, - 10 * k );
},
InOut: function ( k ) {
if ( k === 0 ) return 0;
if ( k === 1 ) return 1;
if ( ( k *= 2 ) < 1 ) return 0.5 * Math.pow( 1024, k - 1 );
return 0.5 * ( - Math.pow( 2, - 10 * ( k - 1 ) ) + 2 );
}
},
Circular: {
In: function ( k ) {
return 1 - Math.sqrt( 1 - k * k );
},
Out: function ( k ) {
return Math.sqrt( 1 - ( --k * k ) );
},
InOut: function ( k ) {
if ( ( k *= 2 ) < 1) return - 0.5 * ( Math.sqrt( 1 - k * k) - 1);
return 0.5 * ( Math.sqrt( 1 - ( k -= 2) * k) + 1);
}
},
Elastic: {
In: function ( k ) {
var s, a = 0.1, p = 0.4;
if ( k === 0 ) return 0;
if ( k === 1 ) return 1;
if ( !a || a < 1 ) { a = 1; s = p / 4; }
else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
return - ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) );
},
Out: function ( k ) {
var s, a = 0.1, p = 0.4;
if ( k === 0 ) return 0;
if ( k === 1 ) return 1;
if ( !a || a < 1 ) { a = 1; s = p / 4; }
else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
return ( a * Math.pow( 2, - 10 * k) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) + 1 );
},
InOut: function ( k ) {
var s, a = 0.1, p = 0.4;
if ( k === 0 ) return 0;
if ( k === 1 ) return 1;
if ( !a || a < 1 ) { a = 1; s = p / 4; }
else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
if ( ( k *= 2 ) < 1 ) return - 0.5 * ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) );
return a * Math.pow( 2, -10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) * 0.5 + 1;
}
},
Back: {
In: function ( k ) {
var s = 1.70158;
return k * k * ( ( s + 1 ) * k - s );
},
Out: function ( k ) {
var s = 1.70158;
return --k * k * ( ( s + 1 ) * k + s ) + 1;
},
InOut: function ( k ) {
var s = 1.70158 * 1.525;
if ( ( k *= 2 ) < 1 ) return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) );
return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 );
}
},
Bounce: {
In: function ( k ) {
return 1 - KUTE.Easing.Bounce.Out( 1 - k );
},
Out: function ( k ) {
if ( k < ( 1 / 2.75 ) ) {
return 7.5625 * k * k;
} else if ( k < ( 2 / 2.75 ) ) {
return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
} else if ( k < ( 2.5 / 2.75 ) ) {
return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
} else {
return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
}
},
InOut: function ( k ) {
if ( k < 0.5 ) return KUTE.Easing.Bounce.In( k * 2 ) * 0.5;
return KUTE.Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5;
}
}
};
// prevent mousewheel or touch events while tweening scroll
document.addEventListener('mousewheel', preventScroll, false);
document.addEventListener('touchstart', preventScroll, false);
function preventScroll(e){
var data = document.body.getAttribute('data-tweening');
if ( data && data === 'scroll' ) {
e.preventDefault();
}
};

132
performance.html Normal file
View file

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html lang="en">
<head>
<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="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);
}
.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>
</head>
<body>
<div id="info" class="padding">
<p><a class="back" href="index.html">Back to KUTE.js</a></p>
<p>Engine </p>
<span id="engine" class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" tabindex="0">Select <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li><a id="kute" href="#">KUTE</a></li>
<li><a id="gsap" href="#">GSAP</a></li>
<li><a id="tween" href="#">Tween.js</a></li>
</ul>
</span>
<p>Property </p>
<span id="property" class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" tabindex="0">Select <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li><a id="left" href="#">left</a></li>
<li><a id="translateX" href="#">translateX</a></li>
</ul>
</span>
<p>Repeat </p>
<span id="repeat" class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" tabindex="0">Select <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li><a id="5" href="#">5</a></li>
<li><a id="10" href="#">10</a></li>
<li><a id="15" href="#">15</a></li>
<li><a id="20" href="#">20</a></li>
</ul>
</span>
<p>How many elements to animate:</p>
<span id="count" class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" tabindex="0">Select <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li><a id="100" href="#">100</a></li>
<li><a id="200" href="#">200</a></li>
<li><a id="300" href="#">300</a></li>
<li><a id="400" href="#">400</a></li>
<li><a id="500" href="#">500</a></li>
<li><a id="600" href="#">600</a></li>
<li><a id="700" href="#">700</a></li>
<li><a id="800" href="#">800</a></li>
<li><a id="900" href="#">900</a></li>
<li><a id="1000" href="#">1000</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>
<div style="width:100%;clear: both">
<button class="btn btn-success" id="start" type="button" style="margin-bottom: 15px">Start</button>
</div>
<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>
</div>
<div id="container"></div>
<!-- JavaScript
================================================== -->
<!-- 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 type="text/javascript" src="https://cdn.jsdelivr.net/bootstrap.native/0.9.9/bootstrap-native.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/TweenMax.min.js"></script>
<script src="./assets/js/tween.min.js"></script> <!-- KUTE local -->
<script src="./src/kute.js"></script> <!-- KUTE local -->
<script src="./assets/js/perf.js"></script> <!-- some stuff -->
</body>
</html>

159
src/kute-bezier.js Normal file
View file

@ -0,0 +1,159 @@
/*
* KUTE.js - The Light Tweening Engine | dnp_theme
* package bezier easing
* BezierEasing by Gaëtan Renaudeau 2014 MIT License
* optimized by dnp_theme 2015 MIT License
* Licensed under MIT-License
*/
KUTE.Ease = {};
KUTE.Ease.bezier = function(mX1, mY1, mX2, mY2) {
return _bz.pB(mX1, mY1, mX2, mY2);
};
var _bz = KUTE.Ease.bezier.prototype;
// These values are established by empiricism with tests (tradeoff: performance VS precision)
_bz.ni = 4; // NEWTON_ITERATIONS
_bz.nms = 0.001; // NEWTON_MIN_SLOPE
_bz.sp = 0.0000001; // SUBDIVISION_PRECISION
_bz.smi = 10, // SUBDIVISION_MAX_ITERATIONS
_bz.ksts = 11; // k Spline Table Size
_bz.ksss = 1.0 / (_bz.ksts - 1.0); // k Sample Step Size
_bz.f32as = 'Float32Array' in window; // float32ArraySupported
_bz.msv = _bz.f32as ? new Float32Array (_bz.ksts) : new Array (_bz.ksts); // m Sample Values
_bz.A = function(aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; };
_bz.B = function(aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; };
_bz.C = function(aA1) { return 3.0 * aA1; };
_bz.r = {};
_bz.pB = function (mX1, mY1, mX2, mY2) {
this._p = false; var self = this;
_bz.r = function(aX){
if (!self._p) _bz.pc(mX1, mX2, mY1, mY2);
if (mX1 === mY1 && mX2 === mY2) return aX;
if (aX === 0) return 0;
if (aX === 1) return 1;
return _bz.cB(_bz.gx(aX, mX1, mX2), mY1, mY2);
};
return _bz.r;
};
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
_bz.cB = function(aT, aA1, aA2) { // calc Bezier
return ((_bz.A(aA1, aA2)*aT + _bz.B(aA1, aA2))*aT + _bz.C(aA1))*aT;
};
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
_bz.gS = function (aT, aA1, aA2) { // getSlope
return 3.0 * _bz.A(aA1, aA2)*aT*aT + 2.0 * _bz.B(aA1, aA2) * aT + _bz.C(aA1);
};
_bz.bS = function(a, aA, aB, mX1, mX2) { // binary Subdivide
var x, t, i = 0, j = _bz.sp, y = _bz.smi;
do {
t = aA + (aB - aA) / 2.0;
x = _bz.cB(t, mX1, mX2) - a;
if (x > 0.0) {
aB = t;
} else {
aA = t;
}
} while (Math.abs(x) > j && ++i < y);
return t;
};
_bz.nri = function (aX, agt, mX1, mX2) { // newton Raphs on Iterate
var i = 0, j = _bz.ni;
for (i; i < j; ++i) {
var cs = _bz.gS(agt, mX1, mX2);
if (cs === 0.0) return agt;
var x = _bz.cB(agt, mX1, mX2) - aX;
agt -= x / cs;
}
return agt;
};
_bz.csv = function (mX1, mX2) { // calc Sample Values
var i = 0, j = _bz.ksts;
for (i; i < j; ++i) {
_bz.msv[i] = _bz.cB(i * _bz.ksss, mX1, mX2);
}
};
_bz.gx = function (aX,mX1,mX2) { //get to X
var iS = 0.0, cs = 1, ls = _bz.ksts - 1;
for (; cs != ls && _bz.msv[cs] <= aX; ++cs) {
iS += _bz.ksss;
}
--cs;
// Interpolate to provide an initial guess for t
var dist = (aX - _bz.msv[cs]) / (_bz.msv[cs+1] - _bz.msv[cs]),
gt = iS + dist * _bz.ksss,
ins = _bz.gS(gt, mX1, mX2),
fiS = iS + _bz.ksss;
if (ins >= _bz.nms) {
return _bz.nri(aX, gt, mX1, mX2);
} else if (ins === 0.0) {
return gt;
} else {
return _bz.bS(aX, iS, fiS, mX1, mX2);
}
};
_bz.pc = function(mX1, mX2, mY1, mY2) {
this._p = true;
if (mX1 != mY1 || mX2 != mY2)
_bz.csv(mX1, mX2);
};
// predefined bezier based easings, can be accessed via string, eg 'easeIn' or 'easeInOutQuart'
// _easings = ["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInExpo","easeOutExpo","easeInOutExpo","slowMo","slowMo1","slowMo2"],
KUTE.Ease.easeIn = function(){ return _bz.pB(0.42, 0.0, 1.00, 1.0); };
KUTE.Ease.easeOut = function(){ return _bz.pB(0.00, 0.0, 0.58, 1.0); };
KUTE.Ease.easeInOut = function(){ return _bz.pB(0.50, 0.16, 0.49, 0.86); };
KUTE.Ease.easeInSine = function(){ return _bz.pB(0.47, 0, 0.745, 0.715); };
KUTE.Ease.easeOutSine = function(){ return _bz.pB(0.39, 0.575, 0.565, 1); };
KUTE.Ease.easeInOutSine = function(){ return _bz.pB(0.445, 0.05, 0.55, 0.95); };
KUTE.Ease.easeInQuad = function () { return _bz.pB(0.550, 0.085, 0.680, 0.530); };
KUTE.Ease.easeOutQuad = function () { return _bz.pB(0.250, 0.460, 0.450, 0.940); };
KUTE.Ease.easeInOutQuad = function () { return _bz.pB(0.455, 0.030, 0.515, 0.955); };
KUTE.Ease.easeInCubic = function () { return _bz.pB(0.55, 0.055, 0.675, 0.19); };
KUTE.Ease.easeOutCubic = function () { return _bz.pB(0.215, 0.61, 0.355, 1); };
KUTE.Ease.easeInOutCubic = function () { return _bz.pB(0.645, 0.045, 0.355, 1); };
KUTE.Ease.easeInQuart = function () { return _bz.pB(0.895, 0.03, 0.685, 0.22); };
KUTE.Ease.easeOutQuart = function () { return _bz.pB(0.165, 0.84, 0.44, 1); };
KUTE.Ease.easeInOutQuart = function () { return _bz.pB(0.77, 0, 0.175, 1); };
KUTE.Ease.easeInQuint = function(){ return _bz.pB(0.755, 0.05, 0.855, 0.06); };
KUTE.Ease.easeOutQuint = function(){ return _bz.pB(0.23, 1, 0.32, 1); };
KUTE.Ease.easeInOutQuint = function(){ return _bz.pB(0.86, 0, 0.07, 1); };
KUTE.Ease.easeInExpo = function(){ return _bz.pB(0.95, 0.05, 0.795, 0.035); };
KUTE.Ease.easeOutExpo = function(){ return _bz.pB(0.19, 1, 0.22, 1); };
KUTE.Ease.easeInOutExpo = function(){ return _bz.pB(1, 0, 0, 1); };
KUTE.Ease.easeInCirc = function(){ return _bz.pB(0.6, 0.04, 0.98, 0.335); };
KUTE.Ease.easeOutCirc = function(){ return _bz.pB(0.075, 0.82, 0.165, 1); };
KUTE.Ease.easeInOutCirc = function(){ return _bz.pB(0.785, 0.135, 0.15, 0.86); };
KUTE.Ease.easeInBack = function(){ return _bz.pB(0.600, -0.280, 0.735, 0.045); };
KUTE.Ease.easeOutBack = function(){ return _bz.pB(0.175, 0.885, 0.320, 1.275); };
KUTE.Ease.easeInOutBack = function(){ return _bz.pB(0.68, -0.55, 0.265, 1.55); };
KUTE.Ease.slowMo = function(){ return _bz.pB(0.000, 0.500, 1.000, 0.500); };
KUTE.Ease.slowMo1 = function(){ return _bz.pB(0.000, 0.700, 1.000, 0.300); };
KUTE.Ease.slowMo2 = function(){ return _bz.pB(0.000, 0.900, 1.000, 0.100); };

26
src/kute-jquery.js Normal file
View file

@ -0,0 +1,26 @@
/* KUTE.js - The Light Tweening Engine
* package jQuery Plugin
* by dnp_theme
* Licensed under MIT-License
*/
(function($) {
$.fn.KUTE = function( method, start, end, ops ) { // method can be Animate(), fromTo(), to(), stop(), start(), chain(), pause()
var tws = [], i, l = this.length;
for (i=0;i<l;i++){
var mt = this[i][method];
if ( typeof mt === 'function' ) {
mt.apply(this[i]);
}
if ( method === 'to' ) {
tws.push( new KUTE[method]( this[i], start, end ) ); // here start is end and end is ops
} else if ( method === 'fromTo' || method === 'Animate' ) {
tws.push( new KUTE[method]( this[i], start, end, ops ) );
} else if ( method === 'chain' ) {
this[i].chain.apply(this[i],start);
}
}
return tws;
};
})(jQuery);

302
src/kute-physics.js Normal file
View file

@ -0,0 +1,302 @@
/*
* KUTE.js - The Light Tweening Engine | dnp_theme
* package dynamics.js easings pack by Michael Villar
* https://github.com/michaelvillar/dynamics.js
* optimized by dnp_theme 2015 MIT License
* Licensed under MIT-License
*/
KUTE.Physics = {};
var _kp = KUTE.Physics, _hPI = Math.PI / 2;
// spring easing
_kp.spring = function(options) {
options = options || {};
var fq = Math.max(1, (options.frequency || 300 ) / 20),
fc = Math.pow(20, (options.friction || 200 ) / 100),
aSt = options.anticipationStrength || 0,
aS = (options.anticipationSize || 0) / 1000;
_kps.run = function(t) {
var A, At, a, angle, b, frictionT, y0, yS;
frictionT = (t / (1 - aS)) - (aS / (1 - aS));
if (t < aS) {
yS = (aS / (1 - aS)) - (aS / (1 - aS));
y0 = (0 / (1 - aS)) - (aS / (1 - aS));
b = Math.acos(1 / _kps.A1(t,yS));
a = (Math.acos(1 / _kps.A1(t,y0)) - b) / (fq * (-aS));
A = _kps.A1;
} else {
A = _kps.A2;
b = 0;
a = 1;
}
At = A(frictionT,aS,aSt,fc);
angle = fq * (t - aS) * a + b;
return 1 - (At * Math.cos(angle));
};
return _kps.run;
};
var _kps = _kp.spring.prototype;
_kps.run = {};
_kps.A1 = function(t,aS,aSt) {
var a, b, x0, x1;
x0 = aS / (1 - aS);
x1 = 0;
b = (x0 - (0.8 * x1)) / (x0 - x1);
a = (0.8 - b) / x0;
return (a * t * aSt / 100) + b;
};
_kps.A2 = function(t,aS,aSt,f) {
return Math.pow(f / 10, -t) * (1 - t);
};
// bounce
_kp.bounce = function(options) {
options = options || {};
var fq = Math.max(1, (options.frequency || 300) / 20),
f = Math.pow(20, (options.friction || 200) / 100);
_kpo.run = function(t) {
var At = Math.pow(f / 10, -t) * (1 - t),
angle = fq * t * 1 + _hPI;
return At * Math.cos(angle);
};
return _kpo.run;
};
var _kpo = _kp.bounce.prototype;
_kpo.run = {};
// gravity
_kp.gravity = function(options) {
var bounciness, curves, elasticity, gravity, initialForce;
options = options || {};
bounciness = ( options.bounciness || 400 ) / 1250;
elasticity = ( options.elasticity || 200 ) / 1000;
initialForce = options.initialForce || false;
gravity = 100;
curves = [];
_kpg.L = (function() {
var b, curve;
b = Math.sqrt(2 / gravity);
curve = {
a: -b,
b: b,
H: 1
};
if (initialForce) {
curve.a = 0;
curve.b = curve.b * 2;
}
while (curve.H > 0.001) {
_kpg.L = curve.b - curve.a;
curve = {
a: curve.b,
b: curve.b + _kpg.L * bounciness,
H: curve.H * bounciness * bounciness
};
}
return curve.b;
})();
(function() {
var L2, b, curve, _results;
b = Math.sqrt(2 / (gravity * _kpg.L * _kpg.L));
curve = {
a: -b,
b: b,
H: 1
};
if (initialForce) {
curve.a = 0;
curve.b = curve.b * 2;
}
curves.push(curve);
L2 = _kpg.L;
_results = [];
while (curve.b < 1 && curve.H > 0.001) {
L2 = curve.b - curve.a;
curve = {
a: curve.b,
b: curve.b + L2 * bounciness,
H: curve.H * elasticity
};
_results.push(curves.push(curve));
}
return _results;
})();
_kpg.fn = function(t) {
var curve, i, v;
i = 0;
curve = curves[i];
while (!(t >= curve.a && t <= curve.b)) {
i += 1;
curve = curves[i];
if (!curve) {
break;
}
}
if (!curve) {
v = initialForce ? 0 : 1;
} else {
v = _kpg.getPointInCurve(curve.a, curve.b, curve.H, t, options, _kpg.L);
}
return v;
};
return _kpg.fn;
};
var _kpg = _kp.gravity.prototype;
_kpg.L = {};
_kpg.fn = {};
_kpg.getPointInCurve = function(a, b, H, t, o, L) {
var c, t2;
L = b - a;
t2 = (2 / L) * t - 1 - (a * 2 / L);
c = t2 * t2 * H - H + 1;
if (o.initialForce) {
c = 1 - c;
}
return c;
};
//throw up and pull down by gravity
_kp.forceWithGravity = function(o) {
var ops = o || {};
ops.initialForce = true;
return _kp.gravity(ops);
};
// multi point bezier
_kp.bezier = function(options) {
options = options || {};
var points = options.points,
returnsToSelf = false, Bs = [];
(function() {
var i, k;
for (i in points) {
k = parseInt(i);
if (k >= points.length - 1) {
break;
}
_kpb.fn(points[k], points[k + 1], Bs);
}
return Bs;
})();
_kpb.run = function(t) {
if (t === 0) {
return 0;
} else if (t === 1) {
return 1;
} else {
return _kpb.yForX(t, Bs, returnsToSelf);
}
};
return _kpb.run;
};
var _kpb = _kp.bezier.prototype;
_kpb.B2 = {};
_kpb.run = {};
_kpb.fn = function(pointA, pointB, Bs) {
var B2 = function(t) {
return _kpb.Bezier(t, pointA, pointA.cp[pointA.cp.length - 1], pointB.cp[0], pointB);
};
return Bs.push(B2);
};
_kpb.Bezier = function(t, p0, p1, p2, p3) {
return {
x: (Math.pow(1 - t, 3) * p0.x) + (3 * Math.pow(1 - t, 2) * t * p1.x) + (3 * (1 - t) * Math.pow(t, 2) * p2.x) + Math.pow(t, 3) * p3.x,
y: (Math.pow(1 - t, 3) * p0.y) + (3 * Math.pow(1 - t, 2) * t * p1.y) + (3 * (1 - t) * Math.pow(t, 2) * p2.y) + Math.pow(t, 3) * p3.y
};
};
_kpb.yForX = function(xTarget, Bs, rTS) {
var B, aB, i, lower, percent, upper, x, xT, _i = 0, _len = Bs.length;
B = null;
for (_i; _i < _len; _i++) {
aB = Bs[_i];
if (xTarget >= aB(0).x && xTarget <= aB(1).x) {
B = aB;
}
if (B !== null) {
break;
}
}
if (!B) {
return ( rTS ? 0 : 1 );
}
xT = 0.0001; // xTolerance
lower = 0; upper = 1;
percent = (upper + lower) / 2;
x = B(percent).x; i = 0;
while (Math.abs(xTarget - x) > xT && i < 100) {
if (xTarget > x) {
lower = percent;
} else {
upper = percent;
}
percent = (upper + lower) / 2;
x = B(percent).x;
i++;
}
return B(percent).y;
};
_kp.physicsInOut = function(options) {
var friction;
options = options || {};
friction = options.friction|| 500;
return _kp.bezier({ points: [ { x: 0, y: 0, cp: [ { x: 0.92 - (friction / 1000), y: 0 } ] }, { x: 1, y: 1, cp: [ { x: 0.08 + (friction / 1000), y: 1 } ] } ] });
};
_kp.physicsIn = function(options) {
var friction;
options = options || {};
friction = options.friction|| 500;
return _kp.bezier({ points: [ { x: 0, y: 0, cp: [ { x: 0.92 - (friction / 1000), y: 0 } ] }, { x: 1, y: 1, cp: [ { x: 1, y: 1 } ] } ] });
};
_kp.physicsOut = function(options) {
var friction;
options = options || {};
friction = options.friction|| 500;
return _kp.bezier({ points: [ { x: 0, y: 0, cp: [ { x: 0, y: 0 } ] }, { x: 1, y: 1, cp: [ { x: 0.08 + (friction / 1000), y: 1 } ] }] });
};
_kp.physicsBackOut = function(options) {
var friction;
options = options || {};
friction = options.friction|| 500;
return _kp.bezier({ points: [{"x":0,"y":0,"cp":[{"x":0,"y":0}]},{"x":1,"y":1,"cp":[{"x":0.735+(friction/1000),"y":1.3}]}] });
};
_kp.physicsBackIn = function(options) {
var friction;
options = options || {};
friction = options.friction|| 500;
return _kp.bezier({ points: [{"x":0,"y":0,"cp":[{"x":0.28-(friction / 1000),"y":-0.6}]},{"x":1,"y":1,"cp":[{"x":1,"y":1}]}] });
};
_kp.physicsBackInOut = function(options) {
var friction;
options = options || {};
friction = options.friction|| 500;
return _kp.bezier({ points: [{"x":0,"y":0,"cp":[{"x":0.68-(friction / 1000),"y":-0.55}]},{"x":1,"y":1,"cp":[{"x":0.265+(friction / 1000),"y":1.45}]}] });
};

File diff suppressed because it is too large Load diff