diff --git a/about.html b/about.html index 0a49d52..048028d 100644 --- a/about.html +++ b/about.html @@ -50,6 +50,7 @@
  • Core Engine
  • CSS Plugin
  • SVG Plugin
  • +
  • Text Plugin
  • Attributes Plugin
  • @@ -58,6 +59,7 @@ @@ -88,8 +90,8 @@

    Basically, this is it!

    -

    A Word On Performance

    -

    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.

    +

    A Note On Performance

    +

    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. We'll dig into each case, by property type or anything that can be considered a factor of influence.

    Function Nesting

    This could be one of the most important factors that influence performance, because we neglect this fact most of the time and changing the scope of an animation engine is important to look after. A quick example would be when we create tween objects on events such as click, scroll or resize, we basically set a totally different scope for the animation and we fill the memory with large chunks of trash/jank, especially on events like resize.

    @@ -107,7 +109,7 @@

    Box Model

    We compared position with transition above, but now we are going to talk about other issues related to resizers: width, height, margin, padding and borderWidth 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 all browsers, especially when you animate these resize properties. When this toxic combination occurs animating a large amount of elements to animate could crash any browser, no exception, and I think any developer should know about this.

    The resize event triggered by these resizer properties can cause some severe issues with legacy browsers 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.

    -

    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.

    +

    A workaound for 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 elements themselves. 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.

    RGB and HEX

    When animating any color property such as (text) color or background-color, KUTE.js always uses/converts to RGB/RGBA, but there is a keepHex:true 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 RGB the winner.

    @@ -123,6 +125,10 @@

    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.

    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 page.

    +

    Property Value Complexity

    +

    Just like the high amount of simultaneous animations influence performance, the property value complexity is also an important factor. If we were to compare all the supported properties in terms of complexity, the list would go like this (from most expensive to least): path morphing, regular transform, matrix3d (not yet supported), box-shadow / text-shadow, colors, box model*, unitless props (scroll, opacity).

    +

    The * wants to emphasize the fact that box model properties of type resizers have additional performance drawbacks as discussed in a previous chapter.

    +

    OSs, Desktops and Mobiles

    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).

    The results show Windows 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!

    @@ -141,7 +147,7 @@

    KUTE.js Project

    KUTE.js continues what was started with jQueryTween (removed) 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.

    It all started with a fork of the popular tween.js and ended up having a KUTE.js version 0.9.5 that's almost as good as the boss, GSAP, at least in terms of performance and browser support. TweenMax have been an outstanding source of wonderful coding practices, and a very tough competitor.

    -

    In the hystory of the making there were consistent contributions of Dav aka @dalisoft for features such as play & 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.

    +

    In the hystory of the making there were consistent contributions of Dav aka @dalisoft for features such as play & pause, Text Plugin, 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.

    Also I would like to thank Ingwie Phoenix for the npm/Bower and UMD implementations.

    @@ -69,6 +70,7 @@ @@ -219,56 +221,6 @@ tween2.chain(tweensCollection2.tweens); -
    -

    Tween Options

    -

    Common Options

    -

    These options affect all types of tweens, no matter the properties used or context.

    -

    duration: 500 option allows you to set the animation duration in miliseconds. The default value is 700.

    -

    repeat: 20 option allows you to run the animation of given tween multiple times. The default value is 0.

    -

    delay: 500 option allows you to delay the tween animation for a certain number of miliseconds. The default value is 0.

    -

    offset: 200 option is only for .allTo() and .allFromTo() methods. This allows you to set a base delay in miliseconds that increases with each element in the collection. This has no effect on other methods and the default value is 0.

    -

    repeatDelay: 500 option allows you to set a number of miliseconds delay between repeatable animations. If repeat option is set to 0, will produce no effect. The default value is 0.

    -

    yoyo: true/false option makes use of the internal reverse functionality to also animate from end to start for a given tween. This option requires that you use the repeat option with at least value 1. The default value is false.

    -

    easing: 'easingCubicInOut' 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 linear.

    - -

    Transform Options

    -

    These options only affect animation involving any property from CSS3 transform specs and have no effect on other CSS properties. While you can set perspective or perspective origin via CSS, these options are here to help, especially with full browser support and preffix free handling.

    -

    perspective: 500 option allows you to set a 3D transformation perspective for a given HTML element that is subject to transform animation. No default value.

    -

    perspectiveOrigin: "50% 50%" option allows you to set a perspectiveOrigin for a given HTML. This option has no default value and only accepts valid CSS values according to it's specs.

    -

    parentPerspective: 500 option allows you to set a 3D perspective for the parent of the HTML element subject to the transform animation.

    -

    parentPerspectiveOrigin: "50% 50%" option allows you to set a perspectiveOrigin 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.

    -

    transformOrigin: "50% 50%" option allows you to set a transformOrigin for the HTML element subject to the transform animation. Also this options only accepts valid CSS values.

    - -

    SVG Options

    -

    These options only affect animation of the path tween property, or what you know as SVG morphing.

    - -

    showMorphInfo: true when true the script will log valuable information about the morph in order to help you maximize both performance and visuals of the morph.

    -

    morphPrecision: Number option allows you to set the sampling size of the morph. The lesser value the better visual but the more power consumption.

    -

    morphIndex: Number option allows you to rotate the second/end path in a way that the points travel the least possible distance during morph, and as an effect the morph animation feel more "natural".

    -

    reverseFirstPath: true when is true this option allows you to reverse the draw direction of the FIRST shape.

    -

    reverseSecondPath: true when is true this option allows you to reverse the draw direction of the SECOND shape.

    - -

    Callback Options

    -

    These options also affect all types of tweens, and are bound by the tween control options and the internal update functions.

    -

    start: function option allows you to set a function to run once tween animation starts.

    -

    update: function option allows you to set a function to run on every frame.

    -

    pause: function option allows you to set a function to run when animation is paused.

    -

    resume: function option allows you to set a function to run when animation is resumed.

    -

    stop: function option allows you to set a function to run when animation is stopped.

    -

    complete: function option allows you to set a function to run when animation is finished.

    -

    A quick example would look like this:

    -
    //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();
    -
    -

    Other

    -

    keepHex: true option allows you to always use HEX color format, even if you have used RGB or RGBA. This option is useful when tweening color properties on legacy browsers, however modern browsers may ignore this option for performance reasons.

    -
    -
    @@ -68,6 +69,7 @@ diff --git a/css.html b/css.html index 44cd036..c0b5a45 100644 --- a/css.html +++ b/css.html @@ -60,6 +60,7 @@
  • Core Engine
  • CSS Plugin
  • SVG Plugin
  • +
  • Text Plugin
  • Attributes Plugin
  • @@ -68,6 +69,7 @@ diff --git a/easing.html b/easing.html index 6d72c3f..312ec81 100644 --- a/easing.html +++ b/easing.html @@ -14,7 +14,7 @@ - KUTE.js Developer API | Javascript Animation Engine + KUTE.js Easing Functions | Javascript Animation Engine @@ -61,6 +61,7 @@
  • Core Engine
  • CSS Plugin
  • SVG Plugin
  • +
  • Text Plugin
  • Attributes Plugin
  • @@ -69,6 +70,7 @@ diff --git a/examples.html b/examples.html index c21fd37..6b64764 100644 --- a/examples.html +++ b/examples.html @@ -14,7 +14,7 @@ - KUTE.js Examples | Javascript Animation Engine + KUTE.js Core Engine Examples | Javascript Animation Engine @@ -59,6 +59,7 @@
  • Core Engine
  • CSS Plugin
  • SVG Plugin
  • +
  • Text Plugin
  • Attributes Plugin
  • @@ -67,6 +68,7 @@ diff --git a/extend.html b/extend.html index 1547b15..5c2b3a5 100644 --- a/extend.html +++ b/extend.html @@ -61,6 +61,7 @@
  • Core Engine
  • CSS Plugin
  • SVG Plugin
  • +
  • Text Plugin
  • Attributes Plugin
  • @@ -69,6 +70,7 @@ @@ -86,9 +88,10 @@

    Basic Plugin Template

    The best way to extend, no matter what you would like to achieve is to use a specific closure, here's an example:

    /* KUTE.js - The Light Tweening Engine
    + * by dnp_theme
      * package - pluginName
      * desc - what your plugin does
    - * by yourNickname aka YOUR NAME
    + * pluginName by yourNickname aka YOUR NAME
      * Licensed under MIT-License
      */
     
    diff --git a/features.html b/features.html
    index 647a968..a214d9e 100644
    --- a/features.html
    +++ b/features.html
    @@ -58,6 +58,7 @@
                         
  • Core Engine
  • CSS Plugin
  • SVG Plugin
  • +
  • Text Plugin
  • Attributes Plugin
  • @@ -66,6 +67,7 @@ @@ -123,13 +125,13 @@

    Unlike previous versions where animations started right away, starting with version 0.9.5 KUTE.js gives you great animation control methods such as: .start(), .stop(), .pause() and .resume(). These public methods work either when animation is not running, running or is paused. You need to see the documentation to learn how these work.

    Tween Options

    -

    Aside from the usual options such as duration, delay, easing, repeat or yoyo, it also comes with specific tween options for transform. For instance 3D rotations require a perspective or a perspective-origin, right?

    +

    Aside from the usual options such as duration, delay, easing, repeat or yoyo, it also comes with specific tween options for transform. For instance 3D rotations require a perspective or a perspective-origin, right? Well, make sure to check that out.

    Callback System

    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.

    Addons

    -

    KUTE.js sports some fine tuned addons: jQuery Plugin, cubic bezier easing functions and also physics based easing functions. It also features an attributes plugin as well as a SVG plugin for various awesome stuff, but I'm open for more features in the future.

    +

    KUTE.js sports some fine tuned addons: jQuery Plugin, SVG Plugin, Text Plugin, Attributes Plugin, CSS Plugin, cubic bezier easing functions and also physics based easing functions. It also features an extensive guide on how to extend, but I'm open for more features in the future.

    Check the documentation on these methods and the examples page for more.

    diff --git a/index.html b/index.html index ddee711..314739e 100644 --- a/index.html +++ b/index.html @@ -58,6 +58,7 @@
  • Core Engine
  • CSS Plugin
  • SVG Plugin
  • +
  • Text Plugin
  • Attributes Plugin
  • @@ -66,6 +67,7 @@ @@ -79,10 +81,10 @@
    -
    -

    Welcome Developers!

    -

    KUTE.js is a Javascript animation engine with top performance, memory efficient & modular code. It delivers a whole bunch of tools to help you create great custom animations.

    -

    +

    +

    +

    +

    Download Github CDN @@ -122,7 +124,7 @@

    Prefix Free

    -

    KUTE.js can detect if the user's browser requires prefix and uses it accordingly for requestAnimationFrame, transform and border-radius, hustle free for older Gecko/Webkit/IE browsers.

    +

    KUTE.js can detect if the user's browser requires prefix and uses it accordingly for transform and border-radius, and even use the utilities yourself, so hustle free for older Gecko/Webkit/IE browsers.

    @@ -132,17 +134,17 @@

    Powerful Methods

    -

    KUTE.js allows you to create tweens and chainable tweens, gives you tween control methods (start/stop/pause/resume) and comes with full spectrum tween options.

    +

    KUTE.js allows you to create tweens and chainable tweens, gives you tween control methods (start/stop/pause/resume) and comes with full spectrum tween options.

    Packed With Tools

    -

    KUTE.js comes with tools to help you configure awesome animations: SVG Plugin, jQuery plugin, cubic-bezier and physics easing functions, color convertors, and you can even extend it yourself.

    +

    KUTE.js comes with tools to help you configure awesome animations: CSS / SVG / ATTR Plugins, jQuery plugin, easing functions, color convertors, and you can even extend it yourself.

    Plenty Of Properties

    -

    KUTE.js covers all animation needs such as SVG morph and other specific CSS properties, then transform, scroll, border-radius, and almost the full box model and also text properties.

    +

    KUTE.js covers all animation needs such as SVG morph and other specific CSS properties, then transform, scroll, border-radius, and almost the full box model and also text properties.

    @@ -169,7 +171,7 @@

    Documentation

    -

    The API documentation is here for you to get you started.

    +

    The API documentation is here for you to get you started.

    @@ -208,6 +210,7 @@ + diff --git a/options.html b/options.html new file mode 100644 index 0000000..65310af --- /dev/null +++ b/options.html @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + KUTE.js Tween Options | Javascript Animation Engine + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + +
    +

    Tween Options

    +

    Common Options

    +

    These options affect all types of tweens, no matter the properties used or context.

    +
      +
    • duration: 500 option allows you to set the animation duration in miliseconds. The default value is 700.
    • +
    • repeat: 20 option allows you to run the animation of given tween multiple times. The default value is 0.
    • +
    • delay: 500 option allows you to delay the tween animation for a certain number of miliseconds. The default value is 0.
    • +
    • offset: 200 option is only for .allTo() and .allFromTo() methods. This allows you to set a base delay in miliseconds that increases with each element in the collection. This has no effect on other methods and the default value is 0.
    • +
    • repeatDelay: 500 option allows you to set a number of miliseconds delay between repeatable animations. If repeat option is set to 0, will produce no effect. The default value is 0.
    • +
    • yoyo: true/false option makes use of the internal reverse functionality to also animate from end to start for a given tween. This option requires that you use the repeat option with at least value 1. The default value is false.
    • +
    • easing: 'easingCubicInOut' 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 linear.
    • +
    + +

    Transform Options

    +

    These options only affect animation involving any 3D property from CSS3 transform and have no effect on other CSS properties. While you can set perspective or perspective origin via CSS, these options are here to help, especially with full browser support and preffix free handling.

    +
      +
    • perspective: 500 option allows you to set a 3D transformation perspective for a given HTML element. No default value.
    • +
    • perspectiveOrigin: "50% 50%" option allows you to set a perspectiveOrigin for a given HTML. This option has no default value and only accepts valid CSS values according to it's specs.
    • +
    • parentPerspective: 500 option allows you to set a 3D perspective for the parent of the HTML element subject to the transform animation.
    • +
    • parentPerspectiveOrigin: "50% 50%" option allows you to set a perspectiveOrigin 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.
    • +
    • transformOrigin: "50% 50%" option allows you to set a transformOrigin for the HTML element subject to the transform animation. Also this options only accepts valid CSS values.
    • +
    + +

    SVG Plugin Options

    +

    The following options only affect animation of the path tween property, to customize the SVG morph animation. See SVG Plugin page.

    +
      +
    • showMorphInfo: true when true the script will log information about the morph in order to help you maximize/customize the morph.
    • +
    • morphPrecision: Number option allows you to set the sampling size of the morph. The lesser value the better visual but the more power required.
    • +
    • morphIndex: Number option allows you to rotate the second/end path in a way that the points travel the least possible distance during morph, and as an effect the morph animation feel more "natural".
    • +
    • reverseFirstPath: true when is true this option allows you to reverse the draw direction of the FIRST shape.
    • +
    • reverseSecondPath: true when is true this option allows you to reverse the draw direction of the SECOND shape.
    • +
    + +

    Text Plugin Options

    +

    The only option for the plugin is the textChars option for the text property and allows you to set the characters set for the scrambling character during the animation. See Text Plugin page for more instructions and demo.

    + +

    Callback Options

    +

    These options also affect all types of tweens, and are bound by the tween control options and the internal update functions.

    +
      +
    • start: function option allows you to set a function to run once tween animation starts.
    • +
    • update: function option allows you to set a function to run on every frame.
    • +
    • pause: function option allows you to set a function to run when animation is paused.
    • +
    • resume: function option allows you to set a function to run when animation is resumed.
    • +
    • stop: function option allows you to set a function to run when animation is stopped.
    • +
    • complete: function option allows you to set a function to run when animation is finished.
    • +
    + +

    A quick example would look like this:

    +
    //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();
    +
    +

    Other

    +

    keepHex: true option allows you to always use HEX color format, even if you have used RGB or RGBA. This option is useful when tweening color properties on legacy browsers, however modern browsers may ignore this option for performance reasons.

    +
    + +
    + + + +
    + + + + +
    + + + + + + + + + + + + + + + diff --git a/properties.html b/properties.html index 595829c..e0b557e 100644 --- a/properties.html +++ b/properties.html @@ -57,6 +57,7 @@
  • Core Engine
  • CSS Plugin
  • SVG Plugin
  • +
  • Text Plugin
  • Attributes Plugin
  • @@ -65,6 +66,7 @@ @@ -160,7 +162,7 @@

    The Attributes Plugin can animate any numerical presentation attribute such as width, cx or stop-opacity, but the values can be also suffixed: 150px or 50%, and for that you must always provide a string value that include the measurement unit, and that, of course, depends on the attribute. This plugin can be a great addition to the above SVG Plugin for specific gradient attributes or specific geometric shapes' attributes.

    The synthax is slightly different to make sure we don't mess up with CSS properties that have the same name because the presentation attribute may be a unitless attribute while the CSS property might require a suffix (%,px,etc). For instance KUTE.to('selector', {attr:{width:150}}) is clearly different from KUTE.to('selector', {width:150}) which is the the CSS property with the same name.

    -

    Text Properties

    +

    Typography Properties

    The CSS Plugin also cover the text properties, and these can be combinated with each other when applied to text elements (paragraphs, headings) as animation fallback for scale on browsers that don't support transform at all. Yes, IE8 and other legacy browsers.

    • fontSize allows you to animate the font-size for a given element.
    • @@ -173,7 +175,14 @@

      Scroll Animation

      KUTE.js core engine currently supports only vertical scroll for both the window and a given element that's scrollable (when scrollHeight is higher than offsetHeight). Both scroll: 150 or scrollTop: 150 notations will do. When animating scroll, KUTE.js will disable all scroll and swipe handlers to prevent animation bubbles as well as scroll bottlenecks.

      -

      Other properties

      +

      String Properties

      +
        +
      • number allows you to tween a number either from 0 or from a current value and updates the innerHTML for a given target. Eg. number:1500
      • +
      • text allows you to write a string one character at a time followed by a scrambling character. Eg. text: 'A demo with <b>substring</b>'.
      • +
      +

      See Text Plugin for details.

      + +

      Other Properties

      • clip allows you to animate the clip property for a given element. Only rect is supported. Eg. clip:[250,200,300,0]. See spec for details.
      • backgroundPosition allows you to animate the background-position for a given element that uses a background image. It only uses % as measurement unit. Eg. backgroundPosition:[50,20]
      • diff --git a/src/kute-css.js b/src/kute-css.js index 793d46f..12d6261 100644 --- a/src/kute-css.js +++ b/src/kute-css.js @@ -17,8 +17,8 @@ } })(function(KUTE){ var K = window.KUTE, p, - _br = K.property('borderRadius'), _brtl = K.property('borderTopLeftRadius'), _brtr = K.property('borderTopRightRadius'), - _brbl = K.property('borderBottomLeftRadius'), _brbr = K.property('borderBottomRightRadius'), // all radius props prefixed + _br = K.property('borderRadius'), _brtl = K.property('borderTopLeftRadius'), _brtr = K.property('borderTopRightRadius'), // all radius props prefixed + _brbl = K.property('borderBottomLeftRadius'), _brbr = K.property('borderBottomRightRadius'), _cls = ['borderColor', 'borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor', 'outlineColor'], // colors 'hex', 'rgb', 'rgba' -- #fff / rgb(0,0,0) / rgba(0,0,0,0) _rd = ['borderRadius', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomLeftRadius', 'borderBottomRightRadius'], // border radius px/any _bm = ['right', 'bottom', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight', @@ -45,7 +45,7 @@ } } - // create prepare/render functions for additional colors properties + // create prepare/process/render functions for additional colors properties for (var i = 0, l = _cls.length; i,./?\=-").split(""), // symbols + _n = String("0123456789").split(""), // numeric + _a = _s.concat(_S,_n), // alpha numeric + _all = _a.concat(_sb), // all caracters + _r = Math.random, _f = Math.floor, _m = Math.min; + + K.prS['text'] = K.prS['number'] = function(l,p,v){ + return l.innerHTML; + } + + K.pp['text'] = function(p,v,l) { + if ( !( 'text' in K.dom ) ) { + K.dom['text'] = function(w,p,v) { + var tp = tp || w.textChars === 'alpha' ? _s // textChars is alpha + : w.textChars === 'upper' ? _S // textChars is numeric + : w.textChars === 'numeric' ? _n // textChars is numeric + : w.textChars === 'alphanumeric' ? _a // textChars is alphanumeric + : w.textChars === 'symbols' ? _sb // textChars is symbols + : w.textChars ? w.textChars.split('') // textChars is a custom text + : _s, l = tp.length, s = w._vE[p], + t = tp[_f((_r() * l))], tx = '', f = s.substring(0); + + tx = f.substring(0,_f(_m(v * f.length, f.length))); + w._el.innerHTML = v < 1 ? tx+t : tx; + } + } + return v; + } + + K.pp['number'] = function(p,v,l) { + if ( !( 'number' in K.dom ) ) { + K.dom['number'] = function(w,p,v) { + w._el.innerHTML = parseInt(w._vS[p] + (w._vE[p] - w._vS[p]) * v); + } + } + return parseInt(v) || 0; + } + + return this; +})); \ No newline at end of file diff --git a/start.html b/start.html index 1f274a5..ab0e7a7 100644 --- a/start.html +++ b/start.html @@ -61,6 +61,7 @@
      • Core Engine
      • CSS Plugin
      • SVG Plugin
      • +
      • Text Plugin
      • Attributes Plugin
      @@ -69,6 +70,7 @@ diff --git a/svg.html b/svg.html index b94beb2..6f76842 100644 --- a/svg.html +++ b/svg.html @@ -59,6 +59,7 @@
    • Core Engine
    • CSS Plugin
    • SVG Plugin
    • +
    • Text Plugin
    • Attributes Plugin
    @@ -67,6 +68,7 @@ diff --git a/text.html b/text.html new file mode 100644 index 0000000..2e686ee --- /dev/null +++ b/text.html @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + KUTE.js Text Plugin | Javascript Animation Engine + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + +
    +

    Text Plugin

    +

    The KUTE.js Text Plugin extends the core engine and enables animation for text elements in two ways: either incrementing or decreasing a number in a given string or writing a string character by character with a very cool effect.

    + +
    // basic synthax for number increments
    +var myNumberTween = KUTE.to('selector', {number: 1500}); // this assumes it will start from current number or from 0
    +
    +// OR text writing character by character
    +var myTextTween = KUTE.to('selector', {text: 'A text string with other <span>substring</span> should do.'});
    +
    + +

    The effects of these two properties are very popular, but pay attention to the fact that every 16 miliseconds the browser has to parse the HTML structure around your target elements so caution is advised. With other words, try to limit the number of simultaneus text animations.

    + +

    Number Incrementing/Decreasing

    +

    In the first example, let's animate a number, approximatelly as written above:

    +
    +

    Total number of lines: 0

    + +
    + Start +
    +
    +

    The button action will toggle the valuesEnd value for the number property, because tweening a number to itself would produce no effect.

    + +

    Writing Text

    +

    This feature come with a additional tween option called textChars for the scrambling text character:

    +
      +
    • alpha use lowercase alphabetical characters, the default value
    • +
    • upper use UPPERCASE alphabetical characters
    • +
    • numeric use numerical characters
    • +
    • symbols use symbols such as #, $, %, etc.
    • +
    • all use all alpha numeric and symbols.
    • +
    • YOUR CUSTOM STRING use your own custom characters; eg: 'KUTE.JS IS #AWESOME'.
    • +
    +
    +

    Click the Start button on the right.

    + +
    + Start +
    +
    +

    Keep in mind that the yoyo feature will NOT un-write / delete character by character the string, but will write the previous text instead.

    + +

    Combining Both

    +
    +
    +
    +

    0

    +
    +
    +

    Clicks so far?

    +
    +
    +
    + Start +
    +
    +

    In this example we've used the textChars option with symbols and all values respectively, but combining the two text properties and some other KUTE.js features can really spice up some content. Have fun!

    + + +
    + + + + +
    + + + + + + + + + + + + + + + + \ No newline at end of file