From fc75dd130f6d3bc4be40ebcf3406b6af47dfd313 Mon Sep 17 00:00:00 2001
From: thednp
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.
+It all started with a fork of the popular tween.js and ended up having a KUTE.js version 0.9.5 that's very fast, memory efficient and super easy to use.
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.
diff --git a/demo/assets/js/perf.js b/demo/assets/js/perf.js index e431719..70b042b 100644 --- a/demo/assets/js/perf.js +++ b/demo/assets/js/perf.js @@ -52,7 +52,7 @@ function random(min, max) { // the variables var container = document.getElementById('container'); -// vendor prefix handle +// vendor prefix handle for Tween.js var transformProperty = KUTE.property('transform'), tws = []; diff --git a/demo/assets/js/svg.js b/demo/assets/js/svg.js index 43c2bca..878cdff 100644 --- a/demo/assets/js/svg.js +++ b/demo/assets/js/svg.js @@ -94,24 +94,52 @@ var draw5 = KUTE.allFromTo(drawEls,{draw:'0% 100%'}, {draw:'50% 50%'}, {duration draw1.chain(draw2); draw2.chain(draw3); draw3.chain(draw4); draw4.chain(draw5); drawBtn.addEventListener('click', function(){ - !draw1.playing && !draw2.playing && !draw3.playing && !draw4.playing && !draw5.playing && draw1.start(); + !draw1.tweens[0].playing && !draw1.tweens[1].playing && !draw1.tweens[2].playing && !draw1.tweens[3].playing && !draw1.tweens[4].playing + && !draw2.tweens[0].playing && !draw2.tweens[1].playing && !draw2.tweens[2].playing && !draw2.tweens[3].playing && !draw2.tweens[4].playing + && !draw3.tweens[0].playing && !draw3.tweens[1].playing && !draw3.tweens[2].playing && !draw3.tweens[3].playing && !draw3.tweens[4].playing + && !draw4.tweens[0].playing && !draw4.tweens[1].playing && !draw4.tweens[2].playing && !draw4.tweens[3].playing && !draw4.tweens[4].playing + && !draw5.tweens[0].playing && !draw5.tweens[1].playing && !draw5.tweens[2].playing && !draw5.tweens[3].playing && !draw5.tweens[4].playing + + && draw1.start(); }, false); -// // svgTransform examples +// svgTransform examples + +// rotation around shape center point var svgRotate = document.getElementById('svgRotate'); var rotateBtn = document.getElementById('rotateBtn'); var svgr1 = svgRotate.getElementsByTagName('path')[0]; var svgr2 = svgRotate.getElementsByTagName('path')[1]; -var svgTween11 = KUTE.to(svgr1, { rotate: 360 }, {transformOrigin: '50% 50%', yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); -var svgTween12 = KUTE.to(svgr2, { svgTransform: { translate: 580, rotate: 360 } }, {yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); +var svgTween11 = KUTE.to(svgr1, { rotate: 360 }, { transformOrigin: '50% 50%', yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); +var svgTween12 = KUTE.to(svgr2, { svgTransform: { translate: 580, rotate: 360 } }, { yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); rotateBtn.addEventListener('click', function(){ !svgTween11.playing && svgTween11.start(); !svgTween12.playing && svgTween12.start(); }, false); +// rotation around shape's parent center point +var svgRotate1 = document.getElementById('svgRotate1'); +var rotateBtn1 = document.getElementById('rotateBtn1'); +var svgr11 = svgRotate1.getElementsByTagName('path')[0]; +var svgr21 = svgRotate1.getElementsByTagName('path')[1]; +var bb = svgr21.getBBox(); +var translation = [580, 0]; +var svgBB = svgr21.ownerSVGElement.getBBox(); +var svgOriginX = (svgBB.width * 50 / 100) - translation[0]; +var svgOriginY = (svgBB.height * 50 / 100)- translation[1]; + +var svgTween111 = KUTE.to(svgr11, { rotate: 360 }, { transformOrigin: (svgBB.width * 50 / 100) + 'px 50%', yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); +var svgTween121 = KUTE.to(svgr21, { svgTransform: { translate: translation, rotate: 360 } }, { transformOrigin: [svgOriginX, svgOriginY], yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); + +rotateBtn1.addEventListener('click', function(){ + !svgTween111.playing && svgTween111.start(); + !svgTween121.playing && svgTween121.start(); +}, false); + +// translate var svgTranslate = document.getElementById('svgTranslate'); var translateBtn = document.getElementById('translateBtn'); var svgt1 = svgTranslate.getElementsByTagName('path')[0]; @@ -124,29 +152,18 @@ translateBtn.addEventListener('click', function(){ !svgTween22.playing && svgTween22.start(); }, false); +// skews in chain var svgSkew = document.getElementById('svgSkew'); var skewBtn = document.getElementById('skewBtn'); var svgsk1 = svgSkew.getElementsByTagName('path')[0]; var svgsk2 = svgSkew.getElementsByTagName('path')[1]; -var svgTween31 = KUTE.to(svgsk1, { skewX: -15 }, {transformOrigin: '0px 0px 0px', - // yoyo: true, repeat: 1, - duration: 1500, easing: "easingCubicOut"}); -var svgTween311 = KUTE.to(svgsk1, { skewY: 15 }, { - // yoyo: true, repeat: 1, - duration: 1500, easing: "easingCubicOut"}); -var svgTween313 = KUTE.to(svgsk1, { skewX: 0, skewY: 0 }, { - // yoyo: true, repeat: 1, - duration: 1500, easing: "easingCubicOut"}); +var svgTween31 = KUTE.to(svgsk1, { skewX: -15 }, {transformOrigin: '50% 50% 0px', duration: 1500, easing: "easingCubicInOut"}); +var svgTween311 = KUTE.to(svgsk1, { skewY: 15 }, {transformOrigin: '50% 50% 0px', duration: 2500, easing: "easingCubicInOut"}); +var svgTween313 = KUTE.to(svgsk1, { skewX: 0, skewY: 0 }, {transformOrigin: '50% 50% 0px', duration: 1500, easing: "easingCubicInOut"}); -var svgTween32 = KUTE.to(svgsk2, {svgTransform: { translate: 580, skewX: -15 } }, { - // yoyo: true, repeat: 1, - duration: 1500, easing: "easingCubicOut"}); -var svgTween322 = KUTE.to(svgsk2, {svgTransform: { translate: 580, skewY: 15 } }, { - // yoyo: true, repeat: 1, - duration: 1500, easing: "easingCubicOut"}); -var svgTween323 = KUTE.to(svgsk2, {svgTransform: { translate: 580, skewY: 0, skewX: 0 } }, { - // yoyo: true, repeat: 1, - duration: 1500, easing: "easingCubicOut"}); +var svgTween32 = KUTE.to(svgsk2, {svgTransform: { translate: 580, skewX: -15 } }, { transformOrigin: '50% 50%', duration: 1500, easing: "easingCubicInOut"}); +var svgTween322 = KUTE.to(svgsk2, {svgTransform: { translate: 580, skewY: 15 } }, { transformOrigin: '50% 50%', duration: 2500, easing: "easingCubicInOut"}); +var svgTween323 = KUTE.to(svgsk2, {svgTransform: { translate: 580, skewY: 0, skewX: 0 } }, { transformOrigin: '50% 50%', duration: 1500, easing: "easingCubicInOut"}); svgTween31.chain(svgTween311); svgTween311.chain(svgTween313); @@ -159,6 +176,7 @@ skewBtn.addEventListener('click', function(){ !svgTween32.playing && !svgTween322.playing && !svgTween323.playing && svgTween32.start(); }, false); +// scale var svgScale = document.getElementById('svgScale'); var scaleBtn = document.getElementById('scaleBtn'); var svgs1 = svgScale.getElementsByTagName('path')[0]; @@ -167,36 +185,33 @@ var svgTween41 = KUTE.to(svgs1, { scale: 1.5 }, {transformOrigin: '50% 50%', yoy var svgTween42 = KUTE.to(svgs2, {svgTransform: { translate: 580, scale: 0.5, -} }, {yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); +} }, {transformOrigin: '50% 50%', yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); scaleBtn.addEventListener('click', function(){ !svgTween41.playing && svgTween41.start(); !svgTween42.playing && svgTween42.start(); }, false); +// mixed transforms var svgMixed = document.getElementById('svgMixed'); var mixedBtn = document.getElementById('mixedBtn'); var svgm1 = svgMixed.getElementsByTagName('path')[0]; var svgm2 = svgMixed.getElementsByTagName('path')[1]; -var svgTween51 = KUTE.to(svgm1, { // a regular transform without svg plugin -// svgTransform: { +var svgTween51 = KUTE.to(svgm1, { // a regular CSS3 transform without svg plugin, works in modern browsers only, EXCEPT IE/Edge translate: 250, - rotate: 360, - skewX: -25, - // skewY: 25, scale: 1.5, -// } + rotate: 320, + skewX: -15 }, {transformOrigin: "50% 50%", yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); var svgTween52 = KUTE.to(svgm2, { svgTransform: { - translate: 580+250, + translate: 830, scale: 1.5, - rotate: 360, - skewX: -25, - // skewY: 25, - } -}, {yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); + rotate: 320, + skewX: -15 +} +}, {transformOrigin: "50% 50%", yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"}); mixedBtn.addEventListener('click', function(){ !svgTween51.playing && svgTween51.start(); diff --git a/demo/options.html b/demo/options.html index c8e6c6d..b42d5ad 100644 --- a/demo/options.html +++ b/demo/options.html @@ -98,10 +98,10 @@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 for a given HTML element. No default value.perspectiveOrigin for a given HTML. This option has no default value and only accepts valid CSS values according to it's specs.perspectiveOrigin for a given HTML/SVG element. This option has no default value and only accepts valid CSS values according to it's specs.perspective for the parent of the HTML element subject to the transform animation.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 for the HTML element subject to the transform animation. Also this options only accepts valid CSS values.transformOrigin for the HTML element subject for the transform animation. Starting KUTE.js 1.6.0 this option also aplies to SVG transforms featured with the SVG Plugin. This options only accepts valid CSS values for CSS3 transforms, but keep in mind that for both CSS3 transform and SVG transform attribute KUTE.js will always think of "50% 50%" as the default value, even if most browser's default value for SVG transform origin is "0px 0px 0px" and the reason is simply consistency all round. When applied to a svgTransform property, it can also accept array values: transformOrigin: [250,250].These tests are only for modern browsers. In Google Chrome you can enable the FPS metter in developer tools, here's how.
+These tests are only for modern browsers. In Webkit browsers like Google Chrome and Opera you can enable the FPS metter in developer tools, here's how.
Please know that a local copy of this page will outperform the live site demo on Google Chrome, the reason is unknown.
@@ -125,6 +125,7 @@ +