Compare commits

...

187 commits

Author SHA1 Message Date
thednp 426a45596c Update v2.2.2 2021-12-27 17:36:00 +02:00
thednp 1dfd1e6109
Update svgMorph.html 2021-12-08 22:19:28 +00:00
thednp 19f9df8a93 Update demo 2021-12-08 23:48:42 +02:00
thednp fd8d4ba7c8 Update demo 2021-11-13 18:54:21 +02:00
thednp 62854fba05 Changes:
* updated dependencies
* ESM is now ES6+
2021-05-31 07:47:31 +00:00
thednp af6f86f983 Easing 'easingCircularOut' typo. 2021-03-31 08:29:40 +00:00
thednp 990f6aea93 Fixed some IE issues with new code base. 2021-03-31 08:08:59 +00:00
thednp f524f7ecaf 2021-03-30 11:26:48 +00:00
thednp dd664e9bc7 2021-03-30 11:19:25 +00:00
thednp 72b1847a0a Changes:
* added ESLint and updated all code base 
* updated SVGPathCommander, CubicBezier, shorter-js, minifill
* updated polyfills
* minor CSS fixes
2021-03-30 09:23:30 +00:00
thednp df3505b3c3 Changes:
* updated SVGPathCommander
* fixed small typo issue with SVGDraw
* version bump
2021-01-09 13:31:02 +00:00
thednp ab686c7cdb 2020-09-24 05:07:44 +00:00
thednp 541daab882 Changes, lots of them:
* Updated SVGPathCommander to make use of the new features, the SVG morph components can now process paths in Node.js
* svgCubicMorph component now can morph lines properly, as shown in the updated demo
* svgMorph component also updated
* documentation updates for more clarity with the morph components
2020-09-23 18:59:42 +00:00
thednp 5ce011d41a Changes:
* Solved some minor issue with `pathToCurve` utility
* Updated SVGPathCommander
2020-09-02 13:26:43 +00:00
thednp 441a9ecedb 2020-08-31 15:35:20 +00:00
thednp 17ce738de3 2020-08-18 12:31:44 +00:00
thednp 60950ffd02 2020-08-18 12:24:08 +00:00
thednp a62165820f 2020-08-16 20:15:17 +00:00
thednp eb72644cfe 2020-08-14 11:50:15 +00:00
thednp 307f59a7a4 2020-07-27 09:40:03 +00:00
thednp ffeb00d326 2020-07-03 09:24:10 +00:00
thednp 1b82c657a1 2020-07-02 10:57:47 +00:00
thednp ca0b3c6a15 2020-07-02 10:49:06 +00:00
thednp 997972c35f 2020-06-24 05:44:51 +00:00
thednp 48dc93e438 2020-06-24 05:38:42 +00:00
thednp d6e9319dc3 2020-06-23 22:07:51 +00:00
thednp 732312431b 2020-06-23 16:37:54 +00:00
thednp 918d566d1e 2020-06-20 10:23:40 +00:00
thednp 18cfa78abb 2020-06-20 09:20:10 +00:00
thednp 88a28c8d19 2020-06-16 15:22:06 +00:00
thednp 784e092960 2020-06-16 15:18:29 +00:00
thednp a8c06c1dad 2020-06-16 14:37:41 +00:00
thednp dab615ea54 2020-06-12 08:03:08 +00:00
thednp 8c52e9f9e7 Demo fixes 2020-06-12 06:12:19 +00:00
thednp 7c12028d46 2020-06-11 15:41:39 +00:00
thednp 97c795a972 2020-06-11 15:30:34 +00:00
thednp ced91131a3 2020-06-11 05:01:56 +00:00
thednp 94fe92738c 2020-06-10 14:34:18 +00:00
thednp 7e098ab567 2020-06-10 13:40:18 +00:00
thednp 96f7709012 2020-06-10 13:20:07 +00:00
thednp 2c756c90b7 2020-06-09 21:34:47 +00:00
thednp acbeb00a48 2020-06-09 20:46:08 +00:00
thednp 1d8cf96422 2020-06-09 20:23:36 +00:00
thednp b51196cb86 2020-06-09 20:22:33 +00:00
thednp cb72a478c2 2020-06-09 20:08:43 +00:00
thednp e313cb369f Added a simple example for #96 2019-11-07 17:49:09 +02:00
thednp 81a86026c5 Removed jQuery plugin from documentation 2019-02-01 12:42:31 +02:00
thednp bd73c423b6 Updating gh-pages as well 2019-02-01 12:06:43 +02:00
thednp 96d7f8952a Trying to solve scroll with EDGE/Safari 2018-11-05 13:27:08 +02:00
thednp 2f1fed31e3 Cleanup 2018-10-19 08:56:10 +03:00
thednp 52bfc84ef7 Another typo. 2018-10-19 08:47:51 +03:00
thednp 1e5deb1f1c Typo 2018-10-18 12:09:27 +03:00
thednp 850b1e5960 Fix SVG Plugin function getPolyLength for <polyline> elements. 2018-10-18 11:47:43 +03:00
thednp 393d0a0a2b Added callback reference #73 2018-07-19 09:25:29 +03:00
thednp d33b3b313b A possible fix for #81 2018-07-19 08:39:11 +03:00
thednp 7cd7fe226c Update start.html 2017-10-05 12:57:13 +03:00
thednp c977185621 Update dist files. 2017-10-05 12:55:29 +03:00
thednp 6192946161 Right, changes:
* fixed `scroll` tweening with new webkit browsers versions
* removed `isMobile` for transforms and svg transforms for now
* code cleanup
2017-09-29 00:56:18 +03:00
thednp 9303db19f1 Update Twitter share links. 2017-09-08 11:43:15 +03:00
thednp da327643c7 Improvement for https://github.com/thednp/kute.js/issues/63 2017-05-29 16:03:59 +03:00
thednp af9e57b1f7 Changes:
* code cleanup, more readable code in plugins
* documentation fixes, the easing selectors fixed
2017-02-02 01:23:21 +02:00
thednp e0274126d8 Changes:
* improved `selector` utility
* improved/simplified `getPrefix()` utility
* improve code readability for the core engine
* improved demos
2017-01-31 19:15:13 +02:00
thednp 024fdd2322 Changes:
* Disabled SVG Plugin related scripts on IE8
* Some documentation fine tuning
2017-01-23 18:54:59 +02:00
thednp 449f5ed1e3 Minor documentation fixes:
* Documentation updates
* Fixed navigation on IE8
2017-01-23 15:55:10 +02:00
thednp 293098c0c6 Some minor documentation fixes. 2017-01-14 23:07:41 +02:00
thednp b414705778 Fixed missing default value for repeatDelay. 2017-01-14 22:03:21 +02:00
thednp 709e78ac3b Changes:
* Included fix https://github.com/thednp/kute.js/pull/49
* Implemented https://github.com/thednp/kute.js/issues/47
* Documentation updates
2017-01-03 00:48:28 +02:00
thednp 7b5bb32c17 Mostly doc updates 2016-12-20 22:06:23 +02:00
thednp 2f4810a0a1 SVG transforms now work properly with fromTo() method, no need to do crossCheck for the method 2016-12-16 22:23:23 +02:00
thednp 3f4e0c4d47 Trying to fix a small issue with SVG transforms when initial rotations/scale/skews aren't 0 (zero) 2016-12-14 16:37:50 +02:00
thednp d5d29d53d2 Adjustments for the SVG Plugin:
* `draw` property will work with 2 decimals for more precise animation
* `svgTransform` will also work with  decimals for translation and rotation
* regular transform will need 2 decimals for translation and rotation
2016-12-14 14:41:50 +02:00
thednp 585de95907 LOL 2016-12-11 04:24:18 +02:00
thednp ead5728dcd Major change:
* fixing SVG transforms for good https://github.com/thednp/kute.js/issues/33
* major changes to the tween objects https://github.com/thednp/kute.js/issues/39
* back to Infinity repeat https://github.com/thednp/kute.js/issues/43
* all round performance improvements
2016-12-11 03:48:37 +02:00
thednp 05c15ee98c Issue with text plugin demo 2016-11-30 18:48:20 +02:00
thednp a82263d4b4 Small typo with Attributes plugin 2016-11-30 18:18:53 +02:00
thednp 4f7682cdca Changes:
* Now all parseProperty functions and prepareStart functions are bound to `this`, the tween object
* changed the Tween constructor for lighter size
* rewritten alot of code for readability
* Documentation updates
2016-11-30 18:12:11 +02:00
thednp 1cf5f87f82 Testing new build. 2016-11-28 03:07:16 +02:00
thednp f07f783731 2016-11-26 19:00:32 +02:00
thednp 3005967c32 2016-11-26 18:56:23 +02:00
thednp 6db0e4b92d 2016-11-26 18:31:59 +02:00
thednp 8d70c4a6c7 2016-11-26 18:24:30 +02:00
thednp 5660465f20 2016-11-26 18:22:38 +02:00
thednp 93ab1779a8 2016-11-26 18:15:00 +02:00
thednp d2141361a3 2016-11-26 18:00:23 +02:00
thednp 6ff8e274d1 Documentation updates and performance test page reworked with safety features. 2016-11-26 17:47:17 +02:00
thednp 90dee25c42 Changes:
* Fixed some bug with Attr plugin
* preparing code for a bundle build script
* documentation updates
2016-11-25 22:54:27 +02:00
thednp 5b61b7a1fe Changes:
* fixed minor issue with `borderRadius` on legacy browsers
* removed CSS properties from SVG plugin (forgot in previous commit)
* simplified core box model properties and CSS transform tween objects to always use `px` or `deg` as unit, with converted values
* implemented the `crossCheck` function for SVG transforms (for stacking transform chains) and the SVG morph
* simplified the `coords` interpolation used for SVG morph
* general code cleanup
* simplified the `processEasing` since the additional easing plugins have been removed, the old version can be found in the js file for easing examples page
* doc updates
2016-11-24 22:57:33 +02:00
thednp 112b35aa5f Changes:
* removed CSS props from SVG plugins
* improved CSS transform performance by creating a more simple tween object
* improved radius properties performance 
* removed Bezier and Physics plugins
* fixes scroll animation performance bottlenecks
* code cleanup and a more readable code
* documentation updates
2016-11-23 20:42:01 +02:00
thednp 178cac445e Removed some recursion from plugins. 2016-10-13 15:32:23 +03:00
thednp b8e98b9764 Minor issue with trueColor fixed after previously changed. 2016-10-13 06:09:23 +03:00
thednp 2121a43c8a Type 2016-10-13 05:46:00 +03:00
thednp c8f46895a8 Changes:
* Recursive functions found in `examples.js` and `css.js`. Now `Maximum call stack size exceeded` error is completely eliminated
* Further optimization for the Tween object constructor
2016-10-12 06:44:42 +03:00
thednp 663e98d810 Docs 2016-10-11 11:19:45 +03:00
thednp 2a1b6aebcf docs 2016-10-10 02:34:32 +03:00
thednp 19bd7f7000 docs 2016-10-09 07:58:02 +03:00
thednp 61182d9b68 Small fix to prevent Uncaught RangeError: Maximum call stack size exceeded error. 2016-10-09 06:10:41 +03:00
thednp 670d18894c Changes:
* Removing the `getBestIndex` utility https://github.com/thednp/kute.js/issues/41
* simplify the SVG plugin
* documentation updates
2016-10-09 05:45:21 +03:00
thednp 352069e5c4 Related to CommonJS https://github.com/thednp/kute.js/issues/40#issuecomment-252348599 2016-10-07 23:10:34 +03:00
thednp 188bd1953b Attempting to fix https://github.com/thednp/kute.js/issues/40 2016-10-07 22:59:35 +03:00
thednp 0348584c94 Documentation typo and README updates 2016-10-04 14:39:34 +03:00
thednp 6a6b7cfad0 2016-10-03 19:42:44 +03:00
thednp 901edb1a8b Trying to simplify the tween object, as described
https://github.com/thednp/kute.js/issues/39

Also fixing https://github.com/thednp/kute.js/issues/40

Minor documentation changes
2016-10-03 19:26:17 +03:00
thednp 56883c77a4 Trying to filter this error ReferenceError: window is not defined https://runkit.com/npm/kute.js 2016-09-24 21:34:19 +03:00
thednp f93780061a Type 2016-09-24 12:12:29 +03:00
thednp 7bcc0049d7 2016-09-24 11:02:21 +03:00
thednp 9bbcffb7b6 Quick fixes and some change:
* Removed `dom` from KUTE object, 
* Re-added Tween to KUTE object (was deleted by mistake). 
* Updated demo and the kute-box-shadow sample plugin
2016-09-24 10:39:04 +03:00
thednp cafb243a36 Attributes Plugin can also tween color attributes: fill, stroke, stopColor. Perhaps some things can be removed from SVG Plugin. 2016-09-24 06:02:25 +03:00
thednp 94116ebe76 Changelog 1.5.7:
* changed the jQuery plugin, it's lighter and plays well with tween control methods
* changed the scope of ticker, tick, easing functions, interpolate functions, all to global, for better performance, some will only be available in the global and will be removed from KUTE object
* added transform interpolate functions
* documentation updates
2016-09-24 03:37:02 +03:00
thednp 15a4d86a8f 2016-09-23 00:43:58 +03:00
thednp 3449aa9a7e 2016-09-22 21:11:57 +03:00
thednp 1c2650a154 More experiments. 2016-09-22 20:58:25 +03:00
thednp 4ff44da4f9 2016-09-22 15:30:31 +03:00
thednp ee496ee8f6 Experimenting with exporting stuff to KUTE object, suspecting a bug with Google Chrome 2016-09-22 15:24:49 +03:00
thednp 4b3108c871 Register additional interpolate functions into the object 2016-09-22 14:46:03 +03:00
thednp f05e454f3e Type 2016-09-22 14:42:06 +03:00
thednp f1b2399d05 Code cleanup 2016-09-22 05:26:43 +03:00
thednp d5724b01e4 Minor fix/improvement with Attributes Plugin regarding current attribute value suffix. 2016-09-20 23:32:11 +03:00
thednp 1736cc9c9a SVG Plugin is broken in 1.5.4, now fixed for 1.5.5
Doc Updates for c6e7caabc6
2016-09-20 13:57:05 +03:00
thednp aba3219412 Minor fix 2016-09-20 06:52:42 +03:00
thednp 695f77c9c4 Small improvement, attribute tweening can also take into account current measurement unit if no unit is specified in end values. 2016-09-20 06:45:11 +03:00
thednp 44816ad61e Now the Attributes Plugin should be able to handle properties like 'stroke-width' or fillOpacity 2016-09-20 06:30:53 +03:00
thednp 9aef44f813 Hopefully fixing https://github.com/thednp/kute.js/issues/35 2016-09-19 20:17:17 +03:00
thednp ab8ef18953 Docs update 2016-09-18 01:16:02 +03:00
thednp 3c9683b002 Decreased default morphPrecision from 25 to 15 for better visual. 2016-09-18 01:07:15 +03:00
thednp eaf8f73b07 Replaced prototype with regular object for AttrPlugin I hope it's for better performance 2016-09-18 01:03:06 +03:00
thednp 069a20430c Missing share icons in svg.html page 2016-09-12 17:47:42 +03:00
thednp fde91644b0 NodeList isn't a good idea for the KUTE.selector utility, it's not workin in IE8.
Added a link in the documentation for a pathToAbslute utility for SVG morphing.
2016-09-12 17:09:09 +03:00
thednp e29d08f6bf Quick docs update 2016-09-07 19:09:41 +03:00
thednp 9ed385e4c2 Fixed issue with text-plugin https://github.com/thednp/kute.js/issues/36
Improved overall performance https://github.com/thednp/kute.js/issues/34
Fixed some issues with SVG Plugin https://github.com/thednp/kute.js/issues/33
Documentation updates
2016-09-03 18:35:49 +03:00
thednp 04010b4cab Fixed https://github.com/thednp/kute.js/issues/30
The script didn't handle polygon morphs when both shapes have same number of points.
2016-08-22 17:10:26 +03:00
thednp 5482d8383e * Added SVG Transforms for SVG Plugin
* Documentation/demo updates
2016-08-22 01:45:23 +03:00
thednp 7d44719816 Added support for stroking animation via draw for <ellipse>, some demo improvements. 2016-08-21 00:11:42 +03:00
thednp dfa70cd629 2016-08-20 16:46:16 +03:00
thednp d184fe310c Small demo improvements. 2016-08-20 16:44:53 +03:00
thednp f121972947 SVG Plugin added draw (stroke animations) support for additional elements: <line>, <circle>, <rect>, <polygon> and <polyline>.
https://github.com/thednp/kute.js/issues/28
2016-08-20 15:58:30 +03:00
thednp 3d8fadde3e 2016-08-19 01:30:41 +03:00
thednp 5f10bd711e 2016-08-19 01:12:53 +03:00
thednp 1d153c363a Fixed Angular related issue with SVG Plugin.
https://github.com/thednp/kute.js/issues/29
2016-08-18 22:28:15 +03:00
thednp ed59e23b77 Some documentation updates and social sharing fixes. 2016-08-17 23:40:42 +03:00
thednp b3b806279d Documentation updates, now we have cdnjs repository.
https://cdnjs.com/libraries/kute.js
2016-08-16 19:24:13 +03:00
thednp 95ecba3f67 2016-03-28 16:07:31 +03:00
thednp 2040b36e44 Added a codepen example for SVG, plus more SEO improvements. 2016-03-27 16:20:24 +03:00
thednp a666fda6e3 2016-03-26 21:32:52 +02:00
thednp 428b45f8e8 Some SEO fixes. 2016-03-26 21:27:48 +02:00
thednp ef57b574f2 Minor issue with opacity, scale. 2016-03-25 19:56:46 +02:00
thednp 45901d20ab 2016-03-24 14:49:42 +02:00
thednp 1423ab641e 2016-03-24 14:48:26 +02:00
thednp d972e26f59 Final version 1.5 commit. 2016-03-24 14:27:27 +02:00
thednp b7b82afb6c minor IE8 demo fix 2016-03-19 10:08:34 +02:00
thednp c1e1d06a9f 2016-03-18 19:18:55 +02:00
thednp ac8f5ebe05 Added Text Plugin, updated docs 2016-03-18 16:23:23 +02:00
thednp f909b46a7e 2016-03-17 16:54:13 +02:00
thednp ccd18a2855 typo 2016-03-17 09:00:32 +02:00
thednp ba36c3bf31 2016-03-16 16:28:07 +02:00
thednp 71929b7fc7 The 1.5 first commit, still testing, changelog in the comments 2016-03-16 15:44:23 +02:00
thednp ddb8212e4c Update kute.js 2016-02-18 21:33:15 +02:00
thednp 6b9b095118 Update kute.js 2016-02-18 21:30:40 +02:00
thednp a6534763af Create kute-svg.js 2016-02-18 20:46:32 +02:00
thednp 9fa0b5a328 Create kute.js 2016-02-18 20:44:34 +02:00
thednp 6943b0c7e8 Update api.html 2015-12-30 01:51:22 +02:00
thednp f00ef2dcd6 2015-10-26 13:04:58 +02:00
thednp af58612491 2015-10-26 12:04:54 +02:00
thednp 74f35db07c 2015-10-26 08:36:48 +02:00
thednp 7808f9760f fixed tween.min.js file 2015-10-18 20:38:49 +03:00
thednp 26f03f6134 2015-10-18 10:19:08 +03:00
thednp 9e693955ed 2015-10-18 09:42:40 +03:00
thednp 6860924799 Added some more features, a changelog will come with the tagged release. 2015-10-18 09:40:11 +03:00
thednp 2a15904963 Update kute-dev.js 2015-10-03 22:02:25 +03:00
thednp eec0a2751a Update kute-dev.js 2015-10-03 21:06:08 +03:00
thednp b2bfd94608 Update kute-dev.js 2015-10-03 21:03:46 +03:00
thednp f0d5096572 Update kute-dev.js 2015-10-03 20:58:57 +03:00
thednp 05748003ea Update kute-dev.js 2015-10-03 14:36:33 +03:00
thednp 7ca29f28c9 Update kute-dev.js 2015-10-03 13:35:12 +03:00
thednp 147a8e9fc8 Update kute-dev.js 2015-09-29 17:05:48 +03:00
thednp 641281daf5 Update kute-dev.js 2015-09-28 18:14:23 +03:00
thednp c2d8f0805e Update kute-dev.js 2015-09-28 17:59:54 +03:00
thednp 780e3a0793 Update kute-dev.js 2015-09-28 15:13:27 +03:00
thednp 1e1bb9306c Update kute-dev.js 2015-09-28 15:12:41 +03:00
thednp a89203dfda Update kute-dev.js 2015-09-27 23:37:40 +03:00
thednp f3353235c2 Update kute-dev.js 2015-09-27 23:35:49 +03:00
thednp fad2ff91bc Update kute-dev.js 2015-09-27 18:39:44 +03:00
thednp c4effded66 Update kute-dev.js 2015-09-26 21:58:29 +03:00
thednp d5a18b8fd5 Update kute-dev.js 2015-09-18 18:29:15 +03:00
thednp 0a24580341 Update kute-dev.js 2015-08-03 18:29:58 +03:00
thednp ae8d9d9472 Update kute-dev.js 2015-08-03 18:28:28 +03:00
thednp 7903fcd166 Rename kute-dev to kute-dev.js 2015-08-03 16:54:59 +03:00
thednp 65c14a6cce Create kute-dev 2015-08-03 16:53:17 +03:00
76 changed files with 15446 additions and 1613 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
node_modules
package-lock.json
experiments

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>

1223
assets/css/kute.css Normal file

File diff suppressed because it is too large Load diff

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

@ -0,0 +1,226 @@
/* PrismJS 1.20.0
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+scss&plugins=line-highlight+line-numbers */
/**
* prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML
* Based on https://github.com/chriskempson/tomorrow-theme
* @author Rose Pritchard
*/
code[class*="language-"],
pre[class*="language-"] {
color: #ccc;
background: none;
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
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;
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #051725;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
}
.token.comment,
.token.block-comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #999;
}
.token.punctuation {
color: #ccc;
}
.token.tag,
.token.attr-name,
.token.namespace,
.token.deleted {
color: #e2777a;
}
.token.function-name {
color: #6196cc;
}
.token.boolean,
.token.number,
.token.function {
color: #f08d49;
}
.token.property,
.token.class-name,
.token.constant,
.token.symbol {
color: #f8c555;
}
.token.selector,
.token.important,
.token.atrule,
.token.keyword,
.token.builtin {
color: #cc99cd;
}
.token.string,
.token.char,
.token.attr-value,
.token.regex,
.token.variable {
color: #7ec699;
}
.token.operator,
.token.entity,
.token.url {
color: #67cdcc;
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}
.token.inserted {
color: green;
}
pre[data-line] {
position: relative;
padding: 1em 0 1em 3em;
}
.line-highlight {
position: absolute;
left: 0;
right: 0;
padding: inherit 0;
margin-top: 1em; /* Same as .prisms padding-top */
background: hsla(24, 20%, 50%,.08);
background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
pointer-events: none;
line-height: inherit;
white-space: pre;
}
.line-highlight:before,
.line-highlight[data-end]:after {
content: attr(data-start);
position: absolute;
top: .4em;
left: .6em;
min-width: 1em;
padding: 0 .5em;
background-color: hsla(24, 20%, 50%,.4);
color: hsl(24, 20%, 95%);
font: bold 65%/1.5 sans-serif;
text-align: center;
vertical-align: .3em;
border-radius: 999px;
text-shadow: none;
box-shadow: 0 1px white;
}
.line-highlight[data-end]:after {
content: attr(data-end);
top: auto;
bottom: .4em;
}
.line-numbers .line-highlight:before,
.line-numbers .line-highlight:after {
content: none;
}
pre[id].linkable-line-numbers span.line-numbers-rows {
pointer-events: all;
}
pre[id].linkable-line-numbers span.line-numbers-rows > span:before {
cursor: pointer;
}
pre[id].linkable-line-numbers span.line-numbers-rows > span:hover:before {
background-color: rgba(128, 128, 128, .2);
}
pre[class*="language-"].line-numbers {
position: relative;
padding-left: 3.8em;
counter-reset: linenumber;
}
pre[class*="language-"].line-numbers > code {
position: relative;
white-space: inherit;
}
.line-numbers .line-numbers-rows {
position: absolute;
pointer-events: none;
top: 0;
font-size: 100%;
left: -3.8em;
width: 3em; /* works for line-numbers below 1000 lines */
letter-spacing: -1px;
border-right: 1px solid #999;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.line-numbers-rows > span {
display: block;
counter-increment: linenumber;
}
.line-numbers-rows > span:before {
content: counter(linenumber);
color: #999;
display: block;
padding-right: 0.8em;
text-align: right;
}

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

@ -0,0 +1,305 @@
*,*::before,*::after{
box-sizing:border-box
}
body{
margin:0;
font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
font-size:1rem;
font-weight:400;
line-height:1.5;
color:#212529;
background-color:#fff;
-webkit-text-size-adjust:100%;
-webkit-tap-highlight-color:rgba(0,0,0,0)
}
[tabindex="-1"]:focus:not(:focus-visible){
outline:0 !important
}
hr{
margin:1rem 0;
color:inherit;
background-color:currentColor;
border:0;
opacity:.25
}
hr:not([size]){
height:1px
}
h1,h2,h3,h4,h5,h6{
margin-top:0;
font-weight:500;
line-height:1.2
}
h1{
font-size:calc(1.375rem + 1.5vw)
}
@media(min-width: 1200px){
h1{
font-size:2.5rem
}
}
h2{
font-size:calc(1.325rem + 0.9vw)
}
@media(min-width: 1200px){
h2{
font-size:2rem
}
}
h3{
font-size:calc(1.3rem + 0.6vw)
}
@media(min-width: 1200px){
h3{
font-size:1.75rem
}
}
h4{
font-size:calc(1.275rem + 0.3vw)
}
@media(min-width: 1200px){
h4{
font-size:1.5rem
}
}
h5{
font-size:1.25rem
}
h6{
font-size:1rem
}
p{
margin-top:0;
margin-bottom:1rem
}
abbr[title],abbr[data-original-title]{
text-decoration:underline;
-webkit-text-decoration:underline dotted;
text-decoration:underline dotted;
cursor:help;
-webkit-text-decoration-skip-ink:none;
text-decoration-skip-ink:none
}
address{
margin-bottom:1rem;
font-style:normal;
line-height:inherit
}
ol,ul{
padding-left:2rem
}
ol,ul,dl{
margin-top:0;
margin-bottom:1rem
}
ol ol,ul ul,ol ul,ul ol{
margin-bottom:0
}
dt{
font-weight:700
}
dd{
margin-bottom:.5rem;
margin-left:0
}
blockquote{
margin:0 0 1rem
}
b,strong{
font-weight:bolder
}
small{
font-size:.875em
}
mark{
padding:.2em;
background-color:#fcf8e3
}
sub,sup{
position:relative;
font-size:.75em;
line-height:0;
vertical-align:baseline
}
sub{
bottom:-0.25em
}
sup{
top:-0.5em
}
a{
color:#0d6efd;
text-decoration:underline
}
a:hover{
color:#024dbc
}
a:not([href]):not([class]),a:not([href]):not([class]):hover{
color:inherit;
text-decoration:none
}
pre,code,kbd,samp{
font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
font-size:1em
}
pre{
display:block;
margin-top:0;
margin-bottom:1rem;
overflow:auto;
font-size:.875em;
-ms-overflow-style:scrollbar
}
pre code{
font-size:inherit;
color:inherit;
word-break:normal
}
code{
font-size:.875em;
color:#d63384;
word-wrap:break-word
}
a>code{
color:inherit
}
kbd{
padding:.2rem .4rem;
font-size:.875em;
color:#fff;
background-color:#212529;
border-radius:.2rem
}
kbd kbd{
padding:0;
font-size:1em;
font-weight:700
}
figure{
margin:0 0 1rem
}
img,svg{
vertical-align:middle
}
table{
caption-side:bottom;
border-collapse:collapse
}
caption{
padding-top:.5rem;
padding-bottom:.5rem;
color:#6c757d;
text-align:left
}
th{
text-align:inherit;
text-align:-webkit-match-parent
}
thead,tbody,tfoot,tr,td,th{
border-color:inherit;
border-style:solid;
border-width:0
}
label{
display:inline-block
}
button{
border-radius:0
}
button:focus{
outline:1px dotted;
outline:5px auto -webkit-focus-ring-color
}
input,button,select,optgroup,textarea{
margin:0;
font-family:inherit;
font-size:inherit;
line-height:inherit
}
button,input{
overflow:visible
}
button,select{
text-transform:none
}
[role=button]{
cursor:pointer
}
select{
word-wrap:normal
}
[list]::-webkit-calendar-picker-indicator{
display:none
}
button,[type=button],[type=reset],[type=submit]{
-webkit-appearance:button
}
button:not(:disabled),[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled){
cursor:pointer
}
::-moz-focus-inner{
padding:0;
border-style:none
}
textarea{
resize:vertical
}
fieldset{
min-width:0;
padding:0;
margin:0;
border:0
}
legend{
float:left;
width:100%;
padding:0;
margin-bottom:.5rem;
font-size:calc(1.275rem + 0.3vw);
line-height:inherit;
white-space:normal
}
@media(min-width: 1200px){
legend{
font-size:1.5rem
}
}
legend+*{
clear:left
}
::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-text,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{
padding:0
}
::-webkit-inner-spin-button{
height:auto
}
[type=search]{
outline-offset:-2px;
-webkit-appearance:textfield
}
::-webkit-search-decoration{
-webkit-appearance:none
}
::-webkit-color-swatch-wrapper{
padding:0
}
::-webkit-file-upload-button{
font:inherit;
-webkit-appearance:button
}
output{
display:inline-block
}
iframe{
border:0
}
summary{
display:list-item;
cursor:pointer
}
progress{
vertical-align:baseline
}
[hidden]{
display:none !important
}

172
assets/css/spicr-theme.css Normal file
View file

@ -0,0 +1,172 @@
/* Spicr theme | thednp © 2020 | MIT-License */
.text-left{
text-align:left
}
.text-center{
text-align:center
}
.text-right{
text-align:right
}
@media(min-width: 768px){
.text-md-left{
text-align:left
}
.text-md-center{
text-align:center
}
.text-md-right{
text-align:right
}
}
.center-block{
display:block;
margin-left:auto;
margin-right:auto
}
.float-right{
float:right !important
}
.float-left{
float:left !important
}
.float-none{
float:none !important
}
.font-weight-normal{
font-weight:normal
}
.font-weight-bold{
font-weight:bold
}
#SpicrDemo{
height:600px
}
.spicr .lead{
margin:0;
font-weight:bold;
text-transform:uppercase;
color:#fff
}
.overlay{
background:rgba(0,0,0,.45);
position:absolute;
top:0;
right:0;
width:100%;
height:100%
}
.spicr-carousel-navigation>*{
vertical-align:text-bottom
}
@media(min-width: 479px){
.spicr-control.long-shadows{
transition:opacity .3s ease-in
}
.spicr-control.long-shadows .arrow-prev{
margin-left:-280px;
padding:0px 5px 0px 250px;
transform:translate(-100%)
}
.spicr-control.long-shadows .arrow-next{
margin-right:-280px;
padding:0px 250px 0px 5px;
transform:translate(100%)
}
.spicr-control.long-shadows .arrow-prev,.spicr-control.long-shadows .arrow-next{
transition:all 1s ease-in
}
.spicr:hover .spicr-control.long-shadows .arrow-prev,.spicr:hover .spicr-control.long-shadows .arrow-next{
transition-duration:.3s;
transition-timing-function:ease-out
}
.spicr-control.long-shadows:focus .arrow-prev,.spicr-control.long-shadows:focus .arrow-next{
transform:translate(0%)
}
.spicr:hover .spicr-control.long-shadows .arrow-prev{
transform:translate(0%)
}
.spicr:hover .spicr-control.long-shadows .arrow-next{
transform:translate(0%)
}
.spicr-control.long-shadows .spicr-icon{
width:40px;
height:40px
}
.spicr-control.long-shadows .arrow-next,.spicr-control.long-shadows .arrow-prev{
border-radius:40px;
margin-top:-20px
}
.spicr-control.long-shadows:focus .arrow-prev{
transform:translate(0%)
}
.spicr-control.long-shadows:focus .arrow-next{
transform:translate(0%)
}
.spicr-control.long-shadows .arrow-prev,.spicr-control.long-shadows .arrow-next{
display:block;
width:auto;
height:auto;
background-color:#000;
background-color:rgba(0,0,0,.3)
}
}
.spicr-carousel h4{
margin-top:0
}
.spicr-slider{
font-size:calc(0.5rem + 1.5vw);
line-height:calc(0.6rem + 1.5vw)
}
.spicr-slider h1{
font-size:calc(1.375rem + 1.5vw);
letter-spacing:-1px;
margin:0
}
.spicr-slider h2{
font-size:calc(1.375rem + 0.9vw);
letter-spacing:0;
margin:0
}
.features-carousel .spicr-pages{
top:.5rem
}
.features-carousel .spicr-pages li{
line-height:1.5rem;
padding:.5rem 1rem
}
@media(min-width: 768px){
.featurette-heading span{
font-size:24px;
line-height:1;
letter-spacing:-1px
}
.spicr-slider{
font-size:1rem;
line-height:1.8rem
}
.spicr-slider h1{
font-size:42px;
line-height:1;
letter-spacing:-2px;
margin:0 0 1.5rem
}
.spicr-slider h2{
font-size:36px;
line-height:1;
letter-spacing:-1px;
margin:0 0 1.5rem
}
}
.background-top-left { background-position: top left !important}
.background-top-center { background-position: top center !important}
.background-top-right { background-position: top center !important}
.background-center-left { background-position: center left !important}
.background-center-center { background-position: center center !important}
.background-center-right { background-position: center right !important}
.background-bottom-left { background-position: bottom left !important}
.background-bottom-center { background-position: bottom center !important}
.background-bottom-right { background-position: bottom right !important}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
assets/img/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

56
assets/img/home.svg Normal file
View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 600 600" style="enable-background:new 0 0 600 600;" xml:space="preserve">
<style type="text/css">
.st0{display:none;}
.st1{display:none;fill:#2196F3;}
</style>
<path id="rectangle" class="st0" d="M559,597.4H302.1H43.6c-21,0-38-17-38-38V408.8V223.6V44c0-21,17-38,38-38h105.6H300h160.3H559
c21,0,38,17,38,38v184v331.4C597,580.4,580,597.4,559,597.4z"/>
<circle id="circle" class="st0" cx="367.7" cy="377.3" r="210.9"/>
<path id="star" class="st0" d="M302.1,17.9c16,29,81.4,147.7,98.2,178.2c31.1,6,62.3,11.9,93.4,17.9c35.5,6.8,71,13.6,106.5,20.4
c-46.4,49.5-92.7,99-139.1,148.5c1.1,8.5,6.7,53.4,12.4,99.1c5.7,45.3,11.4,91.4,12.9,102.9c-36-16.9-158.8-74.5-184.2-86.4
c-28.5,13.4-151.3,71-184.2,86.4c0.4-3.2,13.3-106.6,13.3-106.6s10.1-81,11.9-95.3C96.8,333.5,50.4,284,4,234.5
c34.4-6.6,68.8-13.2,103.3-19.8c32.2-6.2,64.4-12.3,96.5-18.5C221,165.1,286.5,46.2,302.1,17.9z"/>
<path id="kute-head" class="st1" d="M505.1,520.1c-15.5-13-26-49.1-50.6-67.2c-61.6-45-107.4-15-77.4,20.1
c14.3,16.8,27.2,13.2,40.5,25.2c20.1,18.6,3.1,40.7-15.5,39.2c-10.4-0.8-16.5-10.4-38.2-17.6c-34.9-11.7-84.2-11.2-164.7-24.4
c-109.4-17.8-230.6-111-182-241C62.5,133.5,115.5,62.5,244.8,62.5c170.5,0,213.5,140.7,248.4,210c16.3,32.3,22.7,26.2,36.1,44.8
c12.2,17.1,1.5,46.1-22.9,37.9c-53.7-17.8-77.1,27.2-23.2,62.9c14.5,9.7,59.3,15,73.8,24.7C610.8,478.6,553,560.1,505.1,520.1
L505.1,520.1z"/>
<path id="winky-face" class="st0" d="M347.1,289.3l-13-16.5c-20.1,25.7-15.8,25.2-35.6,0l-13,16.5c-5.1,6.6-14.8-1.3-9.7-7.6
c25.2-32.3,19.9-32.8,40.5-6.4c20.4-26,14.8-26.7,40.5,6.4c2,2.8,1.3,6.6-1.5,8.7C352.7,292.1,349.1,291.6,347.1,289.3L347.1,289.3z
M118,289.3l-13-16.5c-20.1,25.7-15.8,25.2-35.6,0l-13,16.5c-5.1,6.6-14.8-1.3-9.7-7.6c25.2-32.3,19.9-32.8,40.5-6.4
c20.4-26,14.8-26.7,40.5,6.4c2,2.8,1.3,6.6-1.5,8.7C123.6,292.1,120.1,291.6,118,289.3L118,289.3z"/>
<path id="drop" class="st1" d="M558.6,365.4c-13,20.4,23.4,44,36.7,23.7C608.2,368.9,571.8,345.3,558.6,365.4z"/>
<path id="mouth-happy" class="st0" d="M251.9,259c-2,26.5-24.2,46.8-50.4,46.8c-26.5,0-48.4-20.4-50.4-46.6c0-2,1.3-3.8,3.3-3.8
h93.9C250.4,255.2,251.9,256.9,251.9,259L251.9,259z"/>
<path id="mouth" class="st0" d="M173.6,270.5c18,0.4,37.1,0.2,55.9,0c17.3-0.2,17.2,27.3-0.6,27.4c-24.5,0.2-29.4,0.4-54.6,0
C158.9,297.8,156.9,270.2,173.6,270.5z"/>
<path id="eye-left-closed" class="st0" d="M123.1,221.8c-11.5-9.7-35.1-9.7-46.6,0C65.6,231.2,51,214.7,62,205
c19.9-16.8,55.7-16.8,75.6,0C148.6,214.4,133.8,231.5,123.1,221.8z"/>
<path id="eye-right-closed" class="st0" d="M339.7,221.8c-11.5-9.7-35.1-9.7-46.6,0c-10.9,9.4-25.7-7.1-14.5-16.8
c19.9-16.8,55.7-16.8,75.6,0C365.4,214.4,350.7,231.2,339.7,221.8z"/>
<path id="eye-right_1_" class="st0" d="M316.2,236.1c-31.6,0-48.7-21.4-37.5-31.1c19.9-16.8,55.7-16.8,75.6,0
C365.4,214.4,350.9,236.1,316.2,236.1z"/>
<path id="eye-left_1_" class="st0" d="M99.4,236.1c-31.6,0-48.7-21.4-37.5-31.1c19.9-16.8,55.7-16.8,75.6,0
C148.7,214.4,134.1,236.1,99.4,236.1z"/>
<path id="drop-initial" class="st0" d="M505.2,327.1"/>
<path id="polygon" d="M447,45.4H153L6.1,300L153,554.6h294L593.9,300L447,45.4z"/>
<path id="cat" class="st0" d="M519.8,118.6C518.4,90.8,483.3,78,460,82.5c-51.1,9.7-59.4,67.2-48.3,109.4
c5.4,20.5,15.1,42.7,13.6,64.3c-1.3,19.5-7.8,39.2-20.7,54.1c1-0.1,2.2-0.3,3.2-0.4c-1,0.1-2.2,0.3-3.2,0.4
c-12.9,2-25.3,7.4-29.6,9.6c-0.9-13.3-1.8-24.5-2.3-31.9c-0.4-10.3-0.8-18.6-1.1-23.9c-1-12.6-15.9-25.3-28.2-33.7
c-8.8-6-16.5-9.8-16.5-9.8c13.8-10.2,19.8-17.6,21.6-23.9c2.3-8,4.3-35.1,4.3-35.1s1.1-6,1.1-15.2c0-11.6-2-22.6-5.7-32.9h0.1
c0,0,25.4-45.8,14.7-60.1c-8.9-11.7-46.3,16.7-46.3,16.7c-16.3-12.6-36.9-20.2-59.1-20.2c-6,0-11.9,0.5-17.7,1.7
c0,0-7.4-41.3-27.3-39.7c-19.8,1.7-29.3,72.8-29.3,72.8l0.1,0.1c-8.3,9.9-14.7,21.6-18.4,34.3c0,0-11.2,26.4-10.3,42.7
c0.9,16.2,15.9,31.2,25.6,42.3l18.9,19.1c0,0,2.8,3.1,6.9,6.9c-0.4,0.3-3.1,1.5-7,3.8c-11.1,6.4-31.5,20.5-36,41.5
c-0.4,1.9-0.8,4-1,6.1c-1.7,12.8-1.4,30.1-0.4,46.6c-5.9-4.1-25.5-15.8-40.3-4.3c-0.6,0.5-1.1,0.9-1.8,1.4
c-16.5,13.9-25.4,34.4-25.4,53.8c0,9.7,3.7,29.1,12,50.4c1,2.8,2.3,5.6,3.6,8.4c4.6,10.3,10.2,20.8,17.2,30.6
c6.8,9.7,14.8,18.6,24.1,26c0,0-24.2,13.8-33,32.7s-6.6,28.1,3.3,29.7c10.1,1.7,57.1-21.8,57.1-21.8c-0.6,2.9-1.5,6.1-2.6,9.6
c-5.7,9.7-12.8,22.2-7.3,31.4c1.8,2.9,4.8,5.6,9.8,7.7c20.8,8.8,41.2,2.3,50.8-8.4c2.9-3.2,4.8-6.6,5.6-10.3
c1.1-6.1,1-19.3,0.5-34.3c0,0,39.5,9.9,74.9-4c2.9,21.4,5.5,38.8,6.1,43.2c0.1,0.9,0.4,1.7,0.6,2.4c2,4.5,9.9,17.5,34.8,14.5
c12.6-1.5,19.4-7.8,22.8-12.8c1.1-1.7,1.9-3.4,2.2-5.4c0.1-1.1,0.1-2.4-0.1-3.6c-0.8-1.8-1.5-4.1-2.3-6.8c-3.1-8.5-7.7-21.6-10.7-33
h0.1c0,0,1.3,0.3,3.4,0.8c11.7,2.8,50.3,11.5,53.1,9.3c3.3-2.4,5.7-10.6,2.6-24.2c-3.8-16.5-38.5-24.7-38.5-24.7s3.7-4.8,9.2-12.5
c14.2-19.8,40.4-58.3,46.4-80.4c7.7-27.9,9.3-58.7-4.2-74.9c20.3-37.8,27.5-78.3,15.1-120c-5.4-18-21.7-63.1,0.9-75.9
c8.9-5,25.9-8.4,30.1,4.7c0,0-7.8,8.7-9.2,14.4c-1.3,5.9-1.9,16.2,14,18.1C502.4,162.3,521.4,150.6,519.8,118.6z"/>
</svg>

After

Width:  |  Height:  |  Size: 5.1 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

27
assets/img/ms.svg Normal file
View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="multi-morph-example" viewBox="0 0 550 550">
<path id="w21" class="st0" d="M192,470.9L0.2,444.6v-98.7V287H108h84V470.9z"/>
<path id="w22" class="st0" d="M480,288l-0.1,224l-138.7-19.5L224,476V288h128H480z"/>
<path id="w23" class="st0" d="M0.2,256L0,100l99.5-13.5L192,73.9V256H87H0.2z"/>
<path id="w24" class="st0" d="M224,69.2l147.7-21.5L479.9,32v224H352H224V69.2z"/>
<path id="w11" class="st1" d="M128.2,237.8c-44.1,0-78.7,18.7-83.3,20.6L0,414.1c30.9-11.4,58.1-17,83.1-17
c40.4,0,69.8,15.1,94,30.7c11.5-39,39-133,47.2-161.2C205.7,254.8,176.7,237.8,128.2,237.8z"/>
<path id="w12" class="st2" d="M264.2,295.5L219,452.6c13.4,7.7,58.5,32,93.1,32c27.9,0,59.1-7.1,95.4-21.9l43.2-151
c-29.3,9.5-57.4,14.3-83.7,14.3C318.9,326,285.4,310.5,264.2,295.5z"/>
<path id="w13" class="st3" d="M146.4,184.4c38.6,0.4,67.1,15.1,90.7,30.3L283.5,56c-9.8-5.6-41.4-27.7-92.5-28.6
c-25.9,0.5-54.2,7-86.4,19.9L60.3,202.6C92.7,190.3,120.6,184.4,146.4,184.4L146.4,184.4L146.4,184.4z"/>
<path id="w14" class="st4" d="M512,99.1c-29.4,11.4-58.1,17.2-85.5,17.2c-45.8,0-79.6-15.9-101.5-31.2l-46,159.1
c30.9,19.9,64.1,29.9,99.1,29.9c43.1,0,89.5-21.9,89.5-21.9L512,99.1z"/>
<path id="s21" d="M192,471.9L0.2,445.6V288h87.3h52.3H192V471.9z"/>
<path id="s22" class="st0" d="M480,288l-0.1,224L224,476V288H480z"/>
<path id="s23" class="st0" d="M0.2,256L0,100l88.7-12.1l103.3-14V256H0.2z"/>
<path id="s24" d="M224,69.2L479.9,32v224H354.7h-69.4H224V69.2z"/>
<path id="s11" class="st1" d="M128.2,237.8c-44.1,0-78.7,18.7-83.3,20.6L0,414.1c30.9-11.4,58.1-17,83.1-17
c40.4,0,69.8,15.1,94,30.7c11.5-39,39-133,47.2-161.2C205.7,254.8,176.7,237.8,128.2,237.8z"/>
<path id="s12" class="st5" d="M264.2,295.5L219,452.6c13.4,7.7,58.5,32,93.1,32c27.9,0,59.1-7.1,95.4-21.9l43.2-151
c-29.3,9.5-57.4,14.4-83.7,14.3C310.6,325.9,276,303.9,264.2,295.5z"/>
<path id="s13" class="st6" d="M146.4,184.4c38.6,0.4,67.1,15.1,90.7,30.3L283.5,56c-6.6-3.7-45.7-28.6-92.5-28.6
c-25.9,0.5-54.2,7-86.4,19.9L60.3,202.6C92.7,190.3,120.6,184.4,146.4,184.4z"/>
<path id="s14" class="st4" d="M512,99.1c-29.4,11.4-58.1,17.2-85.5,17.2c-45.8,0-79.6-15.9-101.5-31.2l-46,159.1
c30.9,19.9,64.1,29.9,99.1,29.9c43.1,0,89.5-21.9,89.5-21.9L512,99.1z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

14
assets/img/rectangle.svg Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 600 600" style="enable-background:new 0 0 600 600;" xml:space="preserve">
<style type="text/css">
.st0{display:none;}
</style>
<path id="rectangle" class="st0" d="M559,597.4H302.1H43.6c-21,0-38-17-38-38V300V44c0-21,17-38,38-38H300h259c21,0,38,17,38,38
v257.7v257.7C597,580.4,580,597.4,559,597.4z"/>
<path id="star" d="M302.1,17.9c16,29,81.4,147.7,98.2,178.2c13.7,2.6,47.3,9.1,83.5,16c46.1,8.8,96.5,18.5,116.4,22.3
c-25.1,26.7-117.8,125.7-139.1,148.5c1.1,8.5,23.8,190.5,25.3,202c-36-16.9-158.8-74.5-184.2-86.4c-28.5,13.4-151.3,71-184.2,86.4
c0.4-3.2,23.4-187.6,25.2-201.9C122.8,361.3,30,262.3,4,234.5c17.3-3.3,59.5-11.4,101.3-19.4c41.4-7.9,82.5-15.8,98.5-18.9
C221,165.1,286.5,46.2,302.1,17.9z"/>
</svg>

After

Width:  |  Height:  |  Size: 997 B

34
assets/img/social.svg Normal file
View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="complex-morph-example" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px" y="0px" viewBox="0 0 513 513" style="enable-background:new 0 0 513 513;" xml:space="preserve">
<style type="text/css">
.st0{display:none;}
</style>
<path id="symbol-left" class="st0" d="M155.9,333.4h-55.6c-3.4,0-5.9-1.5-7.3-3.8c-1.5-2.4-1.5-5.5,0-8.5l59.1-104.3
c0.1-0.1,0.1-0.2,0-0.3l-37.6-65.1c-1.6-3.1-1.8-6.2-0.3-8.5c1.4-2.3,4.2-3.5,7.6-3.5h55.6c8.5,0,12.7,5.5,15.5,10.4
c0,0,38,66.3,38.2,66.7c-2.3,4-60.1,106.2-60.1,106.2C168.2,327.8,164.2,333.4,155.9,333.4z"/>
<path id="symbol-left-clone" class="st0" d="M155.9,333.4h-55.6c-3.4,0-5.9-1.5-7.3-3.8c-1.5-2.4-1.5-5.5,0-8.5l59.1-104.3
c0.1-0.1,0.1-0.2,0-0.3l-37.6-65.1c-1.6-3.1-1.8-6.2-0.3-8.5c1.4-2.3,4.2-3.5,7.6-3.5h55.6c8.5,0,12.7,5.5,15.5,10.4
c0,0,38,66.3,38.2,66.7c-2.3,4-60.1,106.2-60.1,106.2C168.2,327.8,164.2,333.4,155.9,333.4z"/>
<path id="symbol-right" class="st0" d="M419,75.3L295.8,293.1c-0.1,0.1-0.1,0.3,0,0.4l78.4,143.3c1.6,3.1,1.6,6.2,0.1,8.6
c-1.4,2.3-4,3.6-7.4,3.6h-55.6c-8.5,0-12.8-5.7-15.5-10.6c0,0-78.8-144.6-79.1-145c3.9-7,123.8-219.5,123.8-219.5
c3-5.4,6.6-10.6,14.9-10.6h56.2c3.4,0,6,1.3,7.4,3.6C420.5,69.1,420.5,72.2,419,75.3L419,75.3z"/>
<path id="eye-right" class="st0" d="M352,128c2.6,0,5,0.5,7.4,1.3c2.3,0.8,4.5,2,6.6,3.6c10.6,7.8,18,24.2,18,43.1
c0,16.2-5.3,30.5-13.5,39.2c-3.1,3.3-6.6,5.8-10.5,7.3c-2.6,1-5.3,1.5-8,1.5c-4,0-7.8-1.1-11.3-3.1c-2.7-1.6-5.3-3.7-7.6-6.2
c-7.9-8.7-13-22.8-13-38.7c0-19.2,7.5-35.7,18.4-43.4c1.9-1.4,4-2.5,6.1-3.2C346.9,128.5,349.4,128,352,128z"/>
<path id="eye-left" class="st0" d="M176,156c10.4,0,19.7,1.4,27.5,3.9c14.5,4.7,23.5,13.4,23.5,24.8c0,3.7,1.9,21.5-0.1,24.8
c-3.3-5.5-9.2-10.3-16.7-13.9c-5.6-2.7-12.2-4.8-19.4-6c-4.7-0.8-9.6-1.2-14.7-1.2c-8.9,0-17.3,1.3-24.7,3.5
c-12.2,3.7-21.6,10-26.3,17.6c-2-3.3-0.1-21.1-0.1-24.8c0-11.3,8.8-19.9,23-24.6c3.7-1.2,7.8-2.2,12.2-2.9
C165.1,156.4,170.4,156,176,156z"/>
<path id="mouth" class="st0" d="M250.2,416c-42.9,0-82-16.6-111.5-43.9c-7-6.5-13.5-13.6-19.4-21.2c-3.8-4.9-7.3-10-10.6-15.4
c5.6,4.4,11.9,8.2,18.7,11.5c7.1,3.4,14.8,6.2,23,8.4c33.9,9.2,76.7,8.9,120.9,0.1c47.2-9.3,87.3-26.8,114.5-50.3
c6-5.1,11.3-10.6,16-16.3c5.6-6.9,10.3-14.2,13.8-21.8c-1.2,9.2-3.1,18.2-5.7,26.9c-2.6,8.8-5.9,17.3-9.7,25.5
C373.1,376.7,316.1,416,250.2,416L250.2,416z"/>
<path id="rectangle-container" class="st0" d="M426.7,0H85.3C38.4,0,0,38.4,0,85.3v341.3c0,47,38.4,85.3,85.3,85.3h341.3
c46.9,0,85.3-38.4,85.3-85.3V85.3C512,38.4,473.6,0,426.7,0z"/>
<path id="circle-container" d="M0,256c0,100.9,59.8,165.3,72,177.9c9.1,9.4,34.7,34.4,75.6,53.5c50.6,23.7,95,24.6,108.4,24.6
c10.9,0,61.3-0.9,117.6-30c42.1-21.8,67.4-49,73.1-55.3c64-70.6,65.3-157,65.3-170.7c0-18.9-2.1-96.7-61-165.9
c-8.6-10.2-37.3-42-86-65C313.6,0.9,268.6,0,256,0c-11,0-61.8,0.8-118.2,30.1C97.1,51.3,72.4,77.3,66.6,83.7C1.3,154.7,0,243,0,256z
"/>
</svg>

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -0,0 +1,11 @@
/* BACKGROUND POSITION EXAMPLE */
var bgPos = document.getElementById('bgPos'),
bgBox = bgPos.querySelector('.example-box'),
bgb = bgPos.querySelector('.btn'),
bpTween = KUTE.to(bgBox, {backgroundPosition: ['0%','50%']}, { yoyo: true, repeat: 1, duration: 1500, easing: 'easingCubicOut'});
bgb.addEventListener('click', function(e){
e.preventDefault();
!bpTween.playing && bpTween.start();
},false);
/* BACKGROUND POSITION EXAMPLE */

12
assets/js/borderRadius.js Normal file
View file

@ -0,0 +1,12 @@
/* RADIUS EXAMPLES */
var radiusBtn = document.getElementById('radiusBtn');
var allRadius = KUTE.to('#allRadius',{borderRadius:80},{duration: 1500, easing:'easingCubicOut', repeat: 1, yoyo: true});
var tlRadius = KUTE.to('#tlRadius',{borderTopLeftRadius:150},{duration: 1500, easing:'easingCubicOut', repeat: 1, yoyo: true});
var trRadius = KUTE.to('#trRadius',{borderTopRightRadius:150},{duration: 1500, easing:'easingCubicOut', repeat: 1, yoyo: true});
var blRadius = KUTE.to('#blRadius',{borderBottomLeftRadius:150},{duration: 1500, easing:'easingCubicOut', repeat: 1, yoyo: true});
var brRadius = KUTE.to('#brRadius',{borderBottomRightRadius:150},{duration: 1500, easing:'easingCubicOut', repeat: 1, yoyo: true});
radiusBtn.addEventListener('click',function(){
if (!allRadius.playing) { allRadius.start(); tlRadius.start(); trRadius.start(); blRadius.start(); brRadius.start(); }
}, false);
/* RADIUS EXAMPLES */

49
assets/js/boxModel.js Normal file
View file

@ -0,0 +1,49 @@
/* BOX MODEL EXAMPLE */
var boxModel = document.getElementById('boxModel'),
btb = boxModel.querySelector('.btn'),
box = boxModel.querySelector('.example-box-model');
// built the tween objects
var bm1 = KUTE.to(box,{width:250},{ yoyo: true, repeat: 1, duration: 1500, onUpdate: onWidth});
var bm2 = KUTE.to(box,{height:250},{ yoyo: true, repeat: 1, duration: 1500, onUpdate: onHeight});
var bm3 = KUTE.to(box,{left:250},{ yoyo: true, repeat: 1, duration: 1500, onUpdate: onLeft});
var bm4 = KUTE.to(box,{top:-250},{ yoyo: true, repeat: 1, duration: 1500, onUpdate: onTop, onComplete: onComplete});
var bm5 = KUTE.to(box,{marginTop:50},{ yoyo: true, repeat: 1, duration: 1500, onUpdate: onMarginTop});
var bm6 = KUTE.to(box,{marginBottom:50},{ yoyo: true, repeat: 1, duration: 1500, onUpdate: onMarginBottom});
var bm7 = KUTE.to(box,{paddingTop:15},{ yoyo: true, repeat: 1, duration: 1500, onUpdate: onPadding});
var bm8 = KUTE.to(box,{marginTop:50,marginLeft:50,marginBottom:70},{ yoyo: true, repeat: 1, duration: 1500, onUpdate: onMargin, onComplete: onComplete});
// chain the bms
try{
bm1.chain(bm2);
bm2.chain(bm3);
bm3.chain(bm4);
bm4.chain(bm5);
bm5.chain(bm6);
bm6.chain(bm7);
bm7.chain(bm8);
}catch(e){
console.error(e+". TweenBase doesn\'t support chain method")
}
//callback functions
function onWidth() { box.innerHTML = 'WIDTH<br>'+parseInt(box.offsetWidth)+'px'; }
function onHeight() { box.innerHTML = 'HEIGHT<br>'+parseInt(box.offsetHeight)+'px'; }
function onLeft() { box.innerHTML = 'LEFT<br>'+parseInt(box.offsetLeft)+'px'; }
function onTop() { box.innerHTML = 'TOP<br>'+parseInt(box.offsetTop)+'px'; }
function onMarginTop() { box.innerHTML = parseInt(box.style.marginTop)+'px'+'<br>MARGIN'; }
function onMarginBottom() { box.innerHTML = 'MARGIN<br>'+parseInt(box.style.marginBottom)+'px'; }
function onPadding() { box.innerHTML = parseInt(box.style.paddingTop)+'px<br>PADDING'; }
function onMargin() { box.innerHTML = 'MARGIN<br>'+parseInt(box.style.marginTop)+'px'; }
function onComplete() { box.innerHTML = 'BOX<br>&nbsp;MODEL&nbsp;'; }
btb.addEventListener('click', function(e){
e.preventDefault();
!bm1.playing && !bm2.playing && !bm3.playing && !bm4.playing
!bm5.playing && !bm6.playing && !bm7.playing && !bm8.playing
&& bm1.start();
},false);
/* BOX MODEL EXAMPLE */

25
assets/js/clipProperty.js Normal file
View file

@ -0,0 +1,25 @@
/* CLIP EXAMPLE */
var clipExample = document.getElementById('clip'),
clipElement = clipExample.querySelector('.example-box'),
clpbtn = clipExample.querySelector('.btn');
var clp1 = KUTE.to(clipElement, {clip: [0,20,150,0]}, {duration:500, easing: 'easingCubicOut'});
var clp2 = KUTE.to(clipElement, {clip: [0,150,150,130]}, {duration:600, easing: 'easingCubicOut'});
var clp3 = KUTE.to(clipElement, {clip: [0,150,20,0]}, {duration:800, easing: 'easingCubicOut'});
var clp4 = KUTE.to(clipElement, {clip: [0,150,150,0]}, {duration:1200, easing: 'easingExponentialInOut'});
//chain some clps
try{
clp1.chain(clp2);
clp2.chain(clp3);
clp3.chain(clp4);
}catch(e){
console.error(e+". TweenBase doesn\'t support chain method")
}
clpbtn.addEventListener('click', function(e){
e.preventDefault();
!clp1.playing && !clp2.playing && !clp3.playing && !clp4.playing && clp1.start();
},false);
/* CLIP EXAMPLE */

View file

@ -0,0 +1,39 @@
/* 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, {color: '#fff'}, {duration: 1000});
var colTween4 = KUTE.to(colBoxElement, {backgroundColor: '#9C27B0'}, {duration: 1000});
var colTween5 = KUTE.to(colBoxElement, {borderColor: '#069'}, {duration: 1000});
var colTween6 = KUTE.to(colBoxElement, {borderTopColor: '#9C27B0'}, {duration: 1000});
var colTween7 = KUTE.to(colBoxElement, {borderRightColor: '#9C27B0'}, {duration: 1000});
var colTween8 = KUTE.to(colBoxElement, {borderBottomColor: '#9C27B0'}, {duration: 1000});
var colTween9 = KUTE.to(colBoxElement, {borderLeftColor: '#9C27B0'}, {duration: 1000});
var colTween10 = KUTE.to(colBoxElement, {outlineColor: '#9C27B0'}, {duration: 1000, repeat: 1, yoyo: true});
try {
colTween1.chain(colTween2);
colTween2.chain(colTween3);
colTween3.chain(colTween4);
colTween4.chain(colTween5);
colTween5.chain(colTween6);
colTween6.chain(colTween7);
colTween7.chain(colTween8);
colTween8.chain(colTween9);
colTween9.chain(colTween10);
} catch(e){
console.error(e+". TweenBase doesn\'t support chain method")
}
colbtn.addEventListener('click', function(e){
e.preventDefault();
!colTween1.playing && !colTween2.playing && !colTween3.playing && !colTween4.playing
!colTween5.playing && !colTween6.playing && !colTween7.playing && !colTween8.playing
!colTween9.playing && !colTween10.playing && colTween1.start();
},false);
/* COLORS EXAMPLE */

View file

@ -0,0 +1,18 @@
/* FILTER EFFECTS EXAMPLES */
var filterExamples = document.getElementById('filter-examples'),
filterBtn = filterExamples.querySelector('.btn'),
fe1 = filterExamples.getElementsByTagName('div')[0],
fe2 = filterExamples.getElementsByTagName('div')[1],
fe3 = filterExamples.getElementsByTagName('div')[2],
fe4 = filterExamples.getElementsByTagName('div')[3],
fe1Tween = KUTE.to(fe1, {filter :{ url: '#mySVGFilter', blur: 0.05, saturate: 10 }}, {easing: 'easingCubicOut', duration: 1500, repeat:1, yoyo: true}),
fe2Tween = KUTE.to(fe2, {filter :{ url: '#mySVGFilter', sepia: 50, invert: 80 }}, {easing: 'easingCubicOut', duration: 1500, repeat:1, yoyo: true}),
fe3Tween = KUTE.to(fe3, {filter :{ url: '#mySVGFilter', saturate: 150, brightness: 60 }}, {easing: 'easingCubicOut', duration: 1500, repeat:1, yoyo: true}),
fe4Tween = KUTE.to(fe4, {filter :{ url: '#mySVGFilter', opacity: 40, hueRotate: 45, dropShadow:[-10,-10,5,{r:0,g:0,b:0,a:1}] }}, {easing: 'easingCubicOut', duration: 1500, repeat:1, yoyo: true});
filterBtn.addEventListener('click', function(){
!fe1Tween.playing && fe1Tween.start();
!fe2Tween.playing && fe2Tween.start();
!fe3Tween.playing && fe3Tween.start();
!fe4Tween.playing && fe4Tween.start();
}, false);

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

@ -0,0 +1,14 @@
var SpicrMainDemo = document.getElementById('SpicrDemo');
function initMainSpicr(){
new Spicr(SpicrMainDemo);
}
function loadCarouselMedia(){
new dll(SpicrMainDemo,initMainSpicr)
}
document.addEventListener('DOMContentLoaded', function loadWrapper(){
loadCarouselMedia();
document.removeEventListener('DOMContentLoaded', loadWrapper, false)
}, false);

View file

@ -0,0 +1,49 @@
// radius attribute
// var radiusTween = KUTE.to('#circle', {attr: {r: '75px'} }, {repeat:1, yoyo: true, easing: 'easingCubicOut'});
var radiusTween = KUTE.to('#circle', {attr: {r: '75%'} }, {repeat:1, yoyo: true, easing: 'easingCubicOut'});
// coordinates of the circle center
var coordinatesTween1 = KUTE.to('#circle', {attr: {cx:40,cy:40,fillOpacity:0.3}}, { duration: 300, easing: 'easingCubicOut'});
var coordinatesTween2 = KUTE.to('#circle', {attr: {cx:110,cy:40}}, { duration: 400, easing: 'linear'});
var coordinatesTween3 = KUTE.to('#circle', {attr: {cx:75,cy:75,fillOpacity:1}}, { easing: 'easingCubicOut'});
try{
coordinatesTween1.chain(coordinatesTween2);
coordinatesTween2.chain(coordinatesTween3);
coordinatesTween3.chain(radiusTween);
}catch(e){
console.error(e+". TweenBase doesn\'t support chain method")
}
var circleBtn = document.getElementById('circleBtn');
circleBtn.addEventListener('click', function(){
!coordinatesTween1.playing && !coordinatesTween2.playing && !coordinatesTween3.playing && !radiusTween.playing && coordinatesTween1.start();
});
// coordinates of gradient
var gradBtn = document.getElementById('gradBtn');
var closingGradient = KUTE.to('#gradient',{attr: {x1:'49%', x2:'49%', y1:'49%', y2:'51%'}}, {easing: 'easingCubicInOut'});
var rotatingGradient1 = KUTE.to('#gradient',{attr: {x1:'49%', x2:'51%', y1:'51%', y2:'51%'}}, {easing: 'easingCubicInOut'});
var rotatingGradient2 = KUTE.to('#gradient',{attr: {x1:'0%', x2:'51%', y1:'100%', y2:'0%'}}, {easing: 'easingCubicInOut'});
var openingGradient = KUTE.to('#gradient',{attr: {x1:'0%', x2:'0%', y1:'0%', y2:'100%'}}, {duration: 1500, easing: 'easingCubicInOut'});
try{
closingGradient.chain(rotatingGradient1);
rotatingGradient1.chain(rotatingGradient2);
rotatingGradient2.chain(openingGradient);
}catch(e){
console.error(e+". TweenBase doesn\'t support chain method")
}
gradBtn.addEventListener('click', function(){
!closingGradient.playing && !rotatingGradient1.playing && !rotatingGradient2.playing && !openingGradient.playing && closingGradient.start();
});
// fill color
var fillBtn = document.getElementById('fillBtn');
var fillAttribute = KUTE.to('#fill',{attr: {fill: 'red'}}, {duration: 1500, repeat: 1, yoyo: true });
fillBtn.addEventListener('click', function(){
!fillAttribute.playing && fillAttribute.start();
});

View file

@ -0,0 +1,23 @@
/* OPACITY EXAMPLE */
var opacityProperty = document.getElementById('opacityProperty'),
button = opacityProperty.getElementsByClassName('btn')[0],
heart = opacityProperty.getElementsByClassName('example-box')[0],
// fade out
fadeOutTween = KUTE.to(heart,{opacity:0},{duration:2000}),
// fade in
fadeInTween = KUTE.to(heart,{opacity:1},{duration:2000}),
isHidden = true;
button.addEventListener('click', function(e){
e.preventDefault();
if ( !isHidden && !fadeOutTween.playing && !fadeInTween.playing ) {
fadeOutTween.start();
isHidden = !isHidden;
} else if ( isHidden && !fadeOutTween.playing && !fadeInTween.playing ) {
fadeInTween.start();
isHidden = !isHidden;
}
},false);
/* OPACITY EXAMPLE */

111
assets/js/perf-matrix.js Normal file
View file

@ -0,0 +1,111 @@
// testing grounds
"use strict";
var mobileType = '',
isMobile = {
Windows: function() {
var checkW = /IEMobile|Windows Mobile/i.test(navigator.userAgent);
mobileType += checkW ? 'Windows Phones.' : '';
return checkW;
},
Android: function() {
var checkA = /Android/i.test(navigator.userAgent);
mobileType += checkA ? 'Android Phones.' : '';
return checkA;
},
BlackBerry: function() {
var checkB = /BlackBerry/i.test(navigator.userAgent);
mobileType += checkB ? 'BlackBerry.' : '';
return checkB;
},
iOS: function() {
var checkI = /iPhone|iPad|iPod/i.test(navigator.userAgent);
mobileType += checkI ? 'Apple iPhone, iPad or iPod.' : '';
return checkI;
},
any: function() {
return ( isMobile.Windows() || isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() );
}
},
checkMOBS = isMobile.any();
// protect phones, older / low end devices
if (document.body.offsetWidth < 1200 || checkMOBS) {
var explain = '';
explain += checkMOBS && mobileType !== '' ? ('For safety reasons, this page does not work with ' + mobileType) : '';
explain += !checkMOBS && document.body.offsetWidth < 1200 && mobileType === '' ? 'For safety reasons this page does not work on your machine because it might be very old. In other cases the browser window size is not enough for the animation to work properly, so if that\'s the case, maximize the window, refresh and proceed with the tests.' : '';
var warning = '<div style="padding: 20px;">';
warning +='<h1 class="text-danger">Warning!</h1>';
warning +='<p class="lead text-danger">This web page is only for high-end desktop computers.</p>';
warning +='<p class="text-danger">We do not take any responsibility and we are not liable for any damage caused through use of this website, be it indirect, special, incidental or consequential damages to your devices.</p>';
warning +='<p class="text-info">'+explain+'</p>';
warning +='</div>';
document.body.innerHTML = warning;
throw new Error('This page is only for high-end desktop computers. ' + explain);
}
// the variables
var infoContainer = document.getElementById('info');
var container = document.getElementById('container');
var tws = [];
for (var i=0; i<21; i++){
container.innerHTML +=
'<div class="cube">'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'<div class="cube__side"></div>'
+'</div>'
}
var collection = document.getElementsByClassName('cube');
var lastIdx = collection.length-1;
function complete(){
infoContainer.style.display = 'block';
container.style.display = 'none';
}
var engine = document.getElementById('kute'),
fromCSS = { rotate3d: [ 0, 0,0 ], perspective:600 },
fromMX = { transform: { rotate3d: [ 0, 0,0 ], perspective:600 }},
toCSS = { rotate3d: [ 360,0,0 ], perspective:600 },
toMX = { transform: { rotate3d: [ 0,360,0 ], perspective:600 }},
ops = { duration: 2000, repeat: 5 }
// since our engines don't do sync, we make it our own here
if (!engine.src.includes('extra')) {
[].slice.call(collection).map((el,i) => { i===lastIdx && (ops.onComplete = complete); tws.push ( KUTE.fromTo(el,fromCSS,toCSS,ops) ) })
}
if (engine.src.includes('extra')) {
[].slice.call(collection).map((el,i) => { i===lastIdx && (ops.onComplete = complete); tws.push ( KUTE.fromTo(el,fromMX,toMX,ops) ) })
}
function startTest(){
infoContainer.style.display = 'none';
container.style.display = 'block'
tws.length && !tws[0].playing && startKUTE();
}
function startKUTE() {
var now = window.performance.now(), count = tws.length;
tws.forEach((t) => t.start(now));
}
// the start button handle
document.getElementById('start').addEventListener('click', startTest, false);

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

@ -0,0 +1,213 @@
// testing grounds
"use strict";
var mobileType = '',
isMobile = {
Windows: function() {
var checkW = /IEMobile|Windows Mobile/i.test(navigator.userAgent);
mobileType += checkW ? 'Windows Phones.' : '';
return checkW;
},
Android: function() {
var checkA = /Android/i.test(navigator.userAgent);
mobileType += checkA ? 'Android Phones.' : '';
return checkA;
},
BlackBerry: function() {
var checkB = /BlackBerry/i.test(navigator.userAgent);
mobileType += checkB ? 'BlackBerry.' : '';
return checkB;
},
iOS: function() {
var checkI = /iPhone|iPad|iPod/i.test(navigator.userAgent);
mobileType += checkI ? 'Apple iPhone, iPad or iPod.' : '';
return checkI;
},
any: function() {
return ( isMobile.Windows() || isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() );
}
},
checkMOBS = isMobile.any();
// protect phones, older / low end devices
if (document.body.offsetWidth < 1200 || checkMOBS) {
var explain = '';
explain += checkMOBS && mobileType !== '' ? ('For safety reasons, this page does not work with ' + mobileType) : '';
explain += !checkMOBS && document.body.offsetWidth < 1200 && mobileType === '' ? 'For safety reasons this page does not work on your machine because it might be very old. In other cases the browser window size is not enough for the animation to work properly, so if that\'s the case, maximize the window, refresh and proceed with the tests.' : '';
var warning = '<div style="padding: 20px;">';
warning +='<h1 class="text-danger">Warning!</h1>';
warning +='<p class="lead text-danger">This web page is only for high-end desktop computers.</p>';
warning +='<p class="text-danger">We do not take any responsibility and we are not liable for any damage caused through use of this website, be it indirect, special, incidental or consequential damages to your devices.</p>';
warning +='<p class="text-info">'+explain+'</p>';
warning +='</div>';
document.body.innerHTML = warning;
throw new Error('This page is only for high-end desktop computers. ' + explain);
}
// generate a random number within a given range
function random(min, max) {
return Math.random() * (max - min) + min;
}
// the variables
var container = document.getElementById('container');
var tws = [];
function complete(){
document.getElementById('info').style.display = 'block';
container.innerHTML = '';
tws = [];
if (engine==='tween') {
stop()
}
}
function updateLeft(obj){
obj.div.style.left = obj.left +'px';
}
function updateTranslate(obj){
obj.div.style.transform = 'translate3d('+ ((obj.x * 10) / 10 >>0) + 'px,0px,0px)';
}
function buildObjects(){
var c = document.querySelector('[data-count]'), e = document.querySelector('[data-engine]'), r = document.querySelector('[data-repeat]'),
p = document.querySelector('[data-property]'), ct = c && document.querySelector('[data-count]').getAttribute('data-count'),
count = ct ? parseInt(ct) : null,
engine = e && document.querySelector('[data-engine]').getAttribute('data-engine') || null,
repeat = r && document.querySelector('[data-repeat]').getAttribute('data-repeat') || null,
property = p && document.querySelector('[data-property]').getAttribute('data-property') || null,
warning = document.createElement('DIV');
warning.className = 'text-warning padding lead';
container.innerHTML = '';
if (count && engine && property && repeat) {
if (engine === 'gsap') {
document.getElementById('info').style.display = 'none';
}
createTest(count,property,engine,repeat);
// since our engines don't do sync, we make it our own here
if (engine==='kute') {
document.getElementById('info').style.display = 'none';
startKUTE();
}
if (engine==='tween') {
document.getElementById('info').style.display = 'none';
startTWEEN();
}
} 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);
}
}
function animate( time ) {
requestAnimationFrame( animate );
TWEEN.update( time );
}
function stop(){
cancelAnimationFrame(animate)
}
function startKUTE() {
var now = window.performance.now(), count = tws.length;
for (var t =0; t<count; t++){
tws[t].start(now+count/16)
}
}
function startTWEEN() {
for (var t in TWEEN._tweens){
TWEEN._tweens[t].start()
}
animate()
}
function createTest(count, property, engine, repeat) {
var update;
for (var i = 0; i < count; i++) {
var 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';
fromValues = engine==="tween" ? { left: left, div: div } : { left: left };
toValues = { left: toLeft }
} else {
if (engine==="kute"){
// fromValues = { translateX: left }
// toValues = { translateX: toLeft }
fromValues = { transform: {translate3d: [left,0,0] }}
toValues = { transform: {translate3d: [toLeft,0,0] }}
// fromValues = { transform: {translateX: left }}
// toValues = { transform: {translateX: toLeft }}
} else if ( engine==="gsap" ) {
fromValues = engine==='gsap' ? { x: left } : { x: left, div : div }
toValues = { x: toLeft }
} else if (engine==="tween") {
fromValues = { x: left, div : div }
toValues = { x: toLeft }
}
}
container.appendChild(div);
// perf test
if (engine==='kute') {
tws.push(KUTE.fromTo(div, fromValues, toValues, { easing: KUTE.Easing.easingQuadraticInOut, repeat: repeat, yoyo: true, duration: 1000, onComplete: fn }));
} else if (engine==='gsap') {
if (property==="left"){
TweenMax.fromTo(div, 1, fromValues, {left : toValues.left, repeat : repeat, yoyo : true, ease : Quad.easeInOut, onComplete: fn });
} else {
TweenMax.fromTo(div, 1, fromValues, { x:toValues.x, repeat : repeat, yoyo : true, ease : Quad.easeInOut, onComplete: fn });
}
} else if (engine==='tween') {
if (property==="left"){
update = updateLeft;
} else if (property==="translateX"){
update = updateTranslate;
}
TWEEN.add(new TWEEN.Tween(fromValues).to(toValues,1000).easing( TWEEN.Easing.Quadratic.InOut ).onComplete( complete ).onUpdate( update).repeat(repeat).yoyo(true));
}
}
}
// the start button handle
document.getElementById('start').addEventListener('click', buildObjects, false);
//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() {
"use strict";
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);
}
}
}

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;

16
assets/js/progress.js Normal file
View file

@ -0,0 +1,16 @@
// invalidate for unsupported browsers
var isIE = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) !== null ? parseFloat( RegExp.$1 ) : false;
if (isIE&&isIE<9) { (function(){return; }()) } // return if SVG API is not supported
// the range slider
var rangeSlider = document.querySelector('input[type="range"');
// basic morph, only fromTo and allFromTo should work
var morphTween = KUTE.fromTo('#rectangle', { path: '#rectangle' }, { path: '#star' }, { duration: 2500, /*repeat: Infinity, yoyo: true,*/ } );
var progressBar = new KUTE.ProgressBar(rangeSlider,morphTween)
document.getElementById('rectangle').addEventListener('click',function(){
!morphTween.playing && morphTween.start()
})

View file

@ -0,0 +1,82 @@
// Component Util
// returns browser prefix
function getPrefix() {
const prefixes = ['Moz', 'moz', 'Webkit', 'webkit', 'O', 'o', 'Ms', 'ms'];
let thePrefix;
for (let i = 0, pfl = prefixes.length; i < pfl; i++) {
if (`${prefixes[i]}Transform` in document.body.style) { thePrefix = prefixes[i]; break; }
}
return thePrefix;
}
// returns prefixed property | property
function trueProperty(property) {
const prefixRequired = (!(property in document.body.style)) ? true : false; // is prefix required for property | prefix
const prefix = getPrefix();
return prefixRequired ? prefix + (property.charAt(0).toUpperCase() + property.slice(1)) : property;
}
// some old browsers like to use preffixed properties
var transformProperty = trueProperty('transform');
// value 0 means that browser doesn't support any transform
// value 1 means that browser supports at least 2D transforms
var browserVersion = transformProperty in document.body.style ? 1 : 0
// Component usual imports
var numbers = KUTE.Interpolate.numbers;
var getInlineStyle = KUTE.Process.getInlineStyle;
var scope = window._KUTE;
// Component Functions
function getMove(tweenProp,value){
var currentTransform = getInlineStyle(this.element);
var left = this.element.style.left;
var top = this.element.style.top;
var x = browserVersion && currentTransform.translate ? currentTransform.translate[0]
: isFinite(left*1) ? left
: defaultValues.move[0];
var y = browserVersion && currentTransform.translate ? currentTransform.translate[1]
: isFinite(top*1) ? top
: defaultValues.move[1];
return [x,y]
}
function prepareMove(tweenProp,value){
var x = isFinite(value*1) ? parseInt(value) : parseInt(value[0]) || 0;
var y = parseInt(value[1]) || 0;
return [ x, y ]
}
function onStartMove(tweenProp,value){
if (!scope[tweenProp] && this.valuesEnd[tweenProp]) {
if (browserVersion){
scope[tweenProp] = function (elem, a, b, v) {
elem.style[transformProperty] = 'translate('+numbers(a[0],b[0],v)+'px,'+numbers(a[1],b[1],v)+'px)';
};
} else {
scope[tweenProp] = function (elem, a, b, v) {
if (a[0]||b[0]) {
elem.style.left = numbers(a[0],b[0],v)+'px';
}
if (a[1]||b[1]) {
elem.style.top = numbers(a[1],b[1],v)+'px';
}
};
}
}
}
// the component object
var crossBrowserMoveOptions = {
component: 'crossBrowserMove',
property: 'move',
defaultValue: [0,0],
Interpolate: numbers,
functions: {
prepareStart: getMove,
prepareProperty: prepareMove,
onStart: onStartMove
}
};
KUTE.Components.crossBrowserMove = new KUTE.Animation(crossBrowserMoveOptions)

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

@ -0,0 +1,31 @@
// common demo JS
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// toggles utility
var toggles = document.querySelectorAll('[data-function="toggle"]');
function closeToggles(el){
el.classList.remove('open');
}
function classToggles(el){
el.classList.toggle('open');
}
document.addEventListener('click', function(e){
if (e && !e.target.classList) {return;}
var target = e.target.parentNode.tagName === 'LI' || e.target.parentNode.classList && e.target.parentNode.classList.contains('btn-group') ? e.target : e.target.parentNode,
parent = target.parentNode;
for (var i = 0, l = toggles.length; i<l; i++ ){
if ( (parent && parent.tagName === 'LI' || parent && parent.classList && parent.classList.contains('btn-group')) && toggles[i] === target ) {
classToggles(parent);
} else {
closeToggles(toggles[i].parentNode);
}
}
target instanceof Element && target.getAttribute('data-function') && /^#$/.test(target.getAttribute('href')) && e.preventDefault();
}, false);

View file

@ -0,0 +1,23 @@
/* SCROLL EXAMPLE */
var scrollProperty = document.getElementById('scrollProperty'),
button = scrollProperty.getElementsByClassName('btn')[0],
target = scrollProperty.getElementsByClassName('example-item')[0]
button.addEventListener('click', function(e){
e.preventDefault();
var scrollTween = target.scrollTop !==0 ?
KUTE.to(target,{scroll:0},{duration:2000, easing: "easingCircularOut"}) :
KUTE.to(target,{scroll:(target.scrollHeight-target.offsetHeight+10)},{duration:2000, easing: "easingCircularOut"})
!scrollTween.playing && scrollTween.start()
},false);
/* SCROLL EXAMPLE */
// scroll top?
var toTop = document.getElementById('toTop'),
toTopTween = KUTE.to( window, { scroll: 0 }, {easing: 'easingQuarticOut', duration : 1500 } );
function topHandler(e){
e.preventDefault();
toTopTween.start();
}
toTop.addEventListener('click',topHandler,false);

View file

@ -0,0 +1,53 @@
/* BOX SHADOW EXAMPLE */
var boxShadow = document.getElementById('boxShadow'),
boxBtn = boxShadow.querySelector('.btn'),
boxElement = boxShadow.getElementsByTagName('div')[0];
// tween to a string value
var myBSTween1 = KUTE.to(boxElement, {boxShadow: '0px 0px 10px 10px #CDDC39'}, {duration:1000, easing: 'easingCubicInOut'});
// or a fromTo with string and array, hex and rgb
var myBSTween2 = KUTE.fromTo(boxElement, {boxShadow: [0, 0, 10, 10, '#CDDC39']}, {boxShadow: '10px 10px 10px 10px rgb(0,66,99)'}, { duration:1000, easing: 'easingCubicInOut'});
var myBSTween3 = KUTE.to(boxElement, {boxShadow: '10px 10px 10px 10px rgb(0,66,99)'}, {duration:1000, easing: 'easingCubicInOut'});
var myBSTween4 = KUTE.to(boxElement, {boxShadow: '-10px -10px 10px 10px #E91E63'}, {duration:1000, easing: 'easingCubicInOut'});
var myBSTween5 = KUTE.to(boxElement, {boxShadow: '0px 0px 0px 0px rgb(0,0,0)'}, {duration:1000, easing: 'easingCubicIn'});
var myBSTween6 = KUTE.to(boxElement, {boxShadow: [10, 10, 10, '#99A52A', 'inset']}, {duration:2000, easing: 'easingCubicOut', repeat: 1, yoyo: true, onComplete: removeInset});
myBSTween1.chain(myBSTween2);
myBSTween2.chain(myBSTween3);
myBSTween3.chain(myBSTween4);
myBSTween4.chain(myBSTween5);
myBSTween5.chain(myBSTween6);
function removeInset() {
boxElement.style.boxShadow = '0px 0px 0px 0px rgb(0,0,0)';
}
boxBtn.addEventListener('click', function(){
!myBSTween1.playing && !myBSTween2.playing && !myBSTween3.playing &&
!myBSTween4.playing && !myBSTween5.playing && !myBSTween6.playing && myBSTween1.start();
}, false);
/* BOX SHADOW EXAMPLE */
/* TEXT SHADOW EXAMPLE */
var textShadow = document.getElementById('textShadow'),
textBtn = textShadow.querySelector('.btn'),
textElement = textShadow.getElementsByTagName('div')[0];
// tween to a string value
var myTSTween1 = KUTE.to(textElement, {textShadow: '0px 0px 5px #000'}, {duration:1000, easing: 'easingCubicInOut'});
// or a fromTo with string and array, hex and rgb
var myTSTween2 = KUTE.fromTo(textElement, {textShadow: [0, 0, 5, '#000']}, {textShadow: '10px 10px 10px rgb(0,66,99)'}, { duration:1000, easing: 'easingCubicInOut'});
var myTSTween3 = KUTE.to(textElement, {textShadow: '10px 10px 10px rgb(0,66,99)'}, {duration:1000, easing: 'easingCubicInOut'});
var myTSTween4 = KUTE.to(textElement, {textShadow: '-10px -10px 10px #E91E63'}, {duration:1000, easing: 'easingCubicInOut'});
var myTSTween5 = KUTE.to(textElement, {textShadow: '0px 0px 0px rgb(0,0,0)'}, {duration:2000, easing: 'easingCubicIn'});
myTSTween1.chain(myTSTween2);
myTSTween2.chain(myTSTween3);
myTSTween3.chain(myTSTween4);
myTSTween4.chain(myTSTween5);
textBtn.addEventListener('click', function(){
!myTSTween1.playing && !myTSTween2.playing && !myTSTween3.playing &&
!myTSTween4.playing && !myTSTween5.playing && myTSTween1.start();
}, false);
/* TEXT SHADOW EXAMPLE */

View file

@ -0,0 +1,70 @@
// general tween options
var morphOps = {
duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'
}
// basic morph
var morphTween = KUTE.to('#rectangle', { path: '#star' }, morphOps);
var morphTween2 = KUTE.to('#rectangle2', { path: '#star2' }, morphOps);
var morphBtn = document.getElementById('morphBtn');
morphBtn.addEventListener('click', function(){
!morphTween.playing && morphTween.start();
!morphTween2.playing && morphTween2.start();
}, false);
// line to circle
var lineMorph = KUTE.to('#line' ,{path:'#circle' }, morphOps);
var lineMorph1 = KUTE.to('#line1',{path:'#circle1'}, morphOps);
var morphBtnClosed = document.getElementById('morphBtnClosed')
morphBtnClosed.addEventListener('click', function(){
!lineMorph.playing && lineMorph.start();
!lineMorph1.playing && lineMorph1.start();
}, false);
var morphOps1 = {
duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'
}
// multishape morph
var multiMorphBtn = document.getElementById('multiMorphBtn');
var multiMorph1 = KUTE.fromTo('#w11', { path: '#w11', attr:{ fill: "rgb(233,27,31)" } }, { path: '#w21', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph2 = KUTE.fromTo('#w12', { path: '#w12', attr:{ fill: "rgb(255,87,34)" } }, { path: '#w22', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph3 = KUTE.fromTo('#w13', { path: '#w13', attr:{ fill: "rgb(76,175,80)" } }, { path: '#w23', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph4 = KUTE.fromTo('#w14', { path: '#w14', attr:{ fill: "rgb(33,150,243)" } }, { path: '#w24', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph11 = KUTE.fromTo('#w111', { path: '#w111', attr:{ fill: "rgb(233,27,31)" } }, { path: '#w211', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph21 = KUTE.fromTo('#w121', { path: '#w121', attr:{ fill: "rgb(255,87,34)" } }, { path: '#w221', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph31 = KUTE.fromTo('#w131', { path: '#w131', attr:{ fill: "rgb(76,175,80)" } }, { path: '#w231', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph41 = KUTE.fromTo('#w141', { path: '#w141', attr:{ fill: "rgb(33,150,243)" } }, { path: '#w241', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph1s = KUTE.fromTo('#s11', { path: '#s11', attr:{ fill: "rgb(233,27,31)" } }, { path: '#s23', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph2s = KUTE.fromTo('#s12', { path: '#s12', attr:{ fill: "rgb(255,87,34)" } }, { path: '#s21', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph3s = KUTE.fromTo('#s13', { path: '#s13', attr:{ fill: "rgb(76,175,80)" } }, { path: '#s24', attr:{ fill: "#56C5FF" } }, morphOps1);
var multiMorph4s = KUTE.fromTo('#s14', { path: '#s14', attr:{ fill: "rgb(33,150,243)" } }, { path: '#s22', attr:{ fill: "#56C5FF" } }, morphOps1);
multiMorphBtn.addEventListener('click', function(){
!multiMorph1.playing && multiMorph1.start() && multiMorph11.start() && multiMorph1s.start();
!multiMorph2.playing && multiMorph2.start() && multiMorph21.start() && multiMorph2s.start();
!multiMorph3.playing && multiMorph3.start() && multiMorph31.start() && multiMorph3s.start();
!multiMorph4.playing && multiMorph4.start() && multiMorph41.start() && multiMorph4s.start();
}, false);
// complex multi morph
var compliMorphBtn = document.getElementById('compliMorphBtn');
var compliMorph1 = KUTE.fromTo('#rectangle-container', {path: '#rectangle-container', attr:{ fill: "#2196F3"} }, { path: '#circle-container', attr:{ fill: "#FF5722"} }, morphOps1);
var compliMorph2 = KUTE.fromTo('#symbol-left', {path: '#symbol-left'}, { path: '#eye-left' }, morphOps1);
var compliMorph3 = KUTE.fromTo('#symbol-left-clone', {path: '#symbol-left-clone'}, { path: '#mouth' }, morphOps1);
var compliMorph4 = KUTE.fromTo('#symbol-right', {path: '#symbol-right'}, { path: '#eye-right' }, morphOps1);
var compliMorph12 = KUTE.fromTo('#rectangle-container2', {path: '#rectangle-container2', attr:{ fill: "#e91b1f"} }, { path: '#circle-container2', attr:{ fill: "#FF5722"} }, morphOps1);
var compliMorph22 = KUTE.fromTo('#symbol-left2', {path: '#symbol-left2'}, { path: '#eye-left2' }, morphOps1);
var compliMorph32 = KUTE.fromTo('#sample-shape2', {path: '#sample-shape2'}, { path: '#mouth2' }, morphOps1);
var compliMorph42 = KUTE.fromTo('#symbol-right2', {path: '#symbol-right2'}, { path: '#eye-right2' }, morphOps1);
compliMorphBtn.addEventListener('click', function(){
!compliMorph1.playing && compliMorph1.start() && compliMorph12.start();
!compliMorph2.playing && compliMorph2.start() && compliMorph22.start();
!compliMorph3.playing && compliMorph3.start() && compliMorph32.start();
!compliMorph4.playing && compliMorph4.start() && compliMorph42.start();
}, false);

29
assets/js/svgDraw.js Normal file
View file

@ -0,0 +1,29 @@
// draw example
var drawBtn = document.getElementById('drawBtn');
var drawExample = document.getElementById('draw-example');
var drawEls = drawExample.querySelectorAll('*');
var draw1 = KUTE.allFromTo(drawEls,{draw:'0% 0%'}, {draw:'0% 10%'}, {duration: 1500, easing: "easingCubicIn", offset: 250});
var draw2 = KUTE.allFromTo(drawEls,{draw:'0% 10%'}, {draw:'90% 105%'}, {duration: 2500, easing: "easingCubicOut", offset: 250});
var draw3 = KUTE.allFromTo(drawEls,{draw:'90% 105%'}, {draw:'100% 105%'}, {duration: 1500, easing: "easingCubicIn", offset: 250});
var draw4 = KUTE.allFromTo(drawEls,{draw:'0% 0%'}, {draw:'0% 103%'}, {duration: 3500, easing: "easingBackOut", offset: 250});
var draw5 = KUTE.allFromTo(drawEls,{draw:'0% 105%'}, {draw:'50% 50%'}, {duration: 2500, easing: "easingExponentialInOut", offset: 250});
try{
draw1.chain(draw2);
draw2.chain(draw3);
draw3.chain(draw4);
draw4.chain(draw5);
}catch(e){
console.error(e+"TweenBase doesn\'t support chain method")
}
drawBtn.addEventListener('click', function(){
!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);

105
assets/js/svgMorph.js Normal file
View file

@ -0,0 +1,105 @@
// basic morph
var morphTween = KUTE.to('#rectangle', {path: '#star'}, {
duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'
});
var morphBtn = document.getElementById('morphBtn');
morphBtn.addEventListener('click', function(){
!morphTween.playing && morphTween.start();
}, false);
// line to circle
var lineMorph = KUTE.to('#line',{path:'#circle'},{ yoyo:true, repeat:1, duration:2000, easing: 'easingCubicOut'}),
lineMorph1 = KUTE.to('#line1',{path:'#circle1'},{ yoyo:true, repeat:1, duration:2000, easing: 'easingCubicOut'}),
morphBtnClosed = document.getElementById('morphBtnClosed');
morphBtnClosed.addEventListener('click', function(){
!lineMorph.playing && lineMorph.start()
!lineMorph1.playing && lineMorph1.start()
}, false);
// polygon morph
var morphTween21 = KUTE.fromTo('#triangle', {attr: { fill: '#673AB7'}, path: '#triangle' }, { attr: { fill: '#2196F3' }, path: '#square' }, {
duration: 1500, easing: 'easingCubicOut'
});
var morphTween22 = KUTE.fromTo('#triangle', {path: '#square', attr:{ fill: '#2196F3'} }, { path: '#star2', attr:{ fill: 'deeppink' } }, {
delay: 500, duration: 1500, easing: 'easingCubicOut'
});
var morphTween23 = KUTE.fromTo('#triangle', {path: '#star2', attr:{ fill: 'deeppink'} }, { path: '#triangle', attr:{ fill: '#673AB7' } }, {
delay: 500, duration: 1500, easing: 'easingCubicOut'
});
var morphTween24 = KUTE.fromTo('#triangle', {path: '#triangle', attr:{ fill: '#673AB7'} }, { path: '#cat', attr:{ fill: 'darkorange' } }, {
delay: 500, duration: 1500, easing: 'easingCubicOut'
});
var morphTween25 = KUTE.fromTo('#triangle', {path: '#cat', attr:{ fill: 'darkorange'} }, { path: '#triangle', attr:{ fill: '#673AB7' } }, {
delay: 500, duration: 1500, easing: 'easingCubicOut'
});
try{
morphTween21.chain(morphTween22);
morphTween22.chain(morphTween23);
morphTween23.chain(morphTween24);
morphTween24.chain(morphTween25);
morphTween25.chain(morphTween21);
}catch(e){
console.error(e+"TweenBase doesn\'t support chain method")
}
var morphBtn2 = document.getElementById('morphBtn2');
morphBtn2.addEventListener('click', function(){
if ( !morphTween21.playing && !morphTween22.playing && !morphTween23.playing && !morphTween24.playing && !morphTween25.playing ) {
morphTween21.start(); morphTween21._dl = 500;
morphBtn2.innerHTML = 'Stop';
morphBtn2.className = 'btn btn-pink';
} else {
morphTween21.playing && morphTween21.stop(); morphTween21._dl = 0;
morphTween22.playing && morphTween22.stop();
morphTween23.playing && morphTween23.stop();
morphTween24.playing && morphTween24.stop();
morphTween25.playing && morphTween25.stop();
morphBtn2.innerHTML = 'Start';
morphBtn2.className = 'btn btn-green';
}
}, false);
// simple multi morph
var multiMorphBtn = document.getElementById('multiMorphBtn');
var multiMorph1 = KUTE.fromTo('#w11', { path: '#w11', attr:{ fill: "rgb(233,27,31)" } }, { path: '#w21', attr:{ fill: "#56C5FF" } }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var multiMorph2 = KUTE.fromTo('#w12', { path: '#w12', attr:{ fill: "rgb(255,87,34)" } }, { path: '#w22', attr:{ fill: "#56C5FF" } }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var multiMorph3 = KUTE.fromTo('#w13', { path: '#w13', attr:{ fill: "rgb(76,175,80)" } }, { path: '#w23', attr:{ fill: "#56C5FF" } }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var multiMorph4 = KUTE.fromTo('#w14', { path: '#w14', attr:{ fill: "rgb(33,150,243)" } }, { path: '#w24', attr:{ fill: "#56C5FF" } }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var multiMorph1s = KUTE.fromTo('#s11', { path: '#s11', attr:{ fill: "rgb(233,27,31)" } }, { path: '#s23', attr:{ fill: "#56C5FF" } }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var multiMorph2s = KUTE.fromTo('#s12', { path: '#s12', attr:{ fill: "rgb(255,87,34)" } }, { path: '#s21', attr:{ fill: "#56C5FF" } }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var multiMorph3s = KUTE.fromTo('#s13', { path: '#s13', attr:{ fill: "rgb(76,175,80)" } }, { path: '#s24', attr:{ fill: "#56C5FF" } }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var multiMorph4s = KUTE.fromTo('#s14', { path: '#s14', attr:{ fill: "rgb(33,150,243)" } }, { path: '#s22', attr:{ fill: "#56C5FF" } }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
multiMorphBtn.addEventListener('click', function(){
!multiMorph1.playing && multiMorph1.start() && multiMorph1s.start();
!multiMorph2.playing && multiMorph2.start() && multiMorph2s.start();
!multiMorph3.playing && multiMorph3.start() && multiMorph3s.start();
!multiMorph4.playing && multiMorph4.start() && multiMorph4s.start();
}, false);
// complex multi morph
var compliMorphBtn = document.getElementById('compliMorphBtn');
var compliMorph1 = KUTE.fromTo('#rectangle-container', {path: '#rectangle-container', attr:{ fill: "#2196F3"} }, { path: '#circle-container', attr:{ fill: "#FF5722"} }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var compliMorph2 = KUTE.fromTo('#symbol-left', {path: '#symbol-left'}, { path: '#eye-left' }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var compliMorph3 = KUTE.fromTo('#symbol-left-clone', {path: '#symbol-left-clone'}, { path: '#mouth' }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var compliMorph4 = KUTE.fromTo('#symbol-right', {path: '#symbol-right'}, { path: '#eye-right' }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var compliMorph11 = KUTE.fromTo('#rectangle-container1', {path: '#rectangle-container1', attr:{ fill: "#9C27B0"} }, { path: '#circle-container', attr:{ fill: "#FF5722"} }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var compliMorph21 = KUTE.fromTo('#symbol-left1', {path: '#symbol-left1'}, { path: '#eye-left1' }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var compliMorph31 = KUTE.fromTo('#sample-shape', {path: '#sample-shape'}, { path: '#mouth1' }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
var compliMorph41 = KUTE.fromTo('#symbol-right1', {path: '#symbol-right1'}, { path: '#eye-right1' }, { duration: 2000, repeat: 1, yoyo: true, easing: 'easingCubicOut'});
compliMorphBtn.addEventListener('click', function(){
!compliMorph1.playing && compliMorph1.start() && compliMorph11.start();
!compliMorph2.playing && compliMorph2.start() && compliMorph21.start();
!compliMorph3.playing && compliMorph3.start() && compliMorph31.start();
!compliMorph4.playing && compliMorph4.start() && compliMorph41.start();
}, false);

155
assets/js/svgTransform.js Normal file
View file

@ -0,0 +1,155 @@
// invalidate for unsupported browsers
var isIE = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) !== null ? parseFloat( RegExp.$1 ) : false;
if (isIE&&isIE<9) { (function(){return; }()) } // return if SVG API is not supported
// 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, { transform: {rotateZ: 360} }, { yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"});
// var svgTween11 = KUTE.to(svgr1, { rotateZ: 360}, { 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, { transform: {rotateZ: 360} }, { 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];
var svgt2 = svgTranslate.getElementsByTagName('path')[1];
var svgTween21 = KUTE.to(svgt1, { transform: {translateX: 580} }, {yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"});
var svgTween22 = KUTE.to(svgt2, { svgTransform: { translate: [0,0] } }, {yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"});
translateBtn.addEventListener('click', function(){
!svgTween21.playing && svgTween21.start();
!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, { transform: {skew: [-15,0]} }, { duration: 1500, easing: "easingCubicInOut"});
var svgTween311 = KUTE.to(svgsk1, { transform: {skew: [-15,15]} }, { duration: 2500, easing: "easingCubicInOut"});
var svgTween313 = KUTE.to(svgsk1, { transform: {skew: [0, 0]} }, { duration: 1500, easing: "easingCubicInOut"});
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"});
try{
svgTween31.chain(svgTween311);
svgTween311.chain(svgTween313);
svgTween32.chain(svgTween322);
svgTween322.chain(svgTween323);
}catch(e){
console.error(e+"TweenBase doesn\'t support chain method")
}
skewBtn.addEventListener('click', function(){
!svgTween31.playing && !svgTween311.playing && !svgTween313.playing && svgTween31.start();
!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];
var svgs2 = svgScale.getElementsByTagName('path')[1];
var svgTween41 = KUTE.to(svgs1, { transform: {scale3d: [1.5,1.5,1] } }, { yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"});
var svgTween42 = KUTE.to(svgs2, { svgTransform: { translate: 580, scale: 0.5,} }, {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 CSS3 transform without svg plugin, works in modern browsers only, EXCEPT IE/Edge
transform: {
translateX: 250,
scale3d: [1.5,1.5,1],
rotateZ: 320,
skewX: -15
}
}, { yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"});
var svgTween52 = KUTE.to(svgm2, {
svgTransform: {
translate: 830,
scale: 1.5,
rotate: 320,
skewX: -15
}
}, { yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"});
mixedBtn.addEventListener('click', function(){
!svgTween51.playing && svgTween51.start();
!svgTween52.playing && svgTween52.start();
}, false);
// chained transforms
var svgChained = document.getElementById('svgChained');
var chainedBtn = document.getElementById('chainedBtn');
var svgc = svgChained.getElementsByTagName('path')[0];
var svgcTransform = svgc.getAttribute('transform');
var resetSVGTransform = function(){
svgc.setAttribute('transform',svgcTransform);
};
var svgTween6 = KUTE.fromTo(svgc,
{ // from
svgTransform: {
translate: 0,
scale: 0.5,
rotate: 45,
// skewX: 0
},
},
{ // to
svgTransform: {
translate: 450,
scale: 1.5,
rotate: 360,
// skewX: -45
}
},
{transformOrigin: [256,256], complete: resetSVGTransform, yoyo: true, repeat: 1, duration: 1500, easing: "easingCubicOut"});
chainedBtn.addEventListener('click', function(){
!svgTween6.playing && svgTween6.start();
}, false);

View file

@ -0,0 +1,27 @@
/* TEXT PROPERTIES EXAMPLE */
var textProperties = document.getElementById('textProperties'),
heading = textProperties.querySelector('h1'),
button = textProperties.querySelectorAll('.btn')[0],
// 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 tps = KUTE.allFromTo(charsObject,
{ fontSize:50, letterSpacing: 0, color: '#333'},
{ fontSize:80, letterSpacing: 10, color: 'red'},
{ offset: 75, duration: 250, repeat: 1, yoyo:true, repeatDelay: 150, easing: 'easingCubicOut'});
button.addEventListener('click', function(e){
e.preventDefault();
if ( !tps.playing() ) {
tps.start();
}
},false);
/* TEXT PROPERTIES EXAMPLE */

61
assets/js/textWrite.js Normal file
View file

@ -0,0 +1,61 @@
// number increment
var numText = document.getElementById('numText'),
numBtn = document.getElementById('numBtn'),
numTween = KUTE.to(numText, {number: 1550}, {duration: 3000, easing: 'easingCubicOut'});
numBtn.addEventListener('click', function(){
if (!numTween.playing) {
if (numText.innerHTML === '1550') { numTween.valuesEnd['number'] = 0; } else { numTween.valuesEnd['number'] = 1550; }
numTween.start();
}
}, false);
// write text
var headText = document.getElementById('headText'),
headBtn = document.getElementById('headBtn'),
initText = headText.innerHTML,
whichTw = false,
nextText = "This is a <strong>super simple</strong> write text demo.",
headTween = KUTE.to(headText, {text: nextText}, {textChars: 'alpha', duration: 5000, easing: 'easingBounceOut'}),
headTween1 = KUTE.to(headText, {text: initText}, {textChars: 'alpha', duration: 5000, easing: 'easingBounceOut'});
headBtn.addEventListener('click', function(){
!whichTw && !headTween.playing && !headTween1.playing && (headTween.start(), whichTw = !whichTw);
whichTw && !headTween.playing && !headTween1.playing && (headTween1.start(), whichTw = !whichTw);
}, false);
// improved write text
var textTweenBTN = document.getElementById('textExampleBtn');
var textTarget = document.getElementById('textExample');
var textOriginal = textTarget.innerHTML;
var anotherText = 'This text has a <a href="index.html">link to homepage</a> inside.';
var options = {duration: 'auto', textChars: 'alphanumeric'}
textTweenBTN.addEventListener('click', function(){
var newContent = textTarget.innerHTML === textOriginal ? anotherText : textOriginal;
!textTarget.playing && KUTE.Util.createTextTweens(textTarget,newContent,options).start()
})
// combo wombo
var comText = document.getElementById('comText'),
comNum = document.getElementById('comNum'),
comBtn = document.getElementById('comBtn'),
comTween11 = KUTE.to(comNum, {number: 2500}, {duration: 2000, easing: 'easingCubicOut'}),
comTween12 = KUTE.to(comText, {text: "People following on Github."}, { textChars: 'symbols', duration: 3000, easing: 'easingCubicInOut'}),
comTween21 = KUTE.to(comNum, {number: 7500}, {delay: 3000, duration: 2000, easing: 'easingCubicInOut'}),
comTween22 = KUTE.to(comText, {text: "More crazy tricks coming soon."}, {textChars: 'all', delay: 2000, duration: 3000, easing: 'easingCubicInOut'});
try{
comTween11.chain(comTween21);
comTween12.chain(comTween22);
}catch(e){
console.error(`${e} TweenBase doesn't support chain method`)
}
comBtn.addEventListener('click', function(){
if (!comTween11.playing && !comTween21.playing && !comTween12.playing && !comTween22.playing) {
comTween11.start();
comTween12.start();
}
}, false);

View file

@ -0,0 +1,136 @@
/* TRANSFORMS EXAMPLES */
var translateExamples = document.getElementById('translate-examples'),
translateBtn = translateExamples.querySelector('.btn'),
tr2d = translateExamples.getElementsByTagName('div')[0],
trx = translateExamples.getElementsByTagName('div')[1],
trry = translateExamples.getElementsByTagName('div')[2],
trz = translateExamples.getElementsByTagName('div')[3],
tr2dTween = KUTE.to(tr2d, {translate:[170,170]}, {easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500}),
trxTween = KUTE.to(trx, {translateX:-170}, {easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500}),
trryTween = KUTE.to(trry, {translate3d:[0,170,0]}, {easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500}),
trzTween = KUTE.to(trz, {perspective:200, translate3d:[0,0,-100]}, {easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500});
translateBtn.addEventListener('click', function(){
!tr2dTween.playing && tr2dTween.start();
!trxTween.playing && trxTween.start();
!trryTween.playing && trryTween.start();
!trzTween.playing && trzTween.start();
}, false);
var rotExamples = document.getElementById('rotExamples'),
rotBtn = rotExamples.querySelector('.btn'),
r2d = rotExamples.querySelectorAll('div')[0],
rx = rotExamples.querySelectorAll('div')[1],
ry = rotExamples.querySelectorAll('div')[2],
rz = rotExamples.querySelectorAll('div')[3],
r2dTween = KUTE.to(r2d, {rotate:-720}, {easing:'easingCircularInOut', yoyo:true, repeat: 1, duration:1500}),
rxTween = KUTE.to(rx, {rotateX:180}, {easing:'linear', yoyo:true, repeat: 1, duration:1500}),
ryTween = KUTE.to(ry, {perspective:200, rotate3d:[0,-180,0],scale:1.2}, {easing:'easingCubicInOut', yoyo:true, repeat: 1, duration:1500}),
rzTween = KUTE.to(rz, {rotateZ:360}, {easing:'easingBackOut', yoyo:true, repeat: 1, duration:1500});
rotBtn.addEventListener('click', function(){
!r2dTween.playing && r2dTween.start();
!rxTween.playing && rxTween.start();
!ryTween.playing && ryTween.start();
!rzTween.playing && rzTween.start();
}, false);
var skewExamples = document.getElementById('skewExamples'),
skewBtn = skewExamples.querySelector('.btn'),
sx = skewExamples.querySelectorAll('div')[0],
sy = skewExamples.querySelectorAll('div')[1],
sxTween = KUTE.to(sx, {skewX:-25}, {easing:'easingCircularInOut', yoyo:true, repeat: 1, duration:1500}),
syTween = KUTE.to(sy, {skew:[0,25]}, {easing:'easingCircularInOut', yoyo:true, repeat: 1, duration:1500});
skewBtn.addEventListener('click', function(){
!sxTween.playing && sxTween.start();
!syTween.playing && syTween.start();
}, false);
var mixTransforms = document.getElementById('mixTransforms'),
mixBtn = mixTransforms.querySelector('.btn'),
mt1 = mixTransforms.querySelectorAll('div')[0],
mt2 = mixTransforms.querySelectorAll('div')[1],
// pp = KUTE.Util.trueProperty('perspective'),
// tfp = KUTE.Util.trueProperty('transform'),
// tfo = KUTE.Util.trueProperty('transformOrigin'),
mt1Tween = KUTE.to(mt1, {perspective:200,translateX:300,rotateX:360,rotateY:15,rotateZ:5}, { easing:'easingCubicInOut', yoyo:true, repeat: 1, duration:1500}),
mt2Tween = KUTE.to(mt2, {translateX:300,rotateX:360,rotateY:15,rotateZ:5}, { easing:'easingCubicInOut', yoyo:true, repeat: 1, duration:1500});
mixBtn.addEventListener('click', function(){
!mt1Tween.playing && mt1Tween.start();
!mt2Tween.playing && mt2Tween.start();
}, false);
/* 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],
el4 = chainedTweens.querySelectorAll('.example-item')[3],
ctb = chainedTweens.querySelector('.btn');
// built the tween objects for element1
var tween11 = KUTE.fromTo(el1, { perspective:400,translateX:0, rotateX: 0}, {perspective:400,translateX:150, rotateX: 25}, {duration: 2000});
var tween12 = KUTE.fromTo(el1, { perspective:400,translateY:0, rotateY: 0}, {perspective:400,translateY:20, rotateY: 15}, {duration: 2000});
var tween13 = KUTE.fromTo(el1, { perspective:400,translate3d:[150,20,0], rotate3d:[25,15,0]}, {perspective:400,translate3d:[0,0,0], rotate3d:[0,0,0]}, {duration: 3000});
// chain tweens
try {
tween11.chain(tween12);
tween12.chain(tween13);
} catch(e) {
console.warn(e+". TweenBase doesn\'t support chain method")
}
// built the tween objects for element2
var tween21 = KUTE.fromTo(el2, { perspective:400,translateX:0, translateY:0, rotateX: 0, rotateY:0 }, {perspective:400,translateX:150, translateY:0, rotateX: 25, rotateY:0}, {duration: 2000});
var tween22 = KUTE.fromTo(el2, { perspective:400,translateX:150, translateY:0, rotateX: 25, rotateY: 0}, {perspective:400,translateX:150, translateY:20, rotateX: 25, rotateY: 15}, {duration: 2000});
var tween23 = KUTE.fromTo(el2, { perspective:400,translate3d:[150,20,0], rotateX: 25, rotateY:15}, {perspective:400,translate3d:[0,0,0], rotateX: 0, rotateY:0}, {duration: 3000});
// chain tweens
try{
tween21.chain(tween22);
tween22.chain(tween23);
}catch(e){
console.warn(e+". TweenBase doesn\'t support chain method")
}
// built the tween objects for element3
var tween31 = KUTE.to(el3,{ perspective:400,translateX:150, rotateX:25}, {duration: 2000});
var tween32 = KUTE.to(el3,{ perspective:400,translateX:150,translateY:20, rotateY:15}, {duration: 2000});
var tween33 = KUTE.to(el3,{ perspective:400,translateX:0, translateY:0, rotateX: 0, rotateY:0}, {duration: 3000});
// chain tweens
try{
tween31.chain(tween32);
tween32.chain(tween33);
}catch(e){
console.warn(e+". TweenBase doesn\'t support chain method")
}
// built the tween objects for element4
var tween41 = KUTE.to(el4,{ perspective:400, translate3d:[150,0,0], rotate3d: [25,0,0]}, {duration: 2000});
var tween42 = KUTE.to(el4,{ perspective:400, translate3d:[150,20,0], rotate3d:[25,15,0]}, {duration: 2000});
var tween43 = KUTE.to(el4,{ perspective:400, translate3d:[0,0,0], rotate3d: [0,0,0]}, {duration: 3000});
// chain tweens
try{
tween41.chain(tween42);
tween42.chain(tween43);
}catch(e){
console.warn(e+". TweenBase doesn\'t support chain method")
}
ctb.addEventListener('click',function(e){
e.preventDefault();
!tween11.playing && !tween12.playing && !tween13.playing && tween11.start();
!tween21.playing && !tween22.playing && !tween23.playing && tween21.start();
!tween31.playing && !tween32.playing && !tween33.playing && tween31.start();
!tween41.playing && !tween42.playing && !tween43.playing && tween41.start();
},false);
/* CHAINED TWEENS EXAMPLE */

View file

@ -0,0 +1,92 @@
/* MATRIX TRANSFORMS EXAMPLES */
/* using parent perspective */
var matrixExamples = document.getElementById('matrix-examples'),
matrixBtn = matrixExamples.querySelector('.btn'),
mx1 = matrixExamples.getElementsByTagName('div')[0],
mx2 = matrixExamples.getElementsByTagName('div')[1],
mx3 = matrixExamples.getElementsByTagName('div')[2],
mx4 = matrixExamples.getElementsByTagName('div')[3],
mx1Tween = KUTE.to(mx1, {transform: { translate3d:[-50,-50,-50]} }, {easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500}),
mx2Tween = KUTE.to(mx2, {transform: { perspective: 100, translate3d:[-50,-50,-50], rotateX:180 } }, {easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500}),
mx3Tween = KUTE.to(mx3, {transform: { translate3d:[-50,-50,-50], skew:[-15,-15] } }, { easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500}), // matrix(1, 45, 45, 1, 0, -170)
mx4Tween = KUTE.to(mx4, {transform: { translate3d:[-50,-50,-50], rotate3d:[0,-360,0], scaleX: 0.5 } }, { easing:'easingCubicOut', yoyo:true, repeat: 1, duration:1500});
matrixBtn.addEventListener('click', function(){
!mx1Tween.playing && mx1Tween.start();
!mx2Tween.playing && mx2Tween.start();
!mx3Tween.playing && mx3Tween.start();
!mx4Tween.playing && mx4Tween.start();
}, false);
/* 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],
el4 = chainedTweens.querySelectorAll('.example-item')[3],
ctb = chainedTweens.querySelector('.btn');
// built the tween objects for element1
var tween11 = KUTE.fromTo(el1, { transform: {perspective:400,translateX:0, rotateX: 0}}, {transform: {perspective:400,translateX:150, rotateX: 25}}, {duration: 2000});
var tween12 = KUTE.fromTo(el1, { transform: {perspective:400,translateY:0, rotateY: 0}}, {transform: {perspective:400,translateY:20, rotateY: 15}}, {duration: 2000});
var tween13 = KUTE.fromTo(el1, { transform: {perspective:400,translate3d:[150,20,0], rotate3d:[25,15,0]}}, {transform: {perspective:400,translate3d:[0,0,0], rotate3d:[0,0,0]}}, {duration: 3000});
// chain tweens
try {
tween11.chain(tween12);
tween12.chain(tween13);
} catch(e) {
console.warn(e+". TweenBase doesn\'t support chain method")
}
// built the tween objects for element2
var tween21 = KUTE.fromTo(el2, { transform: {perspective:400,translateX:0, translateY:0, rotateX: 0, rotateY:0 }}, {transform: {perspective:400,translateX:150, translateY:0, rotateX: 25, rotateY:0}}, {duration: 2000});
var tween22 = KUTE.fromTo(el2, { transform: {perspective:400,translateX:150, translateY:0, rotateX: 25, rotateY: 0}}, {transform: {perspective:400,translateX:150, translateY:20, rotateX: 25, rotateY: 15}}, {duration: 2000});
var tween23 = KUTE.fromTo(el2, { transform: {perspective:400,translate3d:[150,20,0], rotateX: 25, rotateY:15}}, {transform: {perspective:400,translate3d:[0,0,0], rotateX: 0, rotateY:0}}, {duration: 3000});
// chain tweens
try{
tween21.chain(tween22);
tween22.chain(tween23);
}catch(e){
console.warn(e+". TweenBase doesn\'t support chain method")
}
// built the tween objects for element3
var tween31 = KUTE.to(el3,{ transform: {perspective:400,translateX:150, rotateX:25}}, {duration: 2000});
var tween32 = KUTE.to(el3,{ transform: {perspective:400,translateX:150,translateY:20, rotateY:15}}, {duration: 2000});
var tween33 = KUTE.to(el3,{ transform: {perspective:400,translateX:0, translateY:0, rotateX: 0, rotateY:0}}, {duration: 3000});
// chain tweens
try{
tween31.chain(tween32);
tween32.chain(tween33);
}catch(e){
console.warn(e+". TweenBase doesn\'t support chain method")
}
// built the tween objects for element4
var tween41 = KUTE.to(el4,{ transform: {perspective:400, translate3d:[150,0,0], rotate3d: [25,0,0]}}, {duration: 2000});
var tween42 = KUTE.to(el4,{ transform: {perspective:400, translate3d:[150,20,0], rotate3d:[25,15,0]}}, {duration: 2000});
var tween43 = KUTE.to(el4,{ transform: {perspective:400, translate3d:[0,0,0], rotate3d: [0,0,0]}}, {duration: 3000});
// chain tweens
try{
tween41.chain(tween42);
tween42.chain(tween43);
}catch(e){
console.warn(e+". TweenBase doesn\'t support chain method")
}
ctb.addEventListener('click',function(e){
e.preventDefault();
!tween11.playing && !tween12.playing && !tween13.playing && tween11.start();
!tween21.playing && !tween22.playing && !tween23.playing && tween21.start();
!tween31.playing && !tween32.playing && !tween33.playing && tween31.start();
!tween41.playing && !tween42.playing && !tween43.playing && tween41.start();
},false);
/* CHAINED TWEENS EXAMPLE */

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

File diff suppressed because one or more lines are too long

157
backgroundPosition.html Normal file
View file

@ -0,0 +1,157 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Background Position component for KUTE.js allows you to animate the background-position property on most browsers.">
<meta name="keywords" content="backgroundPosition,background-position,background,kute,kute.js,animation,javascript animation,tweening engine,animation engine,JavaScript,Native JavaScript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Background Position</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<style></style>
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li class="active"><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Background Position</h2>
<p class="condensed lead">The component that animates the CSS property controling the <i>background-position</i> property of a target element.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate the position of the background image, simple and effective.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>Background Position</b> component enables animation for the CSS <b>backgroundPosition</b> property on most browsers.</p>
<p>It can handle an entire set of input values <b>[x,y]</b>, <b>'0% 50%'</b> and even <b>'left center'</b>. The component always updates the values of the position
property via <b>%</b> suffix for simplicity reasons and even if <b>px</b> or any other unit is supported.</p>
<p>While we might not have much use for this kind of animation, some older browsers will love to show you something if that is the case.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Example</h3>
<p>Here a couple of possible tween objects:</p>
<pre><code class="language-javascript">// provide the exact values for interpolation
let bgPosTween = KUTE.to('selector1',{backgroundPosition:[0,50]}).start();
// provide the coordinates
let bgPosTween = KUTE.to('selector1',{backgroundPosition:"0% 50%"}).start();
// or provide the position names
let bgPosTween = KUTE.to('selector1',{backgroundPosition:"left center"}).start();
</code></pre>
<div id="bgPos" class="featurettes">
<div class="example-item example-box" style="background: url('https://picsum.photos/400/300') center center no-repeat;"></div>
<div class="example-buttons">
<a class="btn btn-orange" href="#">Start</a>
</div>
</div>
<h3>Notes</h3>
<ul>
<li>Unfortunatelly this property also has no access at the sub-pixel level, animations are as good as it gets, despite the fact that the <code>%</code> suffix is used.</li>
<li>There are thankfully replacements for this forgotten property that strangelly supports CSS3 transitions, you can simply use all kinds of SVG masks and filters
and the <a href="htmlAttributes.html">HTML Attributes</a> component for much more animation potential and supreme animation quality.</li>
<li>This component is bundled with the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/backgroundPosition.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>

172
borderRadius.html Normal file
View file

@ -0,0 +1,172 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The SVG Border Radius component for KUTE.js enables animation for all the radius based CSS3 properties.">
<meta name="keywords" content="border-radius,border radius,kute,kute.js,animation,javascript animation,tweening engine,animation engine,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Border Radius</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li class="active"><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Border Radius</h2>
<p class="condensed lead">The component that animates the CSS properties that control the radius of the corners of a target element.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate the radius for all corners or a specific one for a target element.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>Border Radius</b> component provides support for the CSS3 <b>border-radius</b> property and all corner variations.</p>
<p>The component accepts any measurement unit but the best results in terms of visual presentation are when you use <b>%</b>, <b>em</b> or any other
subpixel units.</p>
<p>Even if you don't provide any unit at all, the component will work it out with <b>px</b>.</p>
<p>For a quick reference, here are the properties supported:</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Border Radius Properties</h3>
<ul>
<li><kbd class="bg-olive">borderRadius</kbd> allows you to animate the <code>border-radius</code> on all corners for a given element.</li>
<li><kbd class="bg-olive">borderTopLeftRadius</kbd> allows you to animate the <code>border-top-left-radius</code> for a given element.</li>
<li><kbd class="bg-olive">borderTopRightRadius</kbd> allows you to animate the <code>border-top-right-radius</code> for a given element.</li>
<li><kbd class="bg-olive">borderBottomLeftRadius</kbd> allows you to animate the <code>border-bottom-left-radius</code>for a given element.</li>
<li><kbd class="bg-olive">borderBottomRightRadius</kbd> allows you to animate the <code>border-bottom-right-radius</code>for a given element.</li>
</ul>
<h3>Examples</h3>
<p>OK let's have a look at some sample tween objects and a quick demo:</p>
<pre><code class="language-javascript">KUTE.to('selector1',{borderRadius:'100%'}).start();
KUTE.to('selector2',{borderTopLeftRadius:'100%'}).start();
KUTE.to('selector3',{borderTopRightRadius:'5em'}).start();
KUTE.to('selector4',{borderBottomLeftRadius:50}).start();
KUTE.to('selector5',{borderBottomRightRadius:'20px'}).start();
</code></pre>
<div class="featurettes">
<div id="allRadius" class="example-item example-box bg-red">ALL</div>
<div id="tlRadius" class="example-item example-box bg-pink">TL</div>
<div id="trRadius" class="example-item example-box bg-olive">TR</div>
<div id="blRadius" class="example-item example-box bg-indigo">BL</div>
<div id="brRadius" class="example-item example-box bg-blue">BR</div>
<div class="example-buttons">
<a id="radiusBtn" class="btn btn-green" href="javascript:void(0)">Start</a>
</div>
</div>
<h3>Notes</h3>
<ul>
<li>A quick reminder here is that the component does not support radius shorthand values, EG <code>border-radius: 50px 20px</code>.</li>
<li>The component does not use vendor property preffixes anymore, the major browsers don't need for quite some time now. If you want to support
legacy browsers, you still have the utilities available.</li>
<li>Early implementations from any browser that have been deprecated are also not supported.</li>
<li>This component is bundled with <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/borderRadius.js"></script>
</body>
</html>

179
boxModel.html Normal file
View file

@ -0,0 +1,179 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Box Model component for KUTE.js enables animation for all box model properties.">
<meta name="keywords" content="top,left,width,height,kute,kute.js,animation,javascript animation,tweening engine,animation engine,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Box Model</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li class="active"><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Box Model</h2>
<p class="condensed lead">The component that animates most of the CSS box model properties of a target element on all browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate the <b>width</b>, <b>height</b>, <b>borderWidth</b> or spacing for a target element on all browsers.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>Box Model</b> component provides support for all box-model properties and all their variations.</p>
<p>Unlike other components, this one only works with <b>px</b> measurement unit, simply because these properties have no control at subpixel level. This means that even if you use <b>%</b>
as suffix, the computed values are still pixel based in all browsers.</p>
<p>Because modern browsers shine with <b>transform</b> animations and box model properties generally come with performance penalties and other animation
jank, they can be used as fallback for legacy browsers, for your very special clients of course.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Box Model Properties</h3>
<ul>
<li><kbd class="bg-blue">left</kbd>, <kbd class="bg-blue">top</kbd>, <kbd class="bg-olive">right</kbd> and <kbd class="bg-olive">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 class="bg-blue">width</kbd>, <kbd class="bg-blue">height</kbd>, <kbd class="bg-olive">minWidth</kbd>, <kbd class="bg-olive">minHeight</kbd>, <kbd class="bg-olive">maxWidth</kbd>,
<kbd class="bg-olive">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 class="bg-olive">padding</kbd>, <kbd class="bg-olive">margin</kbd>, <kbd class="bg-olive">paddingTop</kbd>, <kbd class="bg-olive">paddingBottom</kbd>, <kbd class="bg-olive">paddingLeft</kbd>,
<kbd class="bg-olive">paddingRight</kbd>, <kbd class="bg-olive">marginTop</kbd>, <kbd class="bg-olive">marginBottom</kbd>, <kbd class="bg-olive">marginLeft</kbd> and
<kbd class="bg-olive">marginRight</kbd> are properties that allow you to animate the spacing of an element inside (via padding) and outside (via margin).</li>
<li><kbd class="bg-olive">borderWidth</kbd>, <kbd class="bg-olive">borderTopWidth</kbd>, <kbd class="bg-olive">borderRightWidth</kbd>, <kbd class="bg-olive">borderBottomWidth</kbd> are
<kbd class="bg-olive">borderLeftWidth</kbd> are properties that allow you to animate the border of an element either on all sides at once or each side separatelly.</li>
<li><kbd class="bg-olive">outlineWidth</kbd> property allows you to animate the <code>outline-width</code> of an element.</li>
</ul>
<p>The properties marked with different color, namely <kbd class="bg-blue">left</kbd>, <kbd class="bg-blue">top</kbd>, <kbd class="bg-blue">width</kbd> and <kbd class="bg-blue">height</kbd> are part of a lighter
version of the component called <i>baseBoxModel.js</i>, since they're the most used and probably most needed in just about every KUTE.js distribution.</p>
<h3>Examples</h3>
<p>OK let's have a look at some sample tween objects and a quick demo:</p>
<pre><code class="language-javascript">let tween1 = KUTE.to('selector1',{width:200})
let tween2 = KUTE.to('selector1',{height:300})
let tween3 = KUTE.to('selector1',{left:250})
let tween4 = KUTE.to('selector1',{top:100})
let tween5 = KUTE.to('selector1',{marginTop:200})
let tween6 = KUTE.to('selector1',{marginBottom:50})
let tween7 = KUTE.to('selector1',{padding:30})
let tween8 = KUTE.to('selector1',{margin:'5px'})
</code></pre>
<p>We're gonna chain these tweens and start the animation.</p>
<div id="boxModel" class="featurettes">
<div class="example-box example-box-model bg-lime" style="padding: 0; font-size:26px; line-height: 70px;">BOX<br>&nbsp;MODEL&nbsp;</div>
<div class="example-buttons">
<a class="btn btn-orange" href="#">Start</a>
</div>
</div>
<h3>Notes</h3>
<ul>
<li>Shorthand notations such as <code>margin: "20px 50px"</code> or any other property are not supported.</li>
<li>Most box-model properties (except <code>top</code>, <code>left</code>, <code>bottom</code> and <code>right</code>) are layout modifiers and will not
produce the best visual experience mainly because they force re-paint on all page layout and they don't support animation under the pixel level.</li>
<li>The <i>baseBoxModel</i> component is featured in all distributions, while the full component is bundled with <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/boxModel.js"></script>
</body>
</html>

153
clipProperty.html Normal file
View file

@ -0,0 +1,153 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Clip Property component for KUTE.js allows you to animate the CSS clip property on most browsers.">
<meta name="keywords" content="clip,css clip,kute,kute.js,animation,javascript animation,tweening engine,animation engine,JavaScript,Native JavaScript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Clip Property</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li class="active"><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Clip Property</h2>
<p class="condensed lead">The component that animates the CSS <i>clip</i> property of a target element on most browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate the <b>clip</b> property of a target element when certain conditions are met.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>Clip Property</b> component enables animation for the CSS <b>clip</b> property on most browsers.</p>
<p>What exactly does it do? Well you can animate the <b>visible</b> rectangular shape of an element that is set to <b>position:absolute</b>.
If conditions are not met (more conditions apply, see notes below), the component will update the target element, but the effect is not visible.</p>
<p>Generally you can set the CSS rule for this property like this <b>clip: rect(top,right,bottom,left)</b> which forms a rectangular masking shape above
a target element making parts of it invisible.</p>
<p>While the CSS <b>clip</b> property has been deprecated, it can still be used to emulate a type of scale/reveal animation for legacy browsers in certain cases.</p>
<p>This component is bundled with the <i>demo/src/kute-extra.js</i> file.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Example</h3>
<p>A possible tween object using the property:</p>
<pre><code class="language-javascript">KUTE.to('selector',{clip:[0,150,100,0]}).start();</code></pre>
<p>And 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('https://picsum.photos/250/250') center center no-repeat;"></div>
<div class="example-buttons">
<a class="btn btn-olive" href="#">Start</a>
</div>
</div>
<h3>Notes</h3>
<ul>
<li>The component will produce no effect for target elements that have <code>overflow:visible</code> style rule.</li>
<li>Also target elements without <code>position:absolute</code> CSS rule will produce no effect.</li>
<li>This property will only work with <code>px</code> unit for the rectangular mask, which is unfortunate.</li>
<li>Don't stop here, there are thankfully replacements for this property, you can simply use all kinds of SVG masks and filters in combination
with the <a href="htmlAttributes.html">HTML Attributes</a> component for much more animation potential and for no compromise on animation quality.</li>
<li>This component is bundled with the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/clipProperty.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>

170
colorProperties.html Normal file
View file

@ -0,0 +1,170 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Color Properties component for KUTE.js enables animation for color based properties and their variations.">
<meta name="keywords" content="color,background-color,outline-color,kute,kute.js,animation,javascript animation,tweening engine,animation engine,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Color Properties</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li class="active"><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Color Properties</h2>
<p class="condensed lead">The component that animates CSS color properties for <b>Element</b> targets on most browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate <i>color</i> properties for a target element and updates its CSS style via <b>RGB</b>.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>Color Properties</b> component provides support for all color properties and all their variations on most browsers.</p>
<p>While with previous versions we used to have a <b>keepHex</b> option to always use the <b>HEX</b> format of the output color, modern browsers outright ignore the option and always
deliver colors in <b>RGB</b> format, probably for performance reasons.</p>
<p>The component supports input values such as <b>HEX</b>, <b>RGB</b> and <b>RGBA</b> for all color properties and most browsers should also work with
<a href="http://www.w3schools.com/colors/colors_names.asp" target="_blank">web safe colors</a>, eg. <b>color: 'red'</b>.</p>
<p>For a quick reference, here are all the supported properties:</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Supported Properties</h3>
<ul>
<li><kbd class="bg-olive">color</kbd> allows you to animate the color for a target text element. Eg. <code>color: '#ff0000'</code>.</li>
<li><kbd class="bg-olive">backgroundColor</kbd> allows you to animate the <code>background-color</code> for a target element. Eg. <code>backgroundColor: 'rgb(202,150,20)'</code>.</li>
<li><kbd class="bg-olive">outlineColor</kbd> allows you to animate the <code>outline-color</code> for a target element. Eg. <code>outline-color: 'cyan'</code>.</li>
<li><kbd class="bg-olive">borderColor</kbd> allows you to animate the <code>border-color</code> on all sides for a target element. Eg. <code>borderColor: 'rgba(250,100,20,0.5)'</code>.</li>
<li><kbd class="bg-olive">borderTopColor</kbd>, <kbd class="bg-olive">borderRightColor</kbd>, <kbd class="bg-olive">borderBottomColor</kbd> and <kbd class="bg-olive">borderLeftColor</kbd> properties allow
you to animate the color of the border on each side of a target element. Eg. <code>borderTopColor: 'rgb(0,66,99)'</code>.</li>
</ul>
<h3>Examples</h3>
<p>OK let's have a look at some sample tween objects and a quick demo:</p>
<pre><code class="language-javascript">KUTE.to('selector1',{color:'rgb(0,66,99)'}).start();
KUTE.to('selector1',{backgroundColor:'#069'}).start();
KUTE.to('selector1',{borderColor:'turquoise'}).start(); // IE9+
</code></pre>
<div id="colBox" class="featurettes">
<div class="example-item example-box bg-olive" style="outline: #fff solid 5px; width: 155px; height: 155px; border:15px solid #9C27B0; line-height: 125px;">Colors</div>
<div class="example-buttons">
<a class="btn btn-blue" href="#">Start</a>
</div>
</div>
<h3>Notes</h3>
<ul>
<li>The component will NOT work with <b>SVGElement</b> targets and their specific color attributes like <code>fill</code> or <code>stroke</code>, for that you can use the
<a href="htmlAttributes.html">HTML Attributes</a> component.</li>
<li>To simplify your workflow, the value processing can also work with web safe colors like <code>steelblue</code> or <code>darkorange</code>.</li>
<li>You can also use <code>RGB</code> or <code>RGBA</code>, but the last one is not supported on legacy browsers and it should fallback to <code>RGB</code>.</li>
<li>Some properties like <code>borderColor</code> and its variations or <code>outlineColor</code> won't have any visible effect if no border or outline style is applied to
your target element.</li>
<li>This component is bundled with the standard <i>kute.js</i> distribution file and the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/colorProperties.js"></script>
</body>
</html>

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

190
filterEffects.html Normal file
View file

@ -0,0 +1,190 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Filter Effects component for KUTE.js allows you to create CSS3 filter based animations on supporting browsers.">
<meta name="keywords" content="css3 filter,filter,kute,kute.js,animation,javascript animation,tweening engine,animation engine,JavaScript,Native JavaScript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Filter Effects</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<style></style>
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li class="active"><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Filter Effects</h2>
<p class="condensed lead">The component that animates the CSS3 <i>filter</i> property for specific <b>Element</b> targets on modern browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate <b>filter</b> functions for a target <b>Element</b> and deliver the best possible animation.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>Filter Effects</b> component provides support for the CSS3 <b>filter</b> property on modern browsers.</p>
<p>The component covers all <b>filter</b> functions, except that the <b>url()</b> function cannot be animated, however the component will
try and keep it's value into the target element styling at all times.</p>
<p>Similar to the <a href="transformFunctions.html">Transform Functions</a> and the <a href="transformMatrix.html">Transform Matrix</a> components,
this component will try and keep same order of the filter functions, regardless of the input order, and the reason is that chained animations can
have some unwanted janky artifact effects.</p>
<p>Most values are in [0-Infinity] range and the presentation is delivered with <b>%</b> suffixed values, except <b>blur()</b> which uses <b>px</b>
as unit/suffix.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Filter Functions</h3>
<ul>
<li><kbd class="bg-olive">url()</kbd> function links an element to an SVG filter, the function is supported to keep it's value into the target element's style in case it's set
initially or you want to set it yourself.</li>
<li><kbd class="bg-olive">opacity()</kbd> can animate the opacity for a target element in the 0-100% range. Default is 100%.</li>
<li><kbd class="bg-olive">blur()</kbd> can animate the blur for a target element in the 0-Infinity range. Default is <b>0px</b> and the unit is always <code>px</code>.</li>
<li><kbd class="bg-olive">saturate()</kbd> can animate the color saturation for a target element in the 0-Infinity range. Default is 100%.</li>
<li><kbd class="bg-olive">grayscale()</kbd> can animate the color desaturation for a target element in the 0-100% range. Default is 0%.</li>
<li><kbd class="bg-olive">brightness()</kbd> can animate the brightness for a target element in the 0-Infinity range. Default is 100%.</li>
<li><kbd class="bg-olive">contrast()</kbd> can animate the contrast for a target element in the 0-Infinity range. Default is 100%.</li>
<li><kbd class="bg-olive">sepia()</kbd> can animate the sepia filter for a target element in the 0-100% range. Default is 0%.</li>
<li><kbd class="bg-olive">invert()</kbd> can animate the color inversion for a target element in the 0-100% range. Default is 0%.</li>
<li><kbd class="bg-olive">hueRotate()</kbd> can animate the color hue rotation for a target element in the 0-Infinity range. Default is 0deg.</li>
<li><kbd class="bg-olive">dropShadow()</kbd> can animate the shadow and all related parameters for a target element. Default is <code>[0,0,0,'black']</code></li>
</ul>
<h3>Examples</h3>
<p>Let's have a look at some sample tween objects and a quick example:</p>
<pre><code class="language-javascript">let fe1 = KUTE.to('selector1', {filter :{ blur: 5 }})
let fe2 = KUTE.to('selector2', {filter :{ sepia: 50, invert: 80 }})
let fe3 = KUTE.to('selector3', {filter :{ saturate: 150, brightness: 90 }})
let fe4 = KUTE.to('selector4', {filter :{ url: '#mySVGFilter', opacity: 40, dropShadow:[5,5,5,'olive'] }})
</code></pre>
<div id="filter-examples" class="featurettes">
<svg style="display: none;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<filter id="mySVGFilter">
<feGaussianBlur in="SourceAlpha" stdDeviation="5"/>
<feOffset dx="5" dy="5" result="offsetblur"/>
<feFlood flood-color="#000000"/>
<feComposite in2="offsetblur" operator="in"/>
<feMerge>
<feMergeNode/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</defs>
</svg>
<div class="example-item example-box" style="background: url('https://picsum.photos/400/300') center center no-repeat; filter: url(#mySVGFilter)">FE1</div>
<div class="example-item example-box" style="background: url('https://picsum.photos/400/300') center center no-repeat; filter: url(#mySVGFilter)">FE2</div>
<div class="example-item example-box" style="background: url('https://picsum.photos/400/300') center center no-repeat; filter: url(#mySVGFilter)">FE3</div>
<div class="example-item example-box" style="background: url('https://picsum.photos/400/300') center center no-repeat">FE4</div>
<div class="example-buttons">
<a class="btn btn-blue" href="javascript:void(0)">Start</a>
</div>
</div>
<h3>Notes</h3>
<ul>
<li>The CSS filter property is supported on all major browsers nowadays, but it's better to <a href="https://caniuse.com/#feat=css-filter-function">check</a> and
<a href="https://css-tricks.com/almanac/properties/f/filter/#browser-support">double check</a>.</li>
<li>This component can be a great addition to all SVG related components, especially because the <code>dropShadow</code> provides a better experience than
<code>boxShadow</code>, as <a href="https://codepen.io/Kseso/pen/Ajamv">shown here</a>.</li>
<li>Since this component can work with the <code>url()</code> function the way it does, the <a href="htmlAttributes.html">HTML Attributes</a> component will
complement greatly for even more animation potential.</li>
<li>Similar to the <a href="htmlAttributes.html">HTML Attributes</a> component, this one can also deal with specific function namespace, for instance <code>hue-rotate</code> and
<code>hueRotate</code>.</li>
<li>This component is bundled with the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/filterEffects.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>

233
htmlAttributes.html Normal file
View file

@ -0,0 +1,233 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The HTML Attributes component for KUTE.js enables animation for any numeric presentation attribute as well as specific color attributes.">
<meta name="keywords" content="presentation attributes,attributes,html attributes,kute,kute.js,animation,javascript animations,tweening engine,animation engine,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js HTML Attributes</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li class="active"><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">HTML Attributes</h2>
<p class="condensed lead">The component that animates color attributes or any single value presentation attribute of a target element on most browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate a wide variety of presetantion attributes of a target element.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>HTML Attributes</b> component enables animation for any numeric presentation attribute, with or without a measurement unit / suffix as well as specific color attributes.</p>
<p>The component can be a great asset for creating complex animations in combination with the SVG components as we'll see in the following examples.</p>
<p>The component doesn't support attributes with multiple values like <b>stroke-dasharray</b>, <b>viewBox</b> or <b>transform</b> for specific reasons. To animate the <b>stroke</b> related attributes, the
<a href="svgDraw.html">SVG Draw</a> component is the tool for you, while for transform you have the <a href="svgTransform.html">SVG Transform</a> component and the
<a href="transformMatrix.html">Transform Matrix</a> component.</p>
<p>Despite the "limitations" of this component, you have access to just about any <b>SVGElement</b> or <b>Element</b>
<a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute" target="_blank">presentation attribute</a> available.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>General Usage</h3>
<pre><code class="language-javascript">// basic notation for unitless attributes
var myAttrTween = KUTE.to('selector', {attr: {attributeName: 75}});
// OR for attributes that are ALWAYS suffixed / have a measurement unit
var mySuffAttrTween = KUTE.to('selector', {attr:{attributeName: '15%'}});
</code></pre>
<h3>Attributes Namespace</h3>
<p>The <b>HTML Attributes</b> component can handle all possible single value presentation attributes with both dashed string and camel-case notation. Let's have a look at a sample notation so you can
get the idea:</p>
<pre><code class="language-javascript">// dashed attribute notation
var myDashedAttrStringTween = KUTE.to('selector', {attr: {'stroke-width': 75}});
// non-dashed attribute notation
var myNonDashedAttrStringTween = KUTE.to('selector', {attr:{strokeWidth: '15px'}});
</code></pre>
<p>The <code>strokeWidth</code> attribute is very interesting because it can work with <code>px</code>, <code>%</code> or with no unit/suffix. In this case, and in any context, the component will always work with the
attribute's current value suffix to eliminate any possible janky animation.</p>
<h3>Examples</h3>
<h4>Color Attributes</h4>
<p>The <b>HTML Attributes</b> component can also animate color attributes: <code>fill</code>, <code>stroke</code> and <code>stopColor</code>. If the elements are affected by their CSS counterparts, the effect
is not visible, you need to make sure that doesn't happen.</p>
<pre><code class="language-javascript">// some fill rgb, rgba, hex
var fillTween = KUTE.to('#element-to-fill', {attr: { fill: 'red' }});
// some stopColor or 'stop-color'
var stopColorTween = KUTE.to('#element-to-do-stop-color', {attr: {stopColor: 'rgb(0,66,99)'}});
</code></pre>
<div class="featurettes">
<svg class="example-box-model example-box" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 615 615">
<path id="fill" fill="#673AB7" d="M38.01,5.653h526.531c17.905,0,32.422,14.516,32.422,32.422v526.531
c0,17.905-14.517,32.422-32.422,32.422H38.01c-17.906,0-32.422-14.517-32.422-32.422V38.075C5.588,20.169,20.104,5.653,38.01,5.653z"/>
</svg>
<div class="example-buttons">
<a id="fillBtn" class="btn btn-blue" href="javascript:void(0)">Start</a>
</div>
</div>
<p>If in this example the <code>fill</code> attribute value would reference a gradient, then <i>rgba(0,0,0,0)</i> is used. Keep in mind that the component will not work with combined
fill values like <code>url(#pattern) rgba()</code>, you are better of only using the <code>url(#pattern)</code> and use other attributes to control directly the animation of that
linked pattern, just like in the last example below.</p>
<h4>Unitless Attributes</h4>
<p>In the next example, let's play with the attributes of a <code>&lt;circle&gt;</code> element: radius and center coordinates.</p>
<pre><code class="language-javascript">// radius attribute
var radiusTween = KUTE.to('#circle', {attr: {r: 75}});
// coordinates of the circle center
var coordinatesTween = KUTE.to('#circle', {attr:{cx:0,cy:0}});
</code></pre>
<p>A quick demo with the above:</p>
<div class="featurettes">
<svg class="example-box-model example-box" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 150">
<circle class="bg-orange" id="circle" cx="75" cy="75" r="40" />
</svg>
<div class="example-buttons">
<a id="circleBtn" class="btn btn-orange" href="javascript:void(0)">Start</a>
</div>
</div>
<h4>Suffixed Attributes</h4 >
<p>Similar to the example on circle attributes, we can also animate the gradient positions but this time with a specific to gradients suffix, and the component will make sure
to always include the suffix for you, as in this example the <code>%</code> unit is found in the current value and used as unit for the DOM update:</p>
<pre><code class="language-javascript">// gradient positions to middle
var closingGradient = KUTE.to('#gradient', {attr: {x1:'49%', x2:'49%', y1:'49%', y2:'49%'}});
// gradient positions rotated
var rotatingGradient = KUTE.to('#gradient', {attr: {x1:'49%', x2:'51%', y1:'51%', y2:'51%'}});
</code></pre>
<div class="featurettes">
<svg class="example-box-model example-box" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 615 615">
<defs>
<linearGradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color: #e91b1f; stop-opacity:1"></stop>
<stop offset="100%" style="stop-color: #2196F3; stop-opacity:1"></stop>
</linearGradient>
</defs>
<path fill="url(#gradient)" d="M38.01,5.653h526.531c17.905,0,32.422,14.516,32.422,32.422v526.531
c0,17.905-14.517,32.422-32.422,32.422H38.01c-17.906,0-32.422-14.517-32.422-32.422V38.075C5.588,20.169,20.104,5.653,38.01,5.653z"/>
</svg>
<div class="example-buttons">
<a id="gradBtn" class="btn btn-pink" href="javascript:void(0)">Start</a>
</div>
</div>
<h3>Notes</h3>
<ul>
<li>The power of this little gem comes from the fact that it can work with internally undefined/unknown attributes, as well as with attributes that are not yet present in the W3 draft. As long as you provide valid values specific
to the attribute, the component will assign an update function and will always double check for the current value to determine if it needs a suffix or if the attribute name needs adjustments
(EG: <code>fillOpacity</code> becomes <code>fill-opacity</code>).</li>
<li>This component is a great addition to complement any SVG related component as well as a great complement to <a href="filterEffects.html">Filter Effects</a> component.</li>
<li>Remember to check your elements markup for changes, your animation might not be visible because equivalent CSS is used.</li>
<li>This component is bundled with the standard <i>kute.js</i> distribution file and the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div><!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/htmlAttributes.js"></script>
</body>
</html>

292
index.html Normal file
View file

@ -0,0 +1,292 @@
<!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, minimum-scale=1.0">
<meta name="description" content="KUTE.js is a fully featured JavaScript animation engine with outstanding performance and supporting 3D transforms, SVG Morph, draw SVG, SVG transform, cross-browser animation, scroll animation, CSS3 properties and many more.">
<meta name="keywords" content="kute,kute.js,animation,javascript animation,tweening engine,animation engine,morph svg,draw svg,svg transform,css3,3d transform,scroll,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="thednp">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js | JavaScript Animation Engine</title>
<!-- RESET CSS -->
<link type="text/css" href="./assets/css/reset.css" rel="stylesheet">
<!-- Spicr CSS -->
<link type="text/css" href="https://cdn.jsdelivr.net/npm/spicr/dist/css/spicr.min.css" rel="stylesheet">
<!-- DEMO KUTE CSS -->
<link type="text/css" href="./assets/css/kute.css" rel="stylesheet">
<link type="text/css" href="./assets/css/spicr-theme.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1 class="active">KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEjs animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div id="SpicrDemo" class="spicr spicr-slider" data-interval="false" >
<div class="spicr-inner">
<div class="item">
<div class="item-bg spicr-layer bg-blue background-bottom-center" data-translate="x:-100%" data-duration="700" data-easing="easingCubicInOut" data-src="https://picsum.photos/id/992/1680/720.jpg">
<div class="overlay"></div>
</div>
<div class="content-wrap h-100"> <!-- IE9 fix -->
<div class="d-flex align-items-end h-100">
<div class="flex-column w-md-50 text-center mb-5" style="margin: 0 auto">
<div class="spicr-layer" data-translate="x:-250" data-duration="600" data-easing="easingCubicInOut">
<h1>Welcome to KUTE.js!</h1>
</div>
<div class="spicr-layer" data-translate="x:-250" data-delay="350" data-duration="700" data-easing="easingCubicInOut">
<p class="lead condensed">The JavaScript animation engine of the future</p>
</div>
<div class="spicr-layer" data-translate="x:-250" data-delay="450" data-duration="800" data-easing="easingCubicInOut">
<p>The magic behind <a class="text-light font-weight-bold" href="https://thednp.github.io/spicr/">Spicr</a>, the result of hard work,
the bridge between old and new, the dream and inspiration.</p>
</div>
<div>
<p class="btns">
<a class="btn btn-red spicr-layer" href="https://github.com/thednp/kute.js/archive/master.zip" data-translate="x:-250" data-delay="750" data-duration="900" data-easing="easingCircularInOut">Download</a>
<a class="btn btn-olive spicr-layer" href="https://thednp.github.io/kute.js" data-translate="x:-250" data-delay="650" data-duration="800" data-easing="easingCircularInOut">Github</a>
<a class="btn btn-indigo spicr-layer" href="https://www.npmjs.com/package/kute.js" data-translate="x:-250" data-delay="550" data-duration="700" data-easing="easingCircularInOut">NPM</a>
<a class="btn btn-blue spicr-layer" href="https://www.jsdelivr.com/package/npm/kute.js" data-translate="x:-250" data-delay="450" data-duration="600" data-easing="easingCircularInOut">CDN</a>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="item perspective-1500">
<div class="item-bg spicr-layer bg-olive" data-rotate="x:90" data-transform-origin="z:50%v" data-duration="700" data-easing="easingCubicInOut" data-src="https://picsum.photos/id/931/1680/720.jpg">
<div class="overlay"></div>
</div>
<div class="content-wrap h-100"><!-- IE9 fix -->
<div class="columns h-100 align-content-center">
<div class="col2 h-md-100"><!-- IE9 fix -->
<div class="d-flex perspective align-items-end align-items-md-center h-md-100">
<div class="spicr-layer" data-translate="y:10%" data-rotate="x:90" data-transform-origin="z:50%" data-duration="800" data-easing="easingCubicInOut">
<h1>Forward Looking</h1>
<p>The modern JavaScript powering the core functionality, the modular architecture, the solid and complete components are all geared towards the future of web development.</p>
</div>
</div>
</div>
<div class="col2 h-md-100">
<div class="d-flex perspective align-items-start align-items-md-center h-md-100">
<div class="spicr-layer" data-translate="y:10%" data-rotate="x:90" data-transform-origin="z:50%" data-duration="900" data-delay="350" data-easing="easingCubicInOut">
<h1>Knowing the Past</h1>
<p>While KUTE.js was re-developed to support mainly modern browsers, it also leaves the door open to old browsers with its legacy components, tools and polyfills.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item">
<div class="item-bg spicr-layer bg-pink" data-translate="y:-100%" data-duration="700" data-easing="easingCubicInOut" data-src="https://picsum.photos/id/668/1680/720.jpg">
<div class="overlay"></div>
</div>
<div class="content-wrap h-100">
<div class="columns align-content-center h-100">
<div class="col2 h-md-100">
<div class="d-flex align-items-start align-items-md-center h-md-100">
<div class="w-100 flex-column"> <!-- IE9 fix -->
<div class="spicr-layer" data-translate="y:-150" data-duration="800" data-delay="550" data-easing="easingCircularOut">
<h1>ES6+ JavaScript</h1>
</div>
<div class="spicr-layer" data-translate="y:-150" data-duration="900" data-delay="650" data-easing="easingCircularOut">
<p>Inside the sources you will find fast &amp; modern JavaScript code with solid build tools. Everything and anything can be done with <b>SVGElement</b>,
HTML attributes, CSS transform, etc.</p>
</div>
</div>
</div>
</div>
<div class="col2 h-md-100"> <!-- IE9 fix -->
<div class="d-flex align-items-end align-items-md-center h-md-100">
<div class="w-100 flex-column"> <!-- IE9 fix -->
<div class="spicr-layer" data-translate="y:-150" data-duration="700" data-delay="350" data-easing="easingCircularOut">
<h1>Cubic Bezier Easing</h1>
</div>
<div class="spicr-layer" data-translate="y:-150" data-duration="800" data-delay="450" data-easing="easingCircularOut">
<p>While the library includes Robert Penner's <a href="http://robertpenner.com/easing/">easing functions</a>, KUTE.js also includes its own
<a href="https://github.com/thednp/CubicBezier">CubicBezier Easing</a> class to provide fast and accurate easing for your animation.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="item perspective-1500">
<div class="item-bg spicr-layer bg-indigo" data-rotate="y:90" data-transform-origin="z:-50%" data-duration="1000" data-easing="easingCubicInOut" data-src="https://picsum.photos/id/581/1680/720.jpg">
<div class="overlay"></div>
</div>
<div class="content-wrap h-100">
<div class="d-flex w-md-75 align-items-center text-md-center justify-content-md-center h-100" style="margin: 0 auto">
<div class="spicr-layer" data-rotate="y:90" data-transform-origin="z:-50%" data-duration="1200" data-easing="easingCubicInOut">
<h1><span>What's not to love about it?</span></h1>
<p>Yeah, the open source, modular and fully featured animation engine for the modern web, fully documented and MIT Licensed.</p>
<p>Any question? Find answers <a href="https://stackoverflow.com/search?q=kute.js">here</a>, or post them <a href="https://github.com/thednp/kute.js/issues">here</a>!</p>
</div>
</div>
</div>
</div>
</div>
<!-- pages -->
<ol class="spicr-pages d-flex flex-row justify-content-center">
<li data-slide-to="0" class=""></li>
<li data-slide-to="1"></li>
<li data-slide-to="2"></li>
<li data-slide-to="3"></li>
</ol>
<a class="left spicr-control long-shadows" data-slide="prev">
<span class="arrow-prev">
<svg class="spicr-icon" viewBox="0 0 1024 1024">
<path d="M658 686l-60 60-256-256 256-256 60 60-196 196z"></path>
</svg>
</span>
</a>
<a class="right spicr-control long-shadows" data-slide="next">
<span class="arrow-next">
<svg class="spicr-icon" viewBox="0 0 1024 1024">
<path d="M366 698l196-196-196-196 60-60 256 256-256 256z"></path>
</svg>
</span>
</a>
</div>
<div class="featurettes dark mt-0">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h2 class="border text-right">Overview</h2>
<p class="condensed text-right">If you're looking for that spicy tool to kickstart your animations, developed with latest technology and modular design, you will love KUTE.js.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The JavaScript animation engine reimagined for the evolving modern web, the library that keeps track on the changing standards, the modular tool
to enable creativity.</p>
<p>Built on modern ES6+ JavaScript Standard, packed with utilities, build tools and a wide range of supported properties, <b>KUTE</b>.js is now a fully featured animation engine
you can use to create complex animations, with properties or elements that cannot be animated with CSS3 transitions or other animation engines, or attributes that aren't
even drafted in the specification yet.</p>
<p class="lead condensed">The JavaScript animation engine that never stops evolving just like we never stop learning. Instead of becoming more bloated, we make it more modular,
instead of compromising we chose innovating. </p>
<p>While <b>KUTE</b>.js doesn't activelly support legacy browsers, it provides a wide range of tools and utilities you can use to create a fallback animation for every browser
and property.</p>
<p>The demo pages use a dedicated polyfill for IE10+ browsers, but today we have <a href="https://polyfill.io/">polyfill services</a> and a wide range of
<a href="http://browserhacks.com" target="_blank">browser detection</a> options to handle legacy browsers, our focus here is the highest performance on modern browsers.</p>
<p>By the way, <b>KUTE</b>.js is <a href="performance.html">really fast</a>.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<div class="columns">
<div class="col2">
<h3 class="border">ES6+ JavaScript</h2>
<p class="condensed">The entire codebase reworked on the latest standards with flexible <code>rollup</code> based build tools. Most classes are extensible via the ES6 <code>extend</code>
or your usual <code>prototype</code>, depending on the class.</p>
</div>
<div class="col2">
<h3 class="border">Lots of Components</h2>
<p class="condensed">All your previously supported properties and plugins have been split into components for more modularity. New additions have been added for a broader scope.
The official distribution only includes most popular components.</p>
</div>
<div class="col2">
<h3 class="border">Familiar Syntax</h2>
<p class="condensed">You can create your tween objects with a familiar syntax with your trusted options, the callback system and other component related options.</p>
</div>
<div class="col2">
<h3 class="border">Tools and Options</h2>
<p class="condensed">Along the wide range of options, certain components provide tools for further control over the outcome. Also there's a <a href="progress.html">progress
bar</a> somewhere.</p>
</div>
<div class="col2">
<h3 class="border">Well Documented</h2>
<p class="condensed">Each component demo page comes packed with tons of guides and tips on how to optimize the performance and visual presentation.</p>
</div>
<div class="col2">
<h3 class="border">MIT License</h2>
<p class="condensed">The library is released under the <a href="https://github.com/thednp/kute.js/blob/master/LICENSE">MIT License</a>.</p>
</div>
</div>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/spicr/dist/js/spicr.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dll.js@1.5.5/dist/dll.min.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/home.js"></script>
</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();
}
};

153
opacityProperty.html Normal file
View file

@ -0,0 +1,153 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Opacity Property component for KUTE.js allows you to animate the opacity CSS property on most browsers.">
<meta name="keywords" content="opacity,kute.js,animation,javascript animation,tweening engine,animation engine,JavaScript,Native JavaScript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Opacity Property</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<style></style>
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li class="active"><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Opacity Property</h2>
<p class="condensed lead">The component that animates the CSS <i>opacity</i> property of a target <b>Element</b> on most browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate the <b>opacity</b> property of a target element.</p>
</div>
<div class="col9 border">
<p>The KUTE.js <b>Opacity Property</b> component enables animation for the <b>opacity</b> CSS property of an <b>Element</b> target on most browsers.</p>
<p>In most cases, the best presentatation can be offered with a nice and smooth fade animation, with opacity going from 0% all the way up to to 100%.</p>
<p>While some components like <a href="htmlAttributes.html">HTML Attributes</a> and <a href="filterEffects.html">Filter Effects</a> do provide some
similar functionality for specific <b>Element</b> types, this component covers all types of elements and is supported on a wide range of modern
and legacy browsers alike.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Example</h3>
<pre><code class="language-javascript">// fade out
let fadeOutTween = KUTE.to('selector1',{opacity:0}).start()
// fade in
let fadeInTween = KUTE.to('selector1',{opacity:1}).start()
</code></pre>
<div id="opacityProperty" class="featurettes">
<div class="example-item example-box" style="opacity:0">
<svg class="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
<path fill="red" d="M880.128 199.936c-85.606-78.541-224.41-78.541-310.016 0l-58.112 53.35-58.163-53.35c-85.606-78.541-224.358-78.541-309.965 0-96.307 88.422-96.307 231.424 0 319.795l368.128 337.869 368.128-337.869c96.256-88.371 96.256-231.424 0-319.795z"></path>
</svg>
</div>
<div class="example-buttons"><a class="btn btn-red" href="javascript:void(0)">Start</a></div>
</div>
<h3>Notes</h3>
<ul>
<li>This demo should work with IE9+ browsers.</li>
<li>Support for the specific IE8 <code>filter:alpha(opacity=50)</code> have been dropped.</li>
<li>Early implementations with vendor preffixes such as <code>-o-opacity</code>, <code>-moz-opacity</code> or <code>-ms-opacity</code> are not supported.</li>
<li>The component is an essential part in ALL KUTE.js distributions.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- <script src="./src/polyfill-legacy.min.js"></script> -->
<script src="./src/polyfill-legacy.min.js"></script>
<script src="./src/kute.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/opacityProperty.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>

212
performance-matrix.html Normal file
View file

@ -0,0 +1,212 @@
<!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, minimum-scale=1.0">
<meta name="description" content="KUTE.js performance testing page, comparing basic transform to matrix transform.">
<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.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<title>KUTE.js | Transform Matrix Performance Testing Page</title>
<style>
body {
background-color: #08263d;
color: #999;
font-size: 12px;
font-family: Helvetica, Arial, Helvetica, sans-serif;
}
.hr { border-color: rgba(255, 255, 255, 0.2); margin: 15px 0 }
a {
color: #ffd626;
text-decoration: none
}
a:hover,
a:focus {
color: #fff;
}
#container {
width: 70%;
/*height: 200px;*/
margin: 5% auto 0 auto;
position: relative;
display: none;
/* perspective: 1200px; */
/* transform-style: preserve-3d; don't overDO the preserve3d */
}
iframe {
width: 100%;
height: 100%;
border: 0
}
.line {
width: 200px;
height: 2px;
position: absolute;
}
.box {
height: 200px
}
#info {
position: absolute;
top: 20%;
left: 0;
width: 350px;
}
.padding {
padding: 20px
}
.btn-group {
margin-bottom: 15px;
}
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
}
.btn-primary {
color: #fff;
background-color: #337ab7;
}
.btn-success {
color: #fff;
background-color: #5cb85c;
}
.text-note {
color: #069
}
.text-danger {
font-weight: bold
}
.list-inline {
padding-left: 0;
list-style: none;
margin-left: -5px;
}
.list-inline>li {
display: inline-block;
padding-right: 5px;
padding-left: 5px;
}
.cube {
flex: 0 1 auto;
width: 100px;
height: 100px;
transform-style: preserve-3d;
display: inline-flex;
margin: 3%
}
.cube .cube__side {
position: absolute;
height: 100%;
width: 100%;
background-color: rgba(80, 176, 255, 0.1);
box-shadow: inset 0 0 0 2px rgb(40, 225, 238);
}
.cube .cube__side:nth-child(1) {transform: translateZ(50px); }
.cube .cube__side:nth-child(2) {transform: translateZ(-50px); }
.cube .cube__side:nth-child(3) {transform: translateX(-50px) rotateY(90deg); }
.cube .cube__side:nth-child(4) {transform: translateX(50px) rotateY(-90deg); }
.cube .cube__side:nth-child(5) {transform: translateY(50px) rotateX(90deg); }
.cube .cube__side:nth-child(6) {transform: translateY(-50px) rotateX(-90deg); }
.cube .cube__side:nth-child(7),
.cube .cube__side:nth-child(8),
.cube .cube__side:nth-child(9),
.cube .cube__side:nth-child(10),
.cube .cube__side:nth-child(11),
.cube .cube__side:nth-child(12),
.cube .cube__side:nth-child(13),
.cube .cube__side:nth-child(14),
.cube .cube__side:nth-child(15) {
background-color: rgba(129, 11, 109, 0.1) !important;
box-shadow: 0 0 1rem #d2ff6a, inset 0 0 0 2px #6afff8;
opacity: 0.2;
}
.cube.alive .cube__side:nth-child(7),
.cube.alive .cube__side:nth-child(8),
.cube.alive .cube__side:nth-child(9),
.cube.alive .cube__side:nth-child(10),
.cube.alive .cube__side:nth-child(11),
.cube.alive .cube__side:nth-child(12),
.cube.alive .cube__side:nth-child(13),
.cube.alive .cube__side:nth-child(14),
.cube.alive .cube__side:nth-child(15) {opacity: 0.5; }
.cube .cube__side:nth-child(7) {transform: translateY(-25px) rotateX(-90deg); }
.cube .cube__side:nth-child(8) {transform: rotateX(-90deg); }
.cube .cube__side:nth-child(9) {transform: translateY(25px) rotateX(-90deg); }
.cube .cube__side:nth-child(10) {transform: translateZ(25px); }
.cube .cube__side:nth-child(11) {transform: none; }
.cube .cube__side:nth-child(12) {transform: translateZ(-25px); }
.cube .cube__side:nth-child(13) {transform: translateX(-25px) rotateY(90deg); }
.cube .cube__side:nth-child(14) {transform: rotateY(90deg); }
.cube .cube__side:nth-child(15) {transform: translateX(25px) rotateY(90deg); }
</style>
</head>
<body>
<div id="info" class="padding">
<ul class="list-inline">
<li><a title="Go to KUTE.js homepage" href="index.html">Homepage</a></li>
<li><a title="Go to animation engine performance comparison page" href="performance.html">Engine Comparison</a></li>
<li><a title="Go to Transform Functions component testing page" href="performance-transform.html">Transform Functions</a></li>
</ul>
<hr class="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 Webkit browsers like Google Chrome and Opera 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 class="text-note">Please know that a local copy of this page will outperform the live site demo on Google Chrome, the reason is unknown.</p>
</div>
<div id="container"></div>
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/bootstrap.native/1.0.1/bootstrap-native.min.js"></script>
<!-- <script src="../experiments/CSSMatrix.js"></script> -->
<script id="kute" src="./src/kute-extra.min.js"></script>
<!-- <script id="kute" src="./src/kute-extra.js"></script> -->
<script src="./assets/js/perf-matrix.js"></script>
</body>
</html>

213
performance-transform.html Normal file
View file

@ -0,0 +1,213 @@
<!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, minimum-scale=1.0">
<meta name="description" content="KUTE.js performance testing page, comparing basic transform to matrix transform.">
<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.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<title>KUTE.js | Regular Transform Performance Testing Page</title>
<style>
body {
background-color: #08263d;
color: #999;
font-size: 12px;
font-family: Helvetica, Arial, Helvetica, sans-serif;
}
a {
color: #ffd626;
text-decoration: none
}
.hr { border-color: rgba(255, 255, 255, 0.2); margin: 15px 0 }
a:hover,
a:focus {
color: #fff;
}
#container {
width: 70%;
/*height: 200px;*/
margin: 5% auto 0 auto;
position: relative;
display: none;
/* perspective: 1200px; */
/* transform-style: preserve-3d; don't overDO the preserve3d */
}
iframe {
width: 100%;
height: 100%;
border: 0
}
.line {
width: 200px;
height: 2px;
position: absolute;
}
.box {
height: 200px
}
#info {
position: absolute;
top: 20%;
left: 0;
width: 350px;
}
.padding {
padding: 20px
}
.btn-group {
margin-bottom: 15px;
}
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
}
.btn-primary {
color: #fff;
background-color: #337ab7;
}
.btn-success {
color: #fff;
background-color: #5cb85c;
}
.text-note {
color: #069
}
.text-danger {
font-weight: bold
}
.list-inline {
padding-left: 0;
list-style: none;
margin-left: -5px;
}
.list-inline>li {
display: inline-block;
padding-right: 5px;
padding-left: 5px;
}
.cube {
flex: 0 1 auto;
width: 100px;
height: 100px;
transform-style: preserve-3d;
display: inline-flex;
margin: 3%
}
.cube .cube__side {
position: absolute;
height: 100%;
width: 100%;
background-color: rgba(80, 176, 255, 0.1);
box-shadow: inset 0 0 0 2px rgb(13, 165, 64);
}
.cube .cube__side:nth-child(1) {transform: translateZ(50px); }
.cube .cube__side:nth-child(2) {transform: translateZ(-50px); }
.cube .cube__side:nth-child(3) {transform: translateX(-50px) rotateY(90deg); }
.cube .cube__side:nth-child(4) {transform: translateX(50px) rotateY(-90deg); }
.cube .cube__side:nth-child(5) {transform: translateY(50px) rotateX(90deg); }
.cube .cube__side:nth-child(6) {transform: translateY(-50px) rotateX(-90deg); }
.cube .cube__side:nth-child(7),
.cube .cube__side:nth-child(8),
.cube .cube__side:nth-child(9),
.cube .cube__side:nth-child(10),
.cube .cube__side:nth-child(11),
.cube .cube__side:nth-child(12),
.cube .cube__side:nth-child(13),
.cube .cube__side:nth-child(14),
.cube .cube__side:nth-child(15) {
background-color: rgba(129, 11, 109, 0.1) !important;
box-shadow: 0 0 1rem #d7ff6a, inset 0 0 0 2px #6aff8f;
opacity: 0.2;
}
.cube.alive .cube__side:nth-child(7),
.cube.alive .cube__side:nth-child(8),
.cube.alive .cube__side:nth-child(9),
.cube.alive .cube__side:nth-child(10),
.cube.alive .cube__side:nth-child(11),
.cube.alive .cube__side:nth-child(12),
.cube.alive .cube__side:nth-child(13),
.cube.alive .cube__side:nth-child(14),
.cube.alive .cube__side:nth-child(15) {opacity: 0.5; }
.cube .cube__side:nth-child(7) {transform: translateY(-25px) rotateX(-90deg); }
.cube .cube__side:nth-child(8) {transform: rotateX(-90deg); }
.cube .cube__side:nth-child(9) {transform: translateY(25px) rotateX(-90deg); }
.cube .cube__side:nth-child(10) {transform: translateZ(25px); }
.cube .cube__side:nth-child(11) {transform: none; }
.cube .cube__side:nth-child(12) {transform: translateZ(-25px); }
.cube .cube__side:nth-child(13) {transform: translateX(-25px) rotateY(90deg); }
.cube .cube__side:nth-child(14) {transform: rotateY(90deg); }
.cube .cube__side:nth-child(15) {transform: translateX(25px) rotateY(90deg); }
</style>
</head>
<body>
<div id="info" class="padding">
<ul class="list-inline">
<li><a title="Go to KUTE.js homepage" href="index.html">Homepage</a></li>
<li><a title="Go to animation engine performance comparison page" href="performance.html">Engine Comparison</a></li>
<li><a title="Go to Transform Matrix component testing page" href="performance-matrix.html">Transform Matrix</a></li>
</ul>
<hr class="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 Webkit browsers like Google Chrome and Opera 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 class="text-note">Please know that a local copy of this page will outperform the live site demo on Google Chrome, the reason is unknown.</p>
</div>
<div id="container"></div>
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/bootstrap.native/1.0.1/bootstrap-native.min.js"></script>
<script id="kute" src="./src/kute.min.js"></script>
<script src="./assets/js/perf-matrix.js"></script>
</body>
</html>

244
performance.html Normal file
View file

@ -0,0 +1,244 @@
<!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, minimum-scale=1.0">
<meta name="description" content="KUTE.js performance testing page, in comparison with GSAP and Tween.js">
<meta name="keywords" content="kute,kute.js,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<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: #08263d;
color: #999;
font-size: 12px;
font-family: Helvetica, Arial, Helvetica, sans-serif;
}
.hr { border-color: rgba(255, 255, 255, 0.2); margin: 15px 0; clear:both }
a {
color: #ffd626;
text-decoration: none
}
.btn-group { display: inline-block}
a:hover,
a:focus {
color: #fff;
}
#container {
width: 200px;
/*height: 200px;*/
margin: 0 auto;
position: relative;
display: block;
}
iframe {
width: 100%;
height: 100%;
border: 0
}
.line {
width: 200px;
height: 2px;
position: absolute;
}
.box {
height: 200px
}
#info {
position: absolute;
top: 20%;
left: 0;
width: 350px;
}
.padding {
padding: 20px
}
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
}
.btn:focus { outline: none }
.btn-primary {
color: #fff;
background-color: #337ab7;
}
.btn-success {
color: #fff;
background-color: #5cb85c;
}
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
font-size: 14px;
text-align: left;
list-style: none;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,.15);
}
.dropdown-menu>li:hover { background-color: rgba(0,0,0,0.2); }
.dropdown-menu>li>a {
display: block;
padding: 3px 20px;
clear: both;
font-weight: 400;
line-height: 1.42857143;
color: #333;
white-space: nowrap;
}
.dropdown {
position:relative
}
.dropdown.open .dropdown-menu {
display: block
}
.text-note {
color: #069
}
.text-danger {
font-weight: bold
}
.list-inline {
padding-left: 0;
list-style: none;
margin-left: -5px;
}
.list-inline>li {
display: inline-block;
padding-right: 5px;
padding-left: 5px;
}
</style>
</head>
<body>
<div id="info" class="padding">
<ul class="list-inline">
<li><a title="Go to KUTE.js homepage" href="index.html">Homepage</a></li>
<li><a title="Go to Transform Functions component testing page" href="performance-transform.html">Transform Functions</a></li>
<li><a title="Go to Transform Matrix component testing page" href="performance-matrix.html">Transform Matrix</a></li>
</ul>
<hr class="hr">
<span id="engine" class="btn-group dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" tabindex="0">Engine <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>
<span id="property" class="btn-group dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" tabindex="0">Property <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>
<span id="repeat" class="btn-group dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" tabindex="0">Repeat <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>
<span id="count" class="btn-group dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" tabindex="0">Count <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="#"><span style="color: red">1000</span></a></li>
<li><a id="1500" href="#"><span style="color: red">1500</span></a></li>
<li><a id="2000" href="#"><span style="color: red">2000</span></a></li>
</ul>
</span>
<hr class="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 Webkit browsers like Google Chrome and Opera 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 class="text-note">Please know that a local copy of this page will outperform the live site demo on Google Chrome, the reason is unknown.</p>
</div>
<div id="container"></div>
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!--[if !IE ]><!-->
<script src="https://cdn.jsdelivr.net/bootstrap.native/1.0.1/bootstrap-native.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.0.5/gsap.min.js"></script>
<script src="./assets/js/tween.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/perf.js"></script>
<!--<![endif]-->
</body>
</html>

219
progress.html Normal file
View file

@ -0,0 +1,219 @@
<!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, minimum-scale=1.0">
<meta name="description" content="A simple tool to showcase control KUTE.js tween objects progress.">
<meta name="keywords" content="kute,kute.js,animation,javascript animation,tweening engine,animation engine,progress,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Using Update Functions | 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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<style>
.text-example {
margin: 0 0 20px;
font-size: 28px
}
.red {
color: red
}
.slider {
margin-right: 20px;
}
input[type="range"] {
-webkit-appearance: none !important;
width: 100%;
height: 12px;
background-color: #b0cde4;
border: 0;
border-radius: 5px;
margin: auto;
transition: all 0.3s ease;
}
input[type="range"]:hover {
background-color: #a3bdd2;
}
input[type="range"]:focus {
outline: none;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none !important;
width: 20px;
height: 20px;
background-color: #2196F3;
border-radius: 30px;
transition: all 0.5s ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
background-color: #1b7bc7;
}
input[type="range"]::-webkit-slider-thumb:active {
box-shadow: 0px 0px 1px #1b7bc7;
}
#rangevalue {
position: absolute; bottom: 20px; right: 20px;
}
</style>
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1 class="active">KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Tween Progress Control</h2>
<p class="condensed lead">The handy tool to manually update a tween via an <b>Input</b> slider.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Create a tween object and link it to a range slider <b>Input</b>. Some stuff happening.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The <b>Progress Bar</b> can be a handy tool that enables you to manually update your tween animation, just in case there is a little
detail you want to make it right.</p>
<p>KUTE.js object exposes all required methods in order for it to work, so why not try to do something fun? How about control tween progress? So let's make a quick tool:</p>
<ul>
<li>We need an <code>&lt;input type="range" min="0" max="1" step="0.00001" /&gt;</code> with these exact <code>min</code>, <code>max</code> and <code>step</code> attributes</li>
<li>Now we need a tween object, let's just do a svg morph for instance, but make sure you use <code>KUTE.fromTo()</code> method, the others don't prepare start values for the tween object</li>
<li>We also need to make sure nothing controls the progress except the range input, so don't use <code>start()</code> or <code>pause()</code> methods at all, as well as <code>repeat</code> and / or <code>yoyo</code> options</li>
<li>Next we attach an <code>input</code> event handler to update the tween progress by using the <code>KUTE.update</code> function, which is the step function triggered on every <code>requestAnimationFrame</code> tick</li>
</ul>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<p>A very basic code sample will look like this:</p>
<pre><code class="language-javascript">// the range slider
var rangeSlider = document.querySelector('input[type="range"');
// basic morph, only fromTo and allFromTo should work
var morphTween = KUTE.to('#rectangle', { path: '#star' } );
// initialize a progressBar for your tween
var progressBar = new KUTE.ProgressBar(rangeSlider,morphTween)
// also start animation when Element is clicked
document.getElementById('rectangle').addEventListener('click',function(){
!morphTween.playing && morphTween.start()
})
</code></pre>
<p>And now let's see the code in action:</p>
<div class="featurettes">
<div class="slider">
<input type="range" min="0" max="1" value="0" step="0.0001" />
<output id="rangevalue">0%</output>
</div>
<svg class="example-box-model example-box" id="morph-example1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="rectangle" class="bg-blue" d="M559,597.4H302.1H43.6c-21,0-38-17-38-38V408.8V223.6V44c0-21,17-38,38-38h105.6H300h160.3H559
c21,0,38,17,38,38v184v331.4C597,580.4,580,597.4,559,597.4z"/>
<path id="star" style="visibility:hidden" d="M302.1,17.9c16,29,81.4,147.7,98.2,178.2c31.1,6,62.3,11.9,93.4,17.9c35.5,6.8,71,13.6,106.5,20.4
c-46.4,49.5-92.7,99-139.1,148.5c1.1,8.5,6.7,53.4,12.4,99.1c5.7,45.3,11.4,91.4,12.9,102.9c-36-16.9-158.8-74.5-184.2-86.4
c-28.5,13.4-151.3,71-184.2,86.4c0.4-3.2,13.3-106.6,13.3-106.6s10.1-81,11.9-95.3C96.8,333.5,50.4,284,4,234.5
c34.4-6.6,68.8-13.2,103.3-19.8c32.2-6.2,64.4-12.3,96.5-18.5C221,165.1,286.5,46.2,302.1,17.9z"/>
</svg>
</div>
<p>We might argue that we want to use other methods in combination with this method, or use this method while animations are running, but there are other libraries out there that can do that already. This example here is just to showcase KUTE.js can do this too.</p>
<p>Note that this tool is not included in the official distribution file.</p>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/progress.js"></script>
</body>
</html>

219
scrollProperty.html Normal file
View file

@ -0,0 +1,219 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Scroll Property component for KUTE.js allows you to animate the vertical scrolling for a target element or window on most browsers.">
<meta name="keywords" content="scroll,vertical scroll,kute.js,animation,javascript animation,tweening engine,animation engine,JavaScript,Native JavaScript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Scroll Property</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<style>
html {scroll-behavior: auto;}
</style>
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li class="active"><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Scroll Property</h2>
<p class="condensed lead">The component that animates the <i>vertical scrolling</i> of a target <b>Element</b> as well as the <b>&lt;window&gt;</b> on most browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">The fully reworked component for <b>vertical scrolling</b> animation is an essential part of <b>KUTE</b>.js.</p>
</div>
<div class="col9 border">
<p class="condensed lead">The KUTE.js <b>Scroll Property</b> component enables animation for the vertical scroll of a target <b>Element</b> or the
<b>&lt;window&gt;</b> on most browsers.</p>
<p>The vertical scrollling animation is a popular choice to spice up the in-page navigation, and most websites use a <i>Back To Top</i> button for
scrolling all the way back to top. For this reason, our component doesn't support horizontal scrolling animation.</p>
<p>The component also uses <b>passive</b> event option for best possible performance along with other improvements like removed the need to use
additional CSS or the use of <b>data-scrolling</b> attribute on the <b>&lt;body&gt;</b> element.</p>
<p>On animation start, the component will lock down all possible pointer events of the animation target to
avoid any unwanted animation glitches.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Example</h3>
<pre><code class="language-javascript">// all websites to top button
KUTE.to(window,{scroll:0}).start()
// scroll to a certain element
KUTE.to(window,{scroll: document.getElementById('myElement').offsetTop }).start()
// scroll to top an overflowing target element
KUTE.to('#myElement',{scroll: 0 }).start()
</code></pre>
<div id="scrollProperty" class="featurettes">
<div class="example-item" style="height:170px; overflow:hidden; max-width: calc(100% - 60px);">
<h4 class="text-dark" style="margin-top:10px">KUTE.js Scroll Property</h4>
<p>Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy
foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive
innovation via workplace diversity and empowerment.</p>
<p>Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal
that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in
real-time will have multiple touchpoints for offshoring.</p>
<p>Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with
additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing
solely on the bottom line.</p>
<h4 class="text-dark">Second Sample Heading</h4>
<p>Podcasting operational change management inside of workflows to establish a framework. Taking seamless key performance indicators
offline to maximise the long tail. Keeping your eye on the ball while performing a deep dive on the start-up mentality to derive
convergence on cross-platform integration.</p>
<p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed
base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.</p>
</div>
<div class="example-buttons"><a class="btn btn-olive" href="javascript:void(0)">Toggle</a></div>
</div>
<div class="featurettes">
<div class="example-item" style="height:170px; overflow:auto; max-width: calc(100% - 80px); scroll-behavior: smooth;">
<h4 id="sample-title" class="text-dark" style="margin-top:10px">scroll-behavior: smooth</h4>
<p>Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy
foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive
innovation via workplace diversity and empowerment.</p>
<p>Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal
that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in
real-time will have multiple touchpoints for offshoring.</p>
<p>Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with
additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing
solely on the bottom line.</p>
<h4 id="sample-title2" class="text-dark">Second Sample Heading</h4>
<p>Podcasting operational change management inside of workflows to establish a framework. Taking seamless key performance indicators
offline to maximise the long tail. Keeping your eye on the ball while performing a deep dive on the start-up mentality to derive
convergence on cross-platform integration.</p>
<p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed
base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.</p>
</div>
<div class="example-buttons">
<a class="btn btn-indigo" onclick="function kickScroll(e){e.preventDefault}" href="#sample-title2">Bottom</a>
</div>
<div class="example-buttons">
<a class="btn btn-olive" onclick="function kickScroll(e){e.preventDefault}" href="#sample-title">Top</a>
</div>
</div>
<p>The above shows a comparison of the <b>Scroll Property</b> component with the <code>scroll-behavior: smooth</code> CSS; while this browser
feature shows excellent performance it lacks the flexibility and support for legacy browsers.</p>
<h3>Notes</h3>
<ul>
<li>The <b>Scroll Property</b> component will lock down any pointer event such as <i>click</i>, <i>touch</i>, or any other event of the target on
animation start to prevent any kind of animation glitches, so make sure to filter your tweens, perhaps you can take a look at the
<a href="./assets/js/scrollProperty.js">scrollProperty.js</a> sample code.</li>
<li>The scroll animation is not as smooth as with transform animations, it has no access at sub-pixel level, but you can play around
with various easing functions and durations to find the best possible outcome.</li>
<li>All pages in this documentation have a <code>&lt;a&gt;Back to top&lt;/a&gt;</code> button at the bottom, just in case you didn't notice, but
only on this page <code>scrollProperty</code> component is used.</li>
<li>The component is only bundled with the <i>demo/src/kute-extra.js</i> file and not in the official build. That is thanks to
<code>scroll-behavior</code>, but you can include this component in your custom builds to enable scrolling for legacy browsers.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scrollProperty.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>

193
shadowProperties.html Normal file
View file

@ -0,0 +1,193 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Shadow Properties component for KUTE.js allows you to create animations for shadow properties on supporting browsers.">
<meta name="keywords" content="textShadow,text-shadow,boxShadow,box-shadow,kute,kute.js,animation,javascript animation,tweening engine,animation engine,JavaScript,Native JavaScript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Shadow Properties</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<style>
.text-example {
margin: 0 0 20px;
font-size: 28px;
line-height: 1.5;
white-space: nowrap;
color: #222
}
</style>
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li class="active"><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Shadow Properties</h2>
<p class="condensed lead">The component that animates shadow properties of a specific target element on most browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate the shadow properties of a target element.</p>
</div>
<div class="col9 border">
<p class='condensed lead'>The KUTE.js <b>Shadow Properties</b> component enables animation for the <b>text-shadow</b> CSS property of text elements
as well as the <b>box-shadow</b> property of any element on most browsers.</p>
<p>The functionality was developed while writing a guide on how to extend KUTE.js a couple of years ago and is now a fully featured component.</p>
<p>The component uses <b>px</b> as unit for the shadow parameters, can animate the color of the shadow and can also handle the <b>inset</b> shadow parameter
of the <b>boxShadow</b> property.</p>
<p>OK let's have a look at a couple of quick examples:</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Box Shadow</h3>
<pre><code class="language-javascript">// tween to a string value
var myBSTween1 = KUTE.to('selector', {boxShadow: '10px 10px #069'}).start();
// or a fromTo with string and array, hex and rgb
var myBSTween2 = KUTE.fromTo(
'selector', // target
{boxShadow: [0, 0, 0, '#069']}, // from
{boxShadow: '5px 5px rgb(0,0,0)'}) // to
.start();
// maybe you want to animate an inset boxShadow?
var myBSTween3 = KUTE.fromTo(
'selector', // target
{boxShadow: [5, 5, 0, '#069', 'inset']}, // from
{boxShadow: '0px 0px rgb(0,0,0)'}) // to
.start();
</code></pre>
<div id="boxShadow" class="featurettes">
<div class="example-item example-box bg-lime"></div>
<div class="example-buttons">
<a class="btn btn-pink" href="javascript:void(0)">Start</a>
</div>
</div>
<h3>Text Shadow</h3>
<pre><code class="language-javascript">// tween to a string value
var myTSTween1 = KUTE.to('selector', {textShadow: '10px 10px #069'}).start();
// or a fromTo with string and array, hex and rgb
var myTSTween2 = KUTE.fromTo(
'selector', // target
{textShadow: [0, 0, 0, '#069']}, // from
{textShadow: '5px 5px rgb(0,0,0)'}) // to
.start();
</code></pre>
<div id="textShadow" class="featurettes">
<div class="text-example">Sample Text</div>
<div class="example-buttons">
<a class="btn btn-orange" href="javascript:void(0)">Start</a>
</div>
</div>
<h3>Notes</h3>
<ul>
<li>The component will NOT handle multiple shadows per target at the same time.</li>
<li>The component features a solid value processing script, it can handle a great deal of combinations of input values.</li>
<li>I highly recommend that you check the <a href="./assets/js/boxShadow.js">boxShadow.js</a> for more insight.</li>
<li>This component is bundled with the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/shadowProperties.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>

908
src/kute-base.js Normal file
View file

@ -0,0 +1,908 @@
/*!
* KUTE.js Base v2.2.2 (http://thednp.github.io/kute.js)
* Copyright 2015-2021 © thednp
* Licensed under MIT (https://github.com/thednp/kute.js/blob/master/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.KUTE = factory());
})(this, (function () { 'use strict';
/**
* The KUTE.js Execution Context
*/
var KEC = {};
var Tweens = [];
var gl0bal;
if (typeof global !== 'undefined') { gl0bal = global; }
else if (typeof window !== 'undefined') { gl0bal = window.self; }
else { gl0bal = {}; }
var globalObject = gl0bal;
// KUTE.js INTERPOLATE FUNCTIONS
// =============================
var interpolate = {};
// schedule property specific function on animation start
// link property update function to KUTE.js execution context
var onStart = {};
// Include a performance.now polyfill.
// source https://github.com/tweenjs/tween.js/blob/master/src/Now.ts
var performanceNow;
// In node.js, use process.hrtime.
// eslint-disable-next-line
// @ts-ignore
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
performanceNow = function () {
// eslint-disable-next-line
// @ts-ignore
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
} else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
// In a browser, use self.performance.now if it is available.
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
performanceNow = self.performance.now.bind(self.performance);
} else if (typeof Date !== 'undefined' && Date.now) {
// Use Date.now if it is available.
performanceNow = Date.now;
} else {
// Otherwise, use 'new Date().getTime()'.
performanceNow = function () { return new Date().getTime(); };
}
var now = performanceNow;
var Time = {};
Time.now = now;
// eslint-disable-next-line import/no-mutable-exports -- impossible to satisfy
var Tick = 0;
/**
*
* @param {number | Date} time
*/
var Ticker = function (time) {
var i = 0;
while (i < Tweens.length) {
if (Tweens[i].update(time)) {
i += 1;
} else {
Tweens.splice(i, 1);
}
}
Tick = requestAnimationFrame(Ticker);
};
// stop requesting animation frame
function stop() {
setTimeout(function () { // re-added for #81
if (!Tweens.length && Tick) {
cancelAnimationFrame(Tick);
Tick = null;
Object.keys(onStart).forEach(function (obj) {
if (typeof (onStart[obj]) === 'function') {
if (KEC[obj]) { delete KEC[obj]; }
} else {
Object.keys(onStart[obj]).forEach(function (prop) {
if (KEC[prop]) { delete KEC[prop]; }
});
}
});
Object.keys(interpolate).forEach(function (i) {
if (KEC[i]) { delete KEC[i]; }
});
}
}, 64);
}
// render update functions
// =======================
var Render = {
Tick: Tick, Ticker: Ticker, Tweens: Tweens, Time: Time,
};
Object.keys(Render).forEach(function (blob) {
if (!KEC[blob]) {
KEC[blob] = blob === 'Time' ? Time.now : Render[blob];
}
});
globalObject._KUTE = KEC;
var defaultOptions = {
duration: 700,
delay: 0,
easing: 'linear',
repeat: 0,
repeatDelay: 0,
yoyo: false,
resetStart: false,
offset: 0,
};
// link properties to interpolate functions
var linkProperty = {};
// schedule property specific function on animation complete
var onComplete = {};
var Objects = {
defaultOptions: defaultOptions,
linkProperty: linkProperty,
onStart: onStart,
onComplete: onComplete,
};
// util - a general object for utils like rgbToHex, processEasing
var Util = {};
var connect = {};
/** @type {KUTE.TweenBase | KUTE.Tween | KUTE.TweenExtra} */
connect.tween = null;
connect.processEasing = null;
// Select Robert Penner's Easing Functions
// updated for ESLint
var Easing = {
/** @type {KUTE.easingFunction} */
linear: function (t) { return t; },
/** @type {KUTE.easingFunction} */
easingQuadraticIn: function (t) { return t * t; },
/** @type {KUTE.easingFunction} */
easingQuadraticOut: function (t) { return t * (2 - t); },
/** @type {KUTE.easingFunction} */
easingQuadraticInOut: function (t) { return (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t); },
/** @type {KUTE.easingFunction} */
easingCubicIn: function (t) { return t * t * t; },
/** @type {KUTE.easingFunction} */
easingCubicOut: function (t0) { var t = t0 - 1; return t * t * t + 1; },
/** @type {KUTE.easingFunction} */
easingCubicInOut: function (t) { return (t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1); },
/** @type {KUTE.easingFunction} */
easingCircularIn: function (t) { return -(Math.sqrt(1 - (t * t)) - 1); },
/** @type {KUTE.easingFunction} */
easingCircularOut: function (t0) { var t = t0 - 1; return Math.sqrt(1 - t * t); },
/** @type {KUTE.easingFunction} */
easingCircularInOut: function (t0) {
var t = t0 * 2;
if (t < 1) { return -0.5 * (Math.sqrt(1 - t * t) - 1); }
t -= 2; return 0.5 * (Math.sqrt(1 - t * t) + 1);
},
/** @type {KUTE.easingFunction} */
easingBackIn: function (t) { var s = 1.70158; return t * t * ((s + 1) * t - s); },
/** @type {KUTE.easingFunction} */
easingBackOut: function (t0) {
var s = 1.70158;
var t = t0 - 1;
return t * t * ((s + 1) * t + s) + 1;
},
/** @type {KUTE.easingFunction} */
easingBackInOut: function (t0) {
var s = 1.70158 * 1.525;
var t = t0 * 2;
if (t < 1) { return 0.5 * (t * t * ((s + 1) * t - s)); }
t -= 2; return 0.5 * (t * t * ((s + 1) * t + s) + 2);
},
};
/**
* Returns a valid `easingFunction`.
*
* @param {KUTE.easingFunction | string} fn function name or constructor name
* @returns {KUTE.easingFunction} a valid easing function
*/
function processEasing(fn) {
if (typeof fn === 'function') {
return fn;
} if (typeof Easing[fn] === 'function') {
return Easing[fn]; // regular Robert Penner Easing Functions
}
return Easing.linear;
}
connect.processEasing = processEasing;
/**
* KUTE.add(Tween)
*
* @param {KUTE.Tween} tw a new tween to add
*/
var add = function (tw) { return Tweens.push(tw); };
/**
* KUTE.remove(Tween)
*
* @param {KUTE.Tween} tw a new tween to add
*/
var remove = function (tw) {
var i = Tweens.indexOf(tw);
if (i !== -1) { Tweens.splice(i, 1); }
};
/**
* KUTE.add(Tween)
*
* @return {KUTE.Tween[]} tw a new tween to add
*/
var getAll = function () { return Tweens; };
/**
* KUTE.removeAll()
*/
var removeAll = function () { Tweens.length = 0; };
// all supported properties
var supportedProperties = {};
/**
* linkInterpolation
* @this {KUTE.Tween}
*/
function linkInterpolation() {
var this$1$1 = this;
// DON'T change
Object.keys(linkProperty).forEach(function (component) {
var componentLink = linkProperty[component];
var componentProps = supportedProperties[component];
Object.keys(componentLink).forEach(function (fnObj) {
if (typeof (componentLink[fnObj]) === 'function' // ATTR, colors, scroll, boxModel, borderRadius
&& Object.keys(this$1$1.valuesEnd).some(function (i) { return (componentProps && componentProps.includes(i))
|| (i === 'attr' && Object.keys(this$1$1.valuesEnd[i]).some(function (j) { return componentProps && componentProps.includes(j); })); })) {
if (!KEC[fnObj]) { KEC[fnObj] = componentLink[fnObj]; }
} else {
Object.keys(this$1$1.valuesEnd).forEach(function (prop) {
var propObject = this$1$1.valuesEnd[prop];
if (propObject instanceof Object) {
Object.keys(propObject).forEach(function (i) {
if (typeof (componentLink[i]) === 'function') { // transformCSS3
if (!KEC[i]) { KEC[i] = componentLink[i]; }
} else {
Object.keys(componentLink[fnObj]).forEach(function (j) {
if (componentLink[i] && typeof (componentLink[i][j]) === 'function') { // transformMatrix
if (!KEC[j]) { KEC[j] = componentLink[i][j]; }
}
});
}
});
}
});
}
});
});
}
var internals = {
add: add,
remove: remove,
getAll: getAll,
removeAll: removeAll,
stop: stop,
linkInterpolation: linkInterpolation,
};
/**
* selector
*
* A selector utility for KUTE.js.
*
* @param {KUTE.selectorType} el target(s) or string selector
* @param {boolean | number} multi when true returns an array/collection of elements
* @returns {Element | Element[] | null}
*/
function selector(el, multi) {
try {
var requestedElem;
var itemsArray;
if (multi) {
itemsArray = el instanceof Array && el.every(function (x) { return x instanceof Element; });
requestedElem = el instanceof HTMLCollection || el instanceof NodeList || itemsArray
? el : document.querySelectorAll(el);
} else {
requestedElem = el instanceof Element || el === window // scroll
? el : document.querySelector(el);
}
return requestedElem;
} catch (e) {
throw TypeError(("KUTE.js - Element(s) not found: " + el + "."));
}
}
/**
* Animation Base Class
*
* Registers components by populating KUTE.js objects and makes sure
* no duplicate component / property is allowed.
*
* This class only registers the minimal amount of component information
* required to enable components animation, which means value processing
* as well as `to()` and `allTo()` methods are not supported.
*/
var AnimationBase = function AnimationBase(Component) {
var ComponentName = Component.component;
// const Objects = { defaultValues, defaultOptions, Interpolate, linkProperty }
var Functions = { onStart: onStart, onComplete: onComplete };
var Category = Component.category;
var Property = Component.property;
// ESLint
this._ = 0;
// set supported category/property
supportedProperties[ComponentName] = Component.properties
|| Component.subProperties || Component.property;
// set additional options
if (Component.defaultOptions) {
// Object.keys(Component.defaultOptions).forEach((op) => {
// defaultOptions[op] = Component.defaultOptions[op];
// });
Object.assign(defaultOptions, Component.defaultOptions);
}
// set functions
if (Component.functions) {
Object.keys(Functions).forEach(function (fn) {
if (fn in Component.functions) {
if (typeof (Component.functions[fn]) === 'function') {
// if (!Functions[fn][ Category||Property ]) {
// Functions[fn][ Category||Property ] = Component.functions[fn];
// }
if (!Functions[fn][ComponentName]) { Functions[fn][ComponentName] = {}; }
if (!Functions[fn][ComponentName][Category || Property]) {
Functions[fn][ComponentName][Category || Property] = Component.functions[fn];
}
} else {
Object.keys(Component.functions[fn]).forEach(function (ofn) {
// if (!Functions[fn][ofn]) Functions[fn][ofn] = Component.functions[fn][ofn];
if (!Functions[fn][ComponentName]) { Functions[fn][ComponentName] = {}; }
if (!Functions[fn][ComponentName][ofn]) {
Functions[fn][ComponentName][ofn] = Component.functions[fn][ofn];
}
});
}
}
});
}
// set interpolate
if (Component.Interpolate) {
Object.keys(Component.Interpolate).forEach(function (fni) {
var compIntObj = Component.Interpolate[fni];
if (typeof (compIntObj) === 'function' && !interpolate[fni]) {
interpolate[fni] = compIntObj;
} else {
Object.keys(compIntObj).forEach(function (sfn) {
if (typeof (compIntObj[sfn]) === 'function' && !interpolate[fni]) {
interpolate[fni] = compIntObj[sfn];
}
});
}
});
linkProperty[ComponentName] = Component.Interpolate;
}
// set component util
if (Component.Util) {
Object.keys(Component.Util).forEach(function (fnu) {
if (!Util[fnu]) { Util[fnu] = Component.Util[fnu]; }
});
}
return { name: ComponentName };
};
/**
* Perspective Interpolation Function.
*
* @param {number} a start value
* @param {number} b end value
* @param {string} u unit
* @param {number} v progress
* @returns {string} the perspective function in string format
*/
function perspective(a, b, u, v) {
// eslint-disable-next-line no-bitwise
return ("perspective(" + (((a + (b - a) * v) * 1000 >> 0) / 1000) + u + ")");
}
/**
* Translate 3D Interpolation Function.
*
* @param {number[]} a start [x,y,z] position
* @param {number[]} b end [x,y,z] position
* @param {string} u unit, usually `px` degrees
* @param {number} v progress
* @returns {string} the interpolated 3D translation string
*/
function translate3d(a, b, u, v) {
var translateArray = [];
for (var ax = 0; ax < 3; ax += 1) {
translateArray[ax] = (a[ax] || b[ax]
// eslint-disable-next-line no-bitwise
? ((a[ax] + (b[ax] - a[ax]) * v) * 1000 >> 0) / 1000 : 0) + u;
}
return ("translate3d(" + (translateArray.join(',')) + ")");
}
/**
* 3D Rotation Interpolation Function.
*
* @param {number} a start [x,y,z] angles
* @param {number} b end [x,y,z] angles
* @param {string} u unit, usually `deg` degrees
* @param {number} v progress
* @returns {string} the interpolated 3D rotation string
*/
function rotate3d(a, b, u, v) {
var rotateStr = '';
// eslint-disable-next-line no-bitwise
rotateStr += a[0] || b[0] ? ("rotateX(" + (((a[0] + (b[0] - a[0]) * v) * 1000 >> 0) / 1000) + u + ")") : '';
// eslint-disable-next-line no-bitwise
rotateStr += a[1] || b[1] ? ("rotateY(" + (((a[1] + (b[1] - a[1]) * v) * 1000 >> 0) / 1000) + u + ")") : '';
// eslint-disable-next-line no-bitwise
rotateStr += a[2] || b[2] ? ("rotateZ(" + (((a[2] + (b[2] - a[2]) * v) * 1000 >> 0) / 1000) + u + ")") : '';
return rotateStr;
}
/**
* Translate 2D Interpolation Function.
*
* @param {number[]} a start [x,y] position
* @param {number[]} b end [x,y] position
* @param {string} u unit, usually `px` degrees
* @param {number} v progress
* @returns {string} the interpolated 2D translation string
*/
function translate(a, b, u, v) {
var translateArray = [];
// eslint-disable-next-line no-bitwise
translateArray[0] = (a[0] === b[0] ? b[0] : ((a[0] + (b[0] - a[0]) * v) * 1000 >> 0) / 1000) + u;
// eslint-disable-next-line no-bitwise
translateArray[1] = a[1] || b[1] ? ((a[1] === b[1] ? b[1] : ((a[1] + (b[1] - a[1]) * v) * 1000 >> 0) / 1000) + u) : '0';
return ("translate(" + (translateArray.join(',')) + ")");
}
/**
* 2D Rotation Interpolation Function.
*
* @param {number} a start angle
* @param {number} b end angle
* @param {string} u unit, usually `deg` degrees
* @param {number} v progress
* @returns {string} the interpolated rotation
*/
function rotate(a, b, u, v) {
// eslint-disable-next-line no-bitwise
return ("rotate(" + (((a + (b - a) * v) * 1000 >> 0) / 1000) + u + ")");
}
/**
* Scale Interpolation Function.
*
* @param {number} a start scale
* @param {number} b end scale
* @param {number} v progress
* @returns {string} the interpolated scale
*/
function scale(a, b, v) {
// eslint-disable-next-line no-bitwise
return ("scale(" + (((a + (b - a) * v) * 1000 >> 0) / 1000) + ")");
}
/**
* Skew Interpolation Function.
*
* @param {number} a start {x,y} angles
* @param {number} b end {x,y} angles
* @param {string} u unit, usually `deg` degrees
* @param {number} v progress
* @returns {string} the interpolated string value of skew(s)
*/
function skew(a, b, u, v) {
var skewArray = [];
// eslint-disable-next-line no-bitwise
skewArray[0] = (a[0] === b[0] ? b[0] : ((a[0] + (b[0] - a[0]) * v) * 1000 >> 0) / 1000) + u;
// eslint-disable-next-line no-bitwise
skewArray[1] = a[1] || b[1] ? ((a[1] === b[1] ? b[1] : ((a[1] + (b[1] - a[1]) * v) * 1000 >> 0) / 1000) + u) : '0';
return ("skew(" + (skewArray.join(',')) + ")");
}
// Component Functions
/**
* Sets the property update function.
* * same to svgTransform, htmlAttributes
* @param {string} tweenProp the property name
*/
function onStartTransform(tweenProp) {
if (!KEC[tweenProp] && this.valuesEnd[tweenProp]) {
KEC[tweenProp] = function (elem, a, b, v) {
// eslint-disable-next-line no-param-reassign
elem.style[tweenProp] = (a.perspective || b.perspective ? perspective(a.perspective, b.perspective, 'px', v) : '') // one side might be 0
+ (a.translate3d ? translate3d(a.translate3d, b.translate3d, 'px', v) : '') // array [x,y,z]
+ (a.rotate3d ? rotate3d(a.rotate3d, b.rotate3d, 'deg', v) : '') // array [x,y,z]
+ (a.skew ? skew(a.skew, b.skew, 'deg', v) : '') // array [x,y]
+ (a.scale || b.scale ? scale(a.scale, b.scale, v) : ''); // one side might be 0
};
}
}
// Base Component
var TransformFunctionsBase = {
component: 'baseTransform',
property: 'transform',
functions: { onStart: onStartTransform },
Interpolate: {
perspective: perspective,
translate3d: translate3d,
rotate3d: rotate3d,
translate: translate,
rotate: rotate,
scale: scale,
skew: skew,
},
};
/**
* Numbers Interpolation Function.
*
* @param {number} a start value
* @param {number} b end value
* @param {number} v progress
* @returns {number} the interpolated number
*/
function numbers(a, b, v) {
var A = +a;
var B = b - a;
// a = +a; b -= a;
return A + B * v;
}
// Component Functions
/**
* Sets the update function for the property.
* @param {string} tweenProp the property name
*/
function boxModelOnStart(tweenProp) {
if (tweenProp in this.valuesEnd && !KEC[tweenProp]) {
KEC[tweenProp] = function (elem, a, b, v) {
/* eslint-disable no-param-reassign -- impossible to satisfy */
/* eslint-disable no-bitwise -- impossible to satisfy */
elem.style[tweenProp] = (v > 0.99 || v < 0.01
? ((numbers(a, b, v) * 10) >> 0) / 10
: (numbers(a, b, v)) >> 0) + "px";
/* eslint-enable no-bitwise */
/* eslint-enable no-param-reassign */
};
}
}
// Component Base Props
var baseBoxProps = ['top', 'left', 'width', 'height'];
var baseBoxOnStart = {};
baseBoxProps.forEach(function (x) { baseBoxOnStart[x] = boxModelOnStart; });
// Component Base
var BoxModelBase = {
component: 'baseBoxModel',
category: 'boxModel',
properties: baseBoxProps,
Interpolate: { numbers: numbers },
functions: { onStart: baseBoxOnStart },
};
/* opacityProperty = {
property: 'opacity',
defaultValue: 1,
interpolators: {numbers},
functions = { prepareStart, prepareProperty, onStart }
} */
// Component Functions
/**
* Sets the property update function.
* @param {string} tweenProp the property name
*/
function onStartOpacity(tweenProp/* , value */) {
// opacity could be 0 sometimes, we need to check regardless
if (tweenProp in this.valuesEnd && !KEC[tweenProp]) {
KEC[tweenProp] = function (elem, a, b, v) {
/* eslint-disable */
elem.style[tweenProp] = ((numbers(a, b, v) * 1000) >> 0) / 1000;
/* eslint-enable */
};
}
}
// Base Component
var OpacityPropertyBase = {
component: 'baseOpacity',
property: 'opacity',
// defaultValue: 1,
Interpolate: { numbers: numbers },
functions: { onStart: onStartOpacity },
};
// import {baseCrossBrowserMove} from '../components/crossBrowserMove'
// support for kute-base ends here
var Components = {
Transform: new AnimationBase(TransformFunctionsBase),
BoxModel: new AnimationBase(BoxModelBase),
Opacity: new AnimationBase(OpacityPropertyBase),
};
function queueStart() {
var this$1$1 = this;
// fire onStart actions
Object.keys(onStart).forEach(function (obj) {
if (typeof (onStart[obj]) === 'function') {
onStart[obj].call(this$1$1, obj); // easing functions
} else {
Object.keys(onStart[obj]).forEach(function (prop) {
onStart[obj][prop].call(this$1$1, prop);
});
}
});
// add interpolations
linkInterpolation.call(this);
}
/**
* The `TweenBase` constructor creates a new `Tween` object
* for a single `HTMLElement` and returns it.
*
* `TweenBase` is meant to be used with pre-processed values.
*/
var TweenBase = function TweenBase(targetElement, startObject, endObject, opsObject) {
var this$1$1 = this;
// element animation is applied to
this.element = targetElement;
/** @type {boolean} */
this.playing = false;
/** @type {number?} */
this._startTime = null;
/** @type {boolean} */
this._startFired = false;
// type is set via KUTE.tweenProps
this.valuesEnd = endObject;
this.valuesStart = startObject;
// OPTIONS
var options = opsObject || {};
// internal option to process inline/computed style at start instead of init
// used by to() method and expects object : {} / false
this._resetStart = options.resetStart || 0;
// you can only set a core easing function as default
/** @type {KUTE.easingOption} */
this._easing = typeof (options.easing) === 'function' ? options.easing : connect.processEasing(options.easing);
/** @type {number} */
this._duration = options.duration || defaultOptions.duration; // duration option | default
/** @type {number} */
this._delay = options.delay || defaultOptions.delay; // delay option | default
// set other options
Object.keys(options).forEach(function (op) {
var internalOption = "_" + op;
if (!(internalOption in this$1$1)) { this$1$1[internalOption] = options[op]; }
});
// callbacks should not be set as undefined
// this._onStart = options.onStart
// this._onUpdate = options.onUpdate
// this._onStop = options.onStop
// this._onComplete = options.onComplete
// queue the easing
var easingFnName = this._easing.name;
if (!onStart[easingFnName]) {
onStart[easingFnName] = function easingFn(prop) {
if (!KEC[prop] && prop === this._easing.name) { KEC[prop] = this._easing; }
};
}
return this;
};
/**
* Starts tweening
* @param {number?} time the tween start time
* @returns {TweenBase} this instance
*/
TweenBase.prototype.start = function start (time) {
// now it's a good time to start
add(this);
this.playing = true;
this._startTime = typeof time !== 'undefined' ? time : KEC.Time();
this._startTime += this._delay;
if (!this._startFired) {
if (this._onStart) {
this._onStart.call(this);
}
queueStart.call(this);
this._startFired = true;
}
if (!Tick) { Ticker(); }
return this;
};
/**
* Stops tweening
* @returns {TweenBase} this instance
*/
TweenBase.prototype.stop = function stop () {
if (this.playing) {
remove(this);
this.playing = false;
if (this._onStop) {
this._onStop.call(this);
}
this.close();
}
return this;
};
/**
* Trigger internal completion callbacks.
*/
TweenBase.prototype.close = function close () {
var this$1$1 = this;
// scroll|transformMatrix need this
Object.keys(onComplete).forEach(function (component) {
Object.keys(onComplete[component]).forEach(function (toClose) {
onComplete[component][toClose].call(this$1$1, toClose);
});
});
// when all animations are finished, stop ticking after ~3 frames
this._startFired = false;
stop.call(this);
};
/**
* Schedule another tween instance to start once this one completes.
* @param {KUTE.chainOption} args the tween animation start time
* @returns {TweenBase} this instance
*/
TweenBase.prototype.chain = function chain (args) {
this._chain = [];
this._chain = args.length ? args : this._chain.concat(args);
return this;
};
/**
* Stop tweening the chained tween instances.
*/
TweenBase.prototype.stopChainedTweens = function stopChainedTweens () {
if (this._chain && this._chain.length) { this._chain.forEach(function (tw) { return tw.stop(); }); }
};
/**
* Update the tween on each tick.
* @param {number} time the tick time
* @returns {boolean} this instance
*/
TweenBase.prototype.update = function update (time) {
var this$1$1 = this;
var T = time !== undefined ? time : KEC.Time();
var elapsed;
if (T < this._startTime && this.playing) { return true; }
elapsed = (T - this._startTime) / this._duration;
elapsed = (this._duration === 0 || elapsed > 1) ? 1 : elapsed;
// calculate progress
var progress = this._easing(elapsed);
// render the update
Object.keys(this.valuesEnd).forEach(function (tweenProp) {
KEC[tweenProp](this$1$1.element,
this$1$1.valuesStart[tweenProp],
this$1$1.valuesEnd[tweenProp],
progress);
});
// fire the updateCallback
if (this._onUpdate) {
this._onUpdate.call(this);
}
if (elapsed === 1) {
// fire the complete callback
if (this._onComplete) {
this._onComplete.call(this);
}
// now we're sure no animation is running
this.playing = false;
// stop ticking when finished
this.close();
// start animating chained tweens
if (this._chain !== undefined && this._chain.length) {
this._chain.map(function (tw) { return tw.start(); });
}
return false;
}
return true;
};
// Update Tween Interface
connect.tween = TweenBase;
var TweenConstructor = connect.tween;
/**
* The `KUTE.fromTo()` static method returns a new Tween object
* for a single `HTMLElement` at a given state.
*
* @param {Element} element target element
* @param {KUTE.tweenProps} startObject
* @param {KUTE.tweenProps} endObject
* @param {KUTE.tweenOptions} optionsObj tween options
* @returns {KUTE.Tween} the resulting Tween object
*/
function fromTo(element, startObject, endObject, optionsObj) {
var options = optionsObj || {};
return new TweenConstructor(selector(element), startObject, endObject, options);
}
var version = "2.2.2";
// @ts-ignore
/**
* A global namespace for library version.
* @type {string}
*/
var Version = version;
var indexBase = {
Animation: AnimationBase,
Components: Components,
Tween: TweenBase,
fromTo: fromTo,
Objects: Objects,
Easing: Easing,
Util: Util,
Render: Render,
Interpolate: interpolate,
Internals: internals,
Selector: selector,
Version: Version,
};
return indexBase;
}));

2
src/kute-base.min.js vendored Normal file

File diff suppressed because one or more lines are too long

5731
src/kute-extra.js Normal file

File diff suppressed because it is too large Load diff

2
src/kute-extra.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
src/kute.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3
src/polyfill-legacy.min.js vendored Normal file
View file

@ -0,0 +1,3 @@
// KUTE.js Polyfill v2.1.1-alpha1 | 2021 © thednp | MIT-License
"use strict";
var r,t,n,e;if(Function.prototype.bind||(Function.prototype.bind=function(){var r=Array.prototype.slice,t=this,n=arguments[0],e=r.call(arguments,1);if("function"!=typeof t)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");return function(){var o=e.concat(r.call(arguments));return t.apply(n,o)}}),Array.from||(Array.from=(r=Object.prototype.toString,t=function(t){return"function"==typeof t||"[object Function]"===r.call(t)},n=Math.pow(2,53)-1,e=function(r){var t=function(r){var t=Number(r);return isNaN(t)?0:0!==t&&isFinite(t)?(t>0?1:-1)*Math.floor(Math.abs(t)):t}(r);return Math.min(Math.max(t,0),n)},function(r){var n=this,o=Object(r);if(null==r)throw new TypeError("Array.from requires an array-like object - not null or undefined");var i,a=arguments.length>1?arguments[1]:void 0;if(void 0!==a){if(!t(a))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(i=arguments[2])}for(var u,f=e(o.length),p=t(n)?Object(new n(f)):new Array(f),c=0;c<f;)u=o[c],p[c]=a?void 0===i?a(u,c):a.call(i,u,c):u,c+=1;return p.length=f,p})),Array.prototype.map||(Array.prototype.map=function(r){var t,n,e;if(null==this)throw new TypeError("this is null or not defined");var o=Object(this),i=o.length>>>0;if("function"!=typeof r)throw new TypeError(r+" is not a function");for(arguments.length>1&&(t=arguments[1]),n=new Array(i),e=0;e<i;){var a,u;e in o&&(a=o[e],u=r.call(t,a,e,o),n[e]=u),e++}return n}),Array.prototype.some||(Array.prototype.some=function(r,t){if(null==this)throw new TypeError("Array.prototype.some called on null or undefined");if("function"!=typeof r)throw new TypeError;for(var n=Object(this),e=n.length>>>0,o=0;o<e;o++)if(o in n&&r.call(t,n[o],o,n))return!0;return!1}),Array.prototype.every||(Array.prototype.every=function(r,t){var n,e;if(null==this)throw new TypeError("this is null or not defined");var o=Object(this),i=o.length>>>0;if("function"!=typeof r&&"[object Function]"!==Object.prototype.toString.call(r))throw new TypeError;for(arguments.length>1&&(n=t),e=0;e<i;){var a;if(e in o)if(a=o[e],!(n?r.call(n,a,e,o):r(a,e,o)))return!1;e++}return!0}),Array.prototype.includes||(Array.prototype.includes=function(r){var t=Object(this),n=parseInt(t.length)||0;if(0===n)return!1;var e,o,i=parseInt(arguments[1])||0;for(i>=0?e=i:(e=n+i)<0&&(e=0);e<n;){if(r===(o=t[e])||r!=r&&o!=o)return!0;e++}return!1}),Array.prototype.flat||Object.defineProperty(Array.prototype,"flat",{configurable:!0,value:function r(){var t=isNaN(arguments[0])?1:Number(arguments[0]);return t?Array.prototype.reduce.call(this,(function(n,e){return Array.isArray(e)?n.push.apply(n,r.call(e,t-1)):n.push(e),n}),[]):Array.prototype.slice.call(this)},writable:!0}),String.prototype.includes||(String.prototype.includes=function(r,t){if(r instanceof RegExp)throw TypeError("first argument must not be a RegExp");return void 0===t&&(t=0),-1!==this.indexOf(r,t)}),Date.now||(Date.now=function(){return(new Date).getTime()}),self.performance||(self.performance={}),!self.performance.now){var o=Date.now();self.performance.now=function(){return Date.now()-o}}if(!window.requestAnimationFrame){var i=Date.now();window.requestAnimationFrame=function(r){if("function"!=typeof r)throw new TypeError(r+"is not a function");var t=Date.now(),n=16+i-t;return n<0&&(n=0),i=t,setTimeout((function(){i=Date.now(),r(performance.now())}),n)},window.cancelAnimationFrame=function(r){clearTimeout(r)}}

3
src/polyfill.min.js vendored Normal file
View file

@ -0,0 +1,3 @@
// KUTE.js Polyfill v2.1.1-alpha1 | 2021 © thednp | MIT-License
"use strict";
var r,t,e,n;Array.from||(Array.from=(r=Object.prototype.toString,t=function(t){return"function"==typeof t||"[object Function]"===r.call(t)},e=Math.pow(2,53)-1,n=function(r){var t=function(r){var t=Number(r);return isNaN(t)?0:0!==t&&isFinite(t)?(t>0?1:-1)*Math.floor(Math.abs(t)):t}(r);return Math.min(Math.max(t,0),e)},function(r){var e=this,i=Object(r);if(null==r)throw new TypeError("Array.from requires an array-like object - not null or undefined");var o,a=arguments.length>1?arguments[1]:void 0;if(void 0!==a){if(!t(a))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(o=arguments[2])}for(var u,f=n(i.length),p=t(e)?Object(new e(f)):new Array(f),c=0;c<f;)u=i[c],p[c]=a?void 0===o?a(u,c):a.call(o,u,c):u,c+=1;return p.length=f,p})),Array.prototype.flat||Object.defineProperty(Array.prototype,"flat",{configurable:!0,value:function r(){var t=isNaN(arguments[0])?1:Number(arguments[0]);return t?Array.prototype.reduce.call(this,(function(e,n){return Array.isArray(n)?e.push.apply(e,r.call(n,t-1)):e.push(n),e}),[]):Array.prototype.slice.call(this)},writable:!0}),Array.prototype.includes||(Array.prototype.includes=function(r){var t=Object(this),e=parseInt(t.length)||0;if(0===e)return!1;var n,i,o=parseInt(arguments[1])||0;for(o>=0?n=o:(n=e+o)<0&&(n=0);n<e;){if(r===(i=t[n])||r!=r&&i!=i)return!0;n++}return!1}),String.prototype.includes||(String.prototype.includes=function(r,t){if(r instanceof RegExp)throw TypeError("first argument must not be a RegExp");return void 0===t&&(t=0),-1!==this.indexOf(r,t)}),Number.isFinite||(Number.isFinite=function(r){return"number"==typeof r&&isFinite(r)}),Number.isInteger||(Number.isInteger=function(r){return"number"==typeof r&&isFinite(r)&&Math.floor(r)===r}),Number.isNaN||(Number.isNaN=function(r){return"number"==typeof r&&r!=r});

369
svgCubicMorph.html Normal file
View file

@ -0,0 +1,369 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The SVG Cubic Morph component for KUTE.js enables animation for the d presentation attribute of path and glyph shapes.">
<meta name="keywords" content="svg morph,svg cubic morph,cross-browser svg morph,svg animation,kute,kute.js,tweening engine,animation engine,animation,javascript animation,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js SVG Cubic Morph</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li class="active"><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">SVG Cubic Morph</h2>
<p class="condensed lead">The component that also covers <i>SVG morphing</i>, with similar functionality as for the <a href="svgMorph.html">SVG Morph</a> component, but with a different
implementation for value processing and animation setup.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate SVG paths with <b>cubic-bezier</b> path commands and improved performance.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>SVG Cubic Morph</b> component enables animation for the <b>d</b> (description) presentation attribute and is the latest in all the SVG
components.</p>
<p>The component will process paths and out of the box will provide the closest possible interpolation by default. It also implements a series of solutions from
<a href="https://github.com/paperjs/paper.js/">Paper.js</a> to determine paths draw direction and automatically reverse one of them for most accurate presentation and as a result
the previously featured options <kbd>reverseFirstPath</kbd> and <kbd>reverseSecondPath</kbd> have been deprecated.</p>
<p>The main difference with the <a href="svgMorph.html">SVG Morph</a> component is the fact that this components is converting all path commands to <i>cubicBezierTo</i>, giving it
the upper hand over the original morph component in many regards. While the other component will spend time to process the path data and create polygons, this component should
deliver the animation faster and using considerably less power.</p>
<p>All path processing is powered by our <a href="https://github.com/thednp/svg-path-commander">SVGPathCommander</a> starting KUTE.js version 2.0.14, which aims to modernize and
improve the path processing and enable transition from closed to and from un-closed shapes.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Basic Example</h3>
<p>The first morphing animation example is a transition from a rectangle into a star, just like for the other component.</p>
<pre><code class="language-markup">&lt;svg id="morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
&lt;path id="rectangle" class="bg-lime" d="M38.01,5.653h526.531c17.905,0,32.422,14.516,32.422,32.422v526.531 c0,17.905-14.517,32.422-32.422,32.422H38.01c-17.906,0-32.422-14.517-32.422-32.422V38.075C5.588,20.169,20.104,5.653,38.01,5.653z"/>
&lt;path id="star" style="visibility:hidden" d="M301.113,12.011l99.25,179.996l201.864,38.778L461.706,380.808 l25.508,203.958l-186.101-87.287L115.01,584.766l25.507-203.958L0,230.785l201.86-38.778L301.113,12.011"/>
&lt;/svg>
</code></pre>
<p>Now we can apply both <code>.to()</code> and <code>fromTo()</code> methods:</p>
<pre><code class="language-javascript">// the fromTo() method
var tween = KUTE.fromTo('#rectangle', {path: '#rectangle' }, { path: '#star' }).start();
// OR
// the to() method will take the path's d attribute value and use it as start value
var tween = KUTE.to('#rectangle', { path: '#star' }).start();
// OR
// simply pass in a valid path string without the need to have two paths in your SVG
var tween = KUTE.to('#rectangle', { path: 'M301.113,12.011l99.25,179.996l201.864,38.778L461.706,380.808l25.508,203.958l-186.101-87.287L115.01,584.766l25.507-203.958L0,230.785l201.86-38.778L301.113,12.011' }).start();
</code></pre>
<p>By default, the component will process the paths as authored and deliver its best without any option required, like for the first red rectangle below which applies to any of the above invocations:</p>
<div class="featurettes">
<svg class="example-box-model example-box" id="morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="rectangle" class="bg-olive" d="M559,597.4H43.6c-21,0-38-17-38-38V44c0-21,17-38,38-38H559c21,0,38,17,38,38v515.4 C597,580.4,580,597.4,559,597.4z"/>
<path id="star" style="visibility:hidden" d="M301.113,12.011l99.25,179.996l201.864,38.778L461.706,380.808 l25.508,203.958l-186.101-87.287L115.01,584.766l25.507-203.958L0,230.785l201.86-38.778L301.113,12.011z"/>
</svg>
<svg class="example-box-model example-box" id="morph-example2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="rectangle2" class="bg-blue" d="M559,597.4H302.1H43.6c-21,0-38-17-38-38V300V44c0-21,17-38,38-38H300h259c21,0,38,17,38,38
v257.7v257.7C597,580.4,580,597.4,559,597.4"/>
<path id="star2" style="visibility:hidden" d="M302.1,17.9c16,29,81.4,147.7,98.2,178.2c13.7,2.6,47.3,9.1,83.5,16c46.1,8.8,96.5,18.5,116.4,22.3
c-25.1,26.7-117.8,125.7-139.1,148.5c1.1,8.5,23.8,190.5,25.3,202c-36-16.9-158.8-74.5-184.2-86.4c-28.5,13.4-151.3,71-184.2,86.4
c0.4-3.2,23.4-187.6,25.2-201.9C122.8,361.3,30,262.3,4,234.5c17.3-3.3,59.5-11.4,101.3-19.4c41.4-7.9,82.5-15.8,98.5-18.9
C221,165.1,286.5,46.2,302.1,17.9"/>
</svg>
<div class="example-buttons">
<a id="morphBtn" class="btn btn-green" href="javascript:void(0)">Start</a>
</div>
</div>
<p><b>Some takeaways:</b></p>
<ul>
<li>The <b class="text-olive">olive shape</b> and its corresponding end shape are both the originals, un-edited shapes.</li>
<li>The <b class="text-blue">blue shape</b> and its corresponding end shape have been edited by removing their <code>Z</code> path commands and by adding additional curve points using a vector graphics editor to match
the amount of points in both shapes.</li>
</ul>
<p>In this example we focus on experimentation to discover ways to optimize the morph animation so that the points travel optimal distance. Keep in mind that the <code>Z</code> path command is actually a shorthand
for <code>L</code> (line path command), sometimes it's required to close the shape, however the path processing tools will remove it or replace it when converting path segments to <code>C</code> cubic-bezier.</p>
<p>Each morph animation as well as each pair of shapes can have its own quirks. You can use the technique on your shapes to optimize the animation to your style. Chris Coyier wrote
<a href="https://css-tricks.com/svg-shape-morphing-works/">an excelent article</a> in which he explains the terminology and workflow on how SVG morphing animation works with simple examples.</p>
<h3>Morphing Unclosed Shapes To Closed Shapes</h3>
<p>The next set of morphing animations is a transition from a line into a circle and showcases the component's behavior when both shapes are closed (they have the <code>Z</code> path command) or one or another is not,
but first let's create the necessary markup and scripting:</p>
<pre><code class="language-markup">&lt;svg id="morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
&lt;path id="line" fill="transparent" stroke="orange" stroke-linejoin="round" stroke-width="10" d="M10 300 L580 300"/>
&lt;path id="star" style="visibility:hidden" d="M10,300a290,290 0 1,0 580,0a290,290 0 1,0 -580,0z"/>
&lt;/svg>
</code></pre>
<pre><code class="language-javascript">// the fromTo() method
var tween = KUTE.fromTo('#line', {path: '#line' }, { path: '#circle' }).start();
// OR
// the to() method will take the path's d attribute value and use it as start value
var tween = KUTE.to('#line', { path: '#circle' }).start();
</code></pre>
<div class="featurettes">
<svg class="example-box-model example-box" id="morph-example-closed" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="line" fill="transparent" stroke="#FF5722" stroke-linejoin="round" stroke-width="15" d="M10 300 L580 300z"/>
<path id="circle" style="visibility:hidden" d="M10,300a290,290 0 1,1 580,0a290,290 0 1,1 -580,0z"/>
</svg>
<svg class="example-box-model example-box" id="morph-example-closed1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="line1" fill="transparent" stroke="#4CAF50" stroke-linejoin="round" stroke-width="15" d="M10 300 L580 300"/>
<path id="circle1" style="visibility:hidden" d="M10,300a290,290 0 1,1 580,0a290,290 0 1,1 -580,0z"/>
</svg>
<div class="example-buttons">
<a id="morphBtnClosed" class="btn btn-green" href="javascript:void(0)">Start</a>
</div>
</div>
<p>As you can see, the functionality of this component is very different from the <a href="svgMorph.html">svgMorph</a> component in the sense that it will
morph shapes as authored. If you replay the above animations, here are a few takeaways:</p>
<ul>
<li>the <b class="text-orange">orange</b> line is <b>closed</b>, this makes the last <code>Z</code> path command behave like a regular line;</li>
<li>the <b class="text-green">green</b> line is <b>not closed</b>, and the presentation looks quite different compared to the other example as well as
the other <a href="./cubicMorph.html">cubicMorph</a> component.</li>
</ul>
<p>This is the visual presentation you can expect with this component. Keep in mind that stroke attributes like <code>stroke-linejoin</code> such can have
a small impact on your animation, particularly on start and end points.</p>
<h3>Subpath Example</h3>
<p>In other cases, you may want to morph paths that have subpaths. Let's have a look at the following SVG:</p>
<pre><code class="language-markup">&lt;svg id="multi-morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
&lt;path id="w1" d="M412.23 511.914c-47.708-24.518-94.086-36.958-137.88-36.958-5.956 0-11.952 0.18-17.948 0.708-55.88 4.624-106.922 19.368-139.75 30.828-8.708 3.198-17.634 6.576-26.83 10.306l-89.822 311.394c61.702-22.832 116.292-33.938 166.27-33.938 80.846 0 139.528 30.208 187.992 61.304 22.962-77.918 78.044-266.09 94.482-322.324-11.95-7.284-24.076-14.57-36.514-21.32z
m116.118 79.156l-90.446 314.148c26.832 15.372 117.098 64.05 186.212 64.05 55.792 0 118.252-14.296 190.834-43.792l86.356-301.976c-58.632 18.922-114.876 28.52-167.464 28.52-95.95 0-163.114-31.098-205.492-60.95z
m-235.526-222.28c77.118 0.798 134.152 30.208 181.416 60.502l92.752-317.344c-19.546-11.196-70.806-39.094-107.858-48.6-24.386-5.684-50.02-8.616-77.204-8.616-51.796 0.976-108.388 13.946-172.888 39.8l-88.44 310.596c64.808-24.436 120.644-36.34 172.086-36.34 0.046 0.002 0.136 0.002 0.136 0.002z
m731.178-170.666c-58.814 22.832-116.208 34.466-171.028 34.466-91.686 0-159.292-31.802-203.094-62.366l-91.95 318.236c61.746 39.708 128.29 59.878 198.122 59.878 56.948 0 115.94-13.68 175.462-40.688l-0.182-2.222 3.734-0.886 88.936-306.418z"/>
&lt;path id="w2" d="M0 187.396l367.2-50.6v354.798h-367.2v-304.2z
m0 649.2v-299.798h367.2v350.398z
m407.6 56v-355.798h488.4v423.2z
m0-761.2l488.4-67.4v427.6h-488.4v-360.2z"/>
&lt;/svg>
</code></pre>
<p>Similar to the <a href="svgMorph.html">svgMorph</a> component, this component doesn't provide multipath processing so we should split the sub-paths into multiple <b>&lt;path&gt;</b> shapes, analyze and associate them
in a way that corresponding shapes are close and their points travel the least possible distance.</p>
<p>Now since we've worked with these paths before, the first example below showcases how the <b>svgCubicMorph</b> component handles it by default. The following example was made possible by editing the shapes with a vector
graphics editor. The last example showcases a creative use of association between starting and end shapes. Let's have a look:</p>
<div class="featurettes">
<svg class="example-box-model example-box" id="multi-morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 550 550">
<path id="w11" fill="#e91b1f" d="M206.115,255.957c-23.854-12.259-47.043-18.479-68.94-18.479c-2.978,0-5.976,0.09-8.974,0.354 c-27.94,2.312-53.461,9.684-69.875,15.414c-4.354,1.599-8.817,3.288-13.415,5.152L0,414.096 c30.851-11.416,58.146-16.969,83.135-16.969c40.423,0,69.764,15.104,93.996,30.652c11.481-38.959,39.022-133.045,47.241-161.162 C218.397,262.975,212.334,259.332,206.115,255.957z"/>
<path id="w12" fill="#FF5722" d="M264.174,295.535l-45.223,157.074c13.416,7.686,58.549,32.024,93.105,32.024 c27.896,0,59.127-7.147,95.417-21.896l43.179-150.988c-29.316,9.461-57.438,14.26-83.732,14.26 C318.945,326.01,285.363,310.461,264.174,295.535z"/>
<path id="w13" fill="#4CAF50" d="M146.411,184.395c38.559,0.399,67.076,15.104,90.708,30.251l46.376-158.672c-9.772-5.598-35.403-19.547-53.929-24.3c-12.193-2.842-25.01-4.308-38.602-4.308c-25.898,0.488-54.194,6.973-86.444,19.9 L60.3,202.564c32.404-12.218,60.322-18.17,86.043-18.17C146.366,184.395,146.411,184.395,146.411,184.395L146.411,184.395z"/>
<path id="w14" fill="#2196F3" d="M512,99.062c-29.407,11.416-58.104,17.233-85.514,17.233c-45.844,0-79.646-15.901-101.547-31.183L278.964,244.23 c30.873,19.854,64.146,29.939,99.062,29.939c28.474,0,57.97-6.84,87.73-20.344l-0.091-1.111l1.867-0.443L512,99.062z"/>
<path id="w21" style="visibility:hidden" d="M192 471.918l-191.844-26.297-0.010-157.621h191.854z"/>
<path id="w22" style="visibility:hidden" d="M479.999 288l-0.063 224-255.936-36.008v-187.992z"/>
<path id="w23" style="visibility:hidden" d="M0.175 256l-0.175-156.037 192-26.072v182.109z"/>
<path id="w24" style="visibility:hidden" d="M224 69.241l255.936-37.241v224h-255.936z"/>
</svg>
<svg class="example-box-model example-box" id="multi-morph-example1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 550 550">
<path id="w111" fill="#e91b1f" d="M128.2,237.8c-44.1,0-78.7,18.7-83.3,20.6L0,414.1c30.9-11.4,58.1-17,83.1-17
c40.4,0,69.8,15.1,94,30.7c11.5-39,39-133,47.2-161.2C205.7,254.8,176.7,237.8,128.2,237.8z"/>
<path id="w121" fill="#FF5722" d="M264.2,295.5L219,452.6c13.4,7.7,58.5,32,93.1,32c27.9,0,59.1-7.1,95.4-21.9l43.2-151
c-29.3,9.5-57.4,14.3-83.7,14.3C318.9,326,285.4,310.5,264.2,295.5z"/>
<path id="w131" fill="#4CAF50" d="M146.4,184.4c38.6,0.4,67.1,15.1,90.7,30.3L283.5,56c-9.8-5.6-41.4-27.7-92.5-28.6
c-25.9,0.5-54.2,7-86.4,19.9L60.3,202.6C92.7,190.3,120.6,184.4,146.4,184.4C146.4,184.4,146.4,184.4,146.4,184.4L146.4,184.4z"/>
<path id="w141" fill="#2196F3" d="M512,99.1c-29.4,11.4-58.1,17.2-85.5,17.2c-45.8,0-79.6-15.9-101.5-31.2l-46,159.1
c30.9,19.9,64.1,29.9,99.1,29.9c43.1,0,89.5-21.9,89.5-21.9L512,99.1z"/>
<path id="w211" style="visibility:hidden" d="M192,470.9L0.2,444.6l0-98.7l0-58.9h107.8H192L192,470.9z"/>
<path id="w221" style="visibility:hidden" d="M480,288l-0.1,224l-138.7-19.5L224,476V288h128H480z"/>
<path id="w231" style="visibility:hidden" d="M0.2,256L0,100l99.5-13.5L192,73.9V256H87H0.2z"/>
<path id="w241" style="visibility:hidden" d="M224,69.2l147.7-21.5L479.9,32v224H352H224V69.2z"/>
</svg>
<svg class="example-box-model example-box" id="multi-morph-example2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 550 550">
<path id="s11" fill="#e91b1f" d="M128.2,237.8c-44.1,0-78.7,18.7-83.3,20.6L0,414.1c30.9-11.4,58.1-17,83.1-17
c40.4,0,69.8,15.1,94,30.7c11.5-39,39-133,47.2-161.2C205.7,254.8,176.7,237.8,128.2,237.8z"/>
<path id="s12" fill="#FF5722" d="M264.2,295.5L219,452.6c13.4,7.7,58.5,32,93.1,32c27.9,0,59.1-7.1,95.4-21.9l43.2-151
c-29.3,9.5-57.4,14.4-83.7,14.3C310.6,325.9,276,303.9,264.2,295.5z"/>
<path id="s13" fill="#4CAF50" d="M146.4,184.4c38.6,0.4,67.1,15.1,90.7,30.3L283.5,56c-6.6-3.7-45.7-28.6-92.5-28.6
c-25.9,0.5-54.2,7-86.4,19.9L60.3,202.6C92.7,190.3,120.6,184.4,146.4,184.4z"/>
<path id="s14" fill="#2196F3" d="M512,99.1c-29.4,11.4-58.1,17.2-85.5,17.2c-45.8,0-79.6-15.9-101.5-31.2l-46,159.1
c30.9,19.9,64.1,29.9,99.1,29.9c43.1,0,89.5-21.9,89.5-21.9L512,99.1z"/>
<path id="s21" style="visibility:hidden" d="M192,471.9L0.2,445.6V288h87.3h52.3H192V471.9z"/>
<path id="s22" style="visibility:hidden" d="M479.999 288l-0.063 224-255.936-36.008v-187.992z"/>
<path id="s23" style="visibility:hidden" d="M0.2,256L0,100l88.7-12.1l103.3-14V256H0.2z"/>
<path id="s24" style="visibility:hidden" d="M224,69.2L479.9,32v224H354.7h-69.4H224V69.2z"/>
</svg>
<div class="example-buttons">
<a id="multiMorphBtn" class="btn btn-indigo" href="javascript:void(0)">Start</a>
</div>
</div>
<p>Make sure to check the markup here as well as the <a href="assets/js/svgCubicMorph.js" target="_blank">svgCubicMorph.js</a> for a full code review.</p>
<h3>Intersecting Paths Example</h3>
<p>The same preparation apply here, however the outcome is a bit different with cubic-bezier path commands, as shown in the first example. For the next two examples, the shapes have been edited for a better outcome.
Let's have a look:</p>
<div class="featurettes">
<svg class="example-box-model example-box" id="complex-morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 513">
<defs>
<mask id="symbol">
<rect width="100%" height="100%" fill="#fff"></rect>
<path id="symbol-left" fill="#000" d="M155.889 333.394h-55.632c-3.351 0-5.854-1.504-7.271-3.792-1.467-2.379-1.542-5.464 0-8.534l59.11-104.313c0.063-0.114 0.063-0.19 0-0.316l-37.615-65.116c-1.556-3.098-1.783-6.157-0.316-8.534 1.417-2.301 4.235-3.477 7.586-3.477h55.632c8.535 0 12.72 5.499 15.489 10.431 0 0 38.020 66.33 38.249 66.696-2.252 3.97-60.059 106.21-60.059 106.21-2.844 5.131-6.852 10.745-15.173 10.745z"></path>
<path id="symbol-left-clone" fill="#000" d="M155.889 333.394h-55.632c-3.351 0-5.854-1.504-7.271-3.792-1.467-2.379-1.542-5.464 0-8.534l59.11-104.313c0.063-0.114 0.063-0.19 0-0.316l-37.615-65.116c-1.556-3.098-1.783-6.157-0.316-8.534 1.417-2.301 4.235-3.477 7.586-3.477h55.632c8.535 0 12.72 5.499 15.489 10.431 0 0 38.020 66.33 38.249 66.696-2.252 3.97-60.059 106.21-60.059 106.21-2.844 5.131-6.852 10.745-15.173 10.745z"></path>
<path id="symbol-right" fill="#000" d="M418.956 75.269l-123.176 217.79c-0.075 0.115-0.075 0.255 0 0.367l78.431 143.295c1.556 3.084 1.593 6.221 0.113 8.597-1.415 2.288-4.033 3.552-7.383 3.552h-55.57c-8.522 0-12.783-5.663-15.54-10.596 0 0-78.848-144.646-79.050-145.023 3.944-6.98 123.797-219.523 123.797-219.523 2.984-5.362 6.587-10.596 14.894-10.596h56.203c3.351 0 5.981 1.265 7.396 3.553 1.466 2.376 1.428 5.511-0.115 8.584z"></path>
<path id="eye-right" style="visibility: hidden;" d="M352 128c17.673 0 32 21.49 32 48s-14.327 48-32 48-32-21.49-32-48 14.327-48 32-48z"></path>
<path id="eye-left" style="visibility: hidden;" d="M176 156.031c29.823 0 51 11.166 51 28.641 0 3.699 1.906 21.497-0.085 24.797-7.414-12.288-27.405-21.094-50.915-21.094s-43.501 8.806-50.915 21.094c-1.991-3.3-0.085-21.098-0.085-24.797 0-17.475 21.177-28.641 51-28.641z"></path>
<path id="mouth" style="visibility: hidden;" d="M250.172 416c-59.621 0-111.929-32.14-141.446-80.476 35.205 27.53 97.267 32.905 162.644 19.989 70.124-13.853 124.555-45.771 144.227-88.297-10.827 83.98-80.759 148.784-165.425 148.784z"></path>
</mask>
</defs>
<path id="rectangle-container" fill="#2196F3" mask="url(#symbol)" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
<path id="circle-container" style="visibility: hidden;" d="M0,256a256,256 0 1,0 512,0a256,256 0 1,0 -512,0z"></path>
</svg>
<svg class="example-box-model example-box" id="complex-morph-example2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 513">
<defs>
<mask id="symbol2">
<rect width="100%" height="100%" fill="#fff"></rect>
<path id="symbol-left2" fill="#000" d="M155.889 333.394h-55.632c-3.351 0-5.854-1.504-7.271-3.792-1.467-2.379-1.542-5.464 0-8.534l59.11-104.313c0.063-0.114 0.063-0.19 0-0.316l-37.615-65.116c-1.556-3.098-1.783-6.157-0.316-8.534 1.417-2.301 4.235-3.477 7.586-3.477h55.632c8.535 0 12.72 5.499 15.489 10.431 0 0 38.020 66.33 38.249 66.696-2.252 3.97-60.059 106.21-60.059 106.21-2.844 5.131-6.852 10.745-15.173 10.745"></path>
<path id="sample-shape2" fill="#000" d="M250 450 L250 450"></path>
<path id="symbol-right2" fill="#000" d="M418.956 75.269l-123.176 217.79c-0.075 0.115-0.075 0.255 0 0.367l78.431 143.295c1.556 3.084 1.593 6.221 0.113 8.597-1.415 2.288-4.033 3.552-7.383 3.552h-55.57c-8.522 0-12.783-5.663-15.54-10.596 0 0-78.848-144.646-79.050-145.023 3.944-6.98 123.797-219.523 123.797-219.523 2.984-5.362 6.587-10.596 14.894-10.596h56.203c3.351 0 5.981 1.265 7.396 3.553 1.466 2.376 1.428 5.511-0.115 8.584"></path>
<path id="eye-right2" style="visibility: hidden;" d="M352,128c2.6,0,5,0.5,7.4,1.3c2.3,0.8,4.5,2,6.6,3.6c10.6,7.8,18,24.2,18,43.1c0,16.2-5.3,30.5-13.5,39.2
c-3.1,3.3-6.6,5.8-10.5,7.3c-2.6,1-5.3,1.5-8,1.5c-4,0-7.8-1.1-11.3-3.1c-2.7-1.6-5.3-3.7-7.6-6.2c-7.9-8.7-13-22.8-13-38.7
c0-19.2,7.5-35.7,18.4-43.4c1.9-1.4,4-2.5,6.1-3.2C346.9,128.5,349.4,128,352,128"></path>
<path id="eye-left2" style="visibility: hidden;" d="M176,156c10.4,0,19.7,1.4,27.5,3.9c14.5,4.7,23.5,13.4,23.5,24.8c0,3.7,1.9,21.5-0.1,24.8
c-3.3-5.5-9.2-10.3-16.7-13.9c-5.6-2.7-12.2-4.8-19.4-6c-4.7-0.8-9.6-1.2-14.7-1.2c-8.9,0-17.3,1.3-24.7,3.5
c-12.2,3.7-21.6,10-26.3,17.6c-2-3.3-0.1-21.1-0.1-24.8c0-11.3,8.8-19.9,23-24.6c3.7-1.2,7.8-2.2,12.2-2.9
C165.1,156.4,170.4,156,176,156"></path>
<path id="mouth2" style="visibility: hidden;" d="M250.172 416c-59.621 0-111.929-32.14-141.446-80.476 35.205 27.53 97.267 32.905 162.644 19.989 70.124-13.853 124.555-45.771 144.227-88.297-10.827 83.98-80.759 148.784-165.425 148.784"></path>
</mask>
</defs>
<path id="rectangle-container2" fill="#e91b1f" mask="url(#symbol2)" d="M426.7,0H85.3C38.4,0,0,38.4,0,85.3v341.3c0,47,38.4,85.3,85.3,85.3h341.3
c46.9,0,85.3-38.4,85.3-85.3V85.3C512,38.4,473.6,0,426.7,0"></path>
<path id="circle-container2" style="visibility: hidden;" d="M0,256c0,100.9,59.8,165.3,72,177.9c9.1,9.4,34.7,34.4,75.6,53.5c50.6,23.7,95,24.6,108.4,24.6
c10.9,0,61.3-0.9,117.6-30c42.1-21.8,67.4-49,73.1-55.3c64-70.6,65.3-157,65.3-170.7c0-18.9-2.1-96.7-61-165.9
c-8.6-10.2-37.3-42-86-65C313.6,0.9,268.6,0,256,0c-11,0-61.8,0.8-118.2,30.1C97.1,51.3,72.4,77.3,66.6,83.7C1.3,154.7,0,243,0,256"></path>
</svg>
<div class="example-buttons">
<a id="compliMorphBtn" class="btn btn-green" href="javascript:void(0)">Start</a>
</div>
</div>
<p>So the technique involves creating <code>&lt;mask></code> elements, splitting multipath shapes into multiple <code>&lt;path></code> shapes, matching the amount of starting and ending shapes by duplicating
an existing shape or by sampling another shape for the same purpose, editing shapes for more accurate point-to-point animation, as well as various options to optimize the visual presentation.</p>
<p>That's it, you now mastered the <b>SVG Cubic Morph</b> component.</p>
<h3>Notes</h3>
<ul>
<li>Starting with KUTE.js version 2.0.14 the component implements <a href="https://github.com/thednp/svg-path-commander">SVGPathCommander</a> for path processing, solving previous issues with over-optimized
path strings among other issues. You can try the <a href="https://thednp.github.io/svg-path-commander/">SVGPathCommander demo page</a> to prepare your path strings.</li>
<li>Since animation works only with <code>path</code> <b>SVGElement</b>s, you might need a <a href="https://thednp.github.io/svg-path-commander/convert.html" target="_blank">shapeToPath</a> utility.</li>
<li>Both SVG morph components will always animate first sub-path from both starting and ending shapes, and for any case hopefully this demo will guide you in mastering the technique.</li>
<li>In some cases your start and end shapes don't have a very close size, you can use your vector graphics editor of choice or <a href="https://github.com/Waest/SVGPathConverter">SVGPathCommander</a>
to apply a scale transformation to your shapes' path commands.</li>
<li>The <b>SVG Cubic Morph</b> component WILL NOT animate paths with sub-paths as of KUTE.js version 2.0.14, hopefuly this guide will help you break the ice.</li>
<li>Compared to <a href="svgMorph.html">svgMorph</a>, this component can be more memory efficient, as we're dealing with significantly less interpolation points which translates directly
into better performance and the shapes never show any sign of "polygon artifacts".</li>
<li>Some shapes can be broken even if the browser won't throw any error so make sure you double check with your SVG editor of choice.</li>
<li>In some cases the duplicated curve bezier points don't produce the best morphing animation, but you can edit the shapes and add your own additional path commands between the existing ones
so that the component will work with actual points that travel less and produce a much more "natural" morphing animation.</li>
<li>The edited shapes can be found in the <b>assets/img</b> folder of this demo, make sure to check them out.</li>
<li>Make sure to check the <a href="assets/js/svgCubicMorph.js" target="_blank">svgCubicMorph.js</a> for a full code review.</li>
<li>This component is affected by the the <code>fill-rule="evenodd"</code> specific SVG attribute, you must make sure you check your shapes in that regard as well.</li>
<li>This component is bundled with the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.js"></script>
<script src="./assets/js/svgCubicMorph.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>

165
svgDraw.html Normal file
View file

@ -0,0 +1,165 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The SVG Draw component for KUTE.js enables animation for the stroke-dasharray and stroke-dashoffset.">
<meta name="keywords" content="svg draw,svg,stroke-dasharray,stroke-dashoffset,svg animation,kute,kute.js,animation,javascript animation,tweening engine,animation engine,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js SVG Draw</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li class="active"><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">SVG Draw</h2>
<p class="condensed lead">The component that animates the stroke of any <b>SVGElement</b> and updates the <i>style</i> attribute of the target.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate the stroke for most <b>SVGElement</b> shapes, with a very easy to use coordinates system.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>SVG Draw</b> component enables animation for the <b>stroke-dasharray</b> and <b>stroke-dashoffset</b> properties via CSS style.</p>
<p>The component uses the SVG standard <b>.getTotalLength()</b> method for <b>&lt;path></b> shapes, while for the other shapes it uses some helper methods to calculate the values
required for animation.</p>
<p>It can work with <b>&lt;path></b>, <b>&lt;glyph></b>, <b>&lt;circle></b>, <b>&lt;ellipse></b>, <b>&lt;rect></b>, <b>&lt;line></b>, <b>&lt;polyline></b> and <b>&lt;polygon></b>
shapes. It uses a very simple to use coordinates system so you can set up animations right away.</p>
<p>As you will see in the examples below, there is alot of flexibility in terms of input values.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Examples</h3>
<pre><code class="language-javascript">// draw the stroke from 0-10% to 90-100%
var tween1 = KUTE.fromTo('selector1',{draw:'0% 10%'}, {draw:'90% 100%'});
// draw the stroke from zero to full path length
var tween2 = KUTE.fromTo('selector1',{draw:'0% 0%'}, {draw:'0% 100%'});
// draw the stroke from full length to 50%
var tween3 = KUTE.fromTo('selector1',{draw:'0% 100%'}, {draw:'50% 50%'});
</code></pre>
<p>Based on the above sample code, let's see some animation going on:</p>
<div class="featurettes">
<svg style="width:600px" class="example-box-model example-box" id="draw-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2046 513">
<path fill="none" style="stroke:#2196F3; stroke-width:20; stroke-dashoffset: -724.077px; stroke-dasharray: 0px, 1448.15px" id="drawSVG" d="M432 64l-240 240-112-112-80 80 192 192 320-320z"/>
<circle fill="none" r="220" cx="780" cy="255" style="stroke:#4CAF50; stroke-width:20; stroke-dashoffset: -690.8px; stroke-dasharray: 0px, 1381.6px" id="drawSVG1"/>
<ellipse fill="none" rx="220" ry="100" cx="780" cy="255" style="stroke:#55c55a; stroke-width:20; stroke-dashoffset: -690.8px; stroke-dasharray: 0px, 1381.6px" id="drawSVG11"/>
<rect fill="none" width="430" height="430" x="1070" y="30" style="stroke:#FF5722; stroke-width:20; stroke-dashoffset: -860px; stroke-dasharray: 0px, 1720px" id="drawSVG2"/>
<polygon fill="none" points="1579,307 1623,117 1801,33 1978,117 2022,307 1899,460 1702,460 1579,307" style="stroke:#673AB7; stroke-width:20; stroke-dashoffset: -860px; stroke-dasharray: 0px, 1720px" id="drawSVG3"/>
</svg>
<div class="example-buttons">
<a id="drawBtn" class="btn btn-blue" href="javascript:void(0)">Start</a>
</div>
</div>
<h3>Notes</h3>
<ul>
<li>Remember that the <code class="bg-indigo">draw</code> property also accepts absolute values, eg. <code>draw: '0 150'</code>; the <code>.to()</code> method takes <code>0% 100%</code>
as start value for your tweens when <code>stroke-dasharray</code> and <code>stroke-dashoffset</code> properties are not set.</li>
<li>Sometimes the <code>stroke</code> on some shapes may not completely close, you might want to consider values outside the [0-100] percent range.</li>
<li>The <b>SVG Draw</b> component can be combined with any other SVG based component to create even more complex animations for SVG elements.</li>
<li>This component is bundled with the default distribution <i>kute.js</i> and the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/svgDraw.js"></script>
</body>
</html>

427
svgMorph.html Normal file
View file

@ -0,0 +1,427 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The SVG Morph component for KUTE.js enables animation for the d presentation attribute of path and glyph shapes.">
<meta name="keywords" content="svg morph,cross-browser svg morph,svg animation,kute,kute.js,tweening engine,animation engine,animation,javascript animation,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js SVG Morph</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li class="active"><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">SVG Morph</h2>
<p class="condensed lead">The component that covers <i>SVG morphing</i>, an animation that's close to impossible with CSS3 transitions and not supported in some legacy browsers. It comes packed
with tools and options to improve performance and visual presentation.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns margin-bottom">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate SVG paths with <b>line-to</b> path commands, improve visual presentation and optimize performance on any device.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>SVG Morph</b> component enables animation for the <b>d</b> (description) presentation attribute and is one of the most important in all the
SVG components.</p>
<p>It only works with inline <b>SVGPathElement</b> shapes and the presentation is always the same when shapes are closed or not (their <b>d</b> attribute ends with <b>Z</b> path command).
On initialization or animation start, depending on the chosen KUTE.js method, it will <a href="http://phrogz.net/SVG/convert_path_to_polygon.xhtml" target="_blank">sample a number of points</a>
along the two paths based on a default / given sample size and will create two arrays of coordinates we need for interpolation.</p>
<p>This component was originally inspired by a <a href="http://bl.ocks.org/mbostock/3081153" target="_blank">D3.js path morphing example</a> and now implements a set of
<a href="https://github.com/d3/d3-polygon">D3 polygon</a> geometric operations and other functionalities from <a href="https://github.com/veltman/flubber">flubber</a> to
produce the coordinates for a very consistent morphing animation.</p>
<p>While in some cases you might be able to create SVG morphing animations via CSS3 <i>transition</i>, this component was developed to provide various solutions for working
with complex shapes, bringing convenience, resources and clarity to one of the most complex types of animation.</p>
<p>All path processing is powered by our <a href="https://github.com/thednp/svg-path-commander">SVGPathCommander</a> starting KUTE.js version 2.0.14, which aims to modernize and
improve the path processing and enable you to prepare your path strings in Node.js.</p>
</div>
</div>
<div class="columns">
<div class="col3">
<h3 class="border text-right">Options</h3>
<p class="condensed text-right">The easy way to optimize morphing animation for every device in a single option.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The <b>SVG Morph</b> component comes with a simple option to optimize animation on every device. Previous versions used to have additional options required for processing,
but now the component will handle all that for you.</p>
<ul>
<li><kbd>morphPrecision: <b class='text-olive'>Number</b></kbd> option allows you to set the sampling size of the shapes in pixels. The lesser value the better visual but the more power consumption
and less performance. The default value is <b>10</b> but the processing functions will determine the best possible outcome depending on shapes' path commands.</li>
</ul>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Basic Example</h3>
<p>The first morphing animation example is a transition from a rectangle into a star, the first path is the start shape and the second is the end shape; we can also add some ID to the
paths so we can easily target them with our code.</p>
<pre><code class="language-markup">&lt;svg id="morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
&lt;path id="rectangle" d="M38.01,5.653h526.531c17.905,0,32.422,14.516,32.422,32.422v526.531 c0,17.905-14.517,32.422-32.422,32.422H38.01c-17.906,0-32.422-14.517-32.422-32.422V38.075C5.588,20.169,20.104,5.653,38.01,5.653z"/>
&lt;path id="star" style="visibility:hidden" d="M301.113,12.011l99.25,179.996l201.864,38.778L461.706,380.808 l25.508,203.958l-186.101-87.287L115.01,584.766l25.507-203.958L0,230.785l201.86-38.778L301.113,12.011"/>
&lt;/svg>
</code></pre>
<p>Now we can apply both <code>.to()</code> and <code>fromTo()</code> methods:</p>
<pre><code class="language-javascript">// the fromTo() method
var tween = KUTE.fromTo('#rectangle', {path: '#rectangle' }, { path: '#star' }).start();
// OR
// the to() method will take the path's d attribute value and use it as start value
var tween = KUTE.to('#rectangle', { path: '#star' }).start();
// OR
// simply pass in a valid path string without the need to have two paths in your SVG
var tween = KUTE.to('#rectangle', { path: 'M301.113,12.011l99.25,179.996l201.864,38.778L461.706,380.808l25.508,203.958l-186.101-87.287L115.01,584.766l25.507-203.958L0,230.785l201.86-38.778L301.113,12.011' }).start();
</code></pre>
<p>For all the above tween objects the animation should look like this:</p>
<div class="featurettes">
<svg class="example-box-model example-box" id="morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="rectangle" class="bg-red" d="M38.01,5.653h526.531c17.905,0,32.422,14.516,32.422,32.422v526.531
c0,17.905-14.517,32.422-32.422,32.422H38.01c-17.906,0-32.422-14.517-32.422-32.422V38.075C5.588,20.169,20.104,5.653,38.01,5.653z"/>
<path id="star" style="visibility:hidden" d="M301.113,12.011l99.25,179.996l201.864,38.778L461.706,380.808
l25.508,203.958l-186.101-87.287L115.01,584.766l25.507-203.958L0,230.785l201.86-38.778L301.113,12.011"/>
</svg>
<div class="example-buttons">
<a id="morphBtn" class="btn btn-green" href="javascript:void(0)">Start</a>
</div>
</div>
<p>That's it, let move on to the next example.</p>
<h3>Morphing Unclosed Shapes To Closed Shapes</h3>
<p>The next morphing animation example is a transition from a line into a circle and this example showcases the component's behavior when one of the paths is not closed (it doesn't have the <i>Z</i> path command),
while the other is closed. In all cases, the component will always consider shapes to be closed, so let's have a look at the example:</p>
<pre><code class="language-markup">&lt;svg id="morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
&lt;path id="line" fill="transparent" stroke="orange" stroke-linejoin="round" stroke-width="10" d="M10 300L590 300"/>
&lt;path id="circle" style="visibility:hidden" d="M10,300a290,290 0 1,0 580,0a290,290 0 1,0 -580,0z"/>
&lt;/svg>
</code></pre>
<p>Now we can apply both <code>.to()</code> and <code>fromTo()</code> methods:</p>
<pre><code class="language-javascript">// the fromTo() method
var tween = KUTE.fromTo('#line', {path: '#line' }, { path: '#circle' }).start();
// OR
// the to() method will take the path's d attribute value and use it as start value
var tween = KUTE.to('#line', { path: '#circle' }).start();
</code></pre>
<div class="featurettes">
<svg class="example-box-model example-box" id="morph-example-closed" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="line" fill="transparent" stroke="#FF5722" stroke-linejoin="round" stroke-width="15" d="M10 300L590 300Z"/>
<path id="circle" style="visibility:hidden" d="M10,300a290,290 0 1,0 580,0a290,290 0 1,0 -580,0z"/>
</svg>
<svg class="example-box-model example-box" id="morph-example-closed1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="line1" fill="transparent" stroke="#4CAF50" stroke-linejoin="round" stroke-width="15" d="M10 300L590 300"/>
<path id="circle1" style="visibility:hidden" d="M10,300a290,290 0 1,0 580,0a290,290 0 1,0 -580,0"/>
</svg>
<div class="example-buttons">
<a id="morphBtnClosed" class="btn btn-green" href="javascript:void(0)">Start</a>
</div>
</div>
<p>The functionality of this component is different from the <a href="svgCubicMorph.html">svgCubicMorph</a> component in the sense that it will animate the shapes as if they are both and always closed.
In the above example, the orange line is closed while the green line is not, and the animation is the same.</p>
<h3>Polygon Paths</h3>
<p>When your paths are only <code>lineto</code>, <code>vertical-lineto</code> and <code>horizontal-lineto</code> based shapes (the <code>d</code> attribute consists of only <code>L</code>, <code>V</code> and
<code>H</code> path commands), the <b>SVG Morph</b> component will work differently from previous versions, it will sample points as for any other non-polygon shapes. In this case you can set a higher
<b>morphPrecision</b> value to optimize performance.</p>
<pre><code class="language-javascript">// let's morph a triangle into a star
var tween1 = KUTE.to('#triangle', { path: '#star' }).start();
// or same path into a square
var tween2 = KUTE.to('#triangle', { path: '#square' }).start();
</code></pre>
<div class="featurettes">
<svg class="example-box-model example-box" id="morph-example2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="triangle" fill="#673AB7" d="M301.113,12.011L576.715,584.766L25.508,584.766L301.113,12.011z"/>
<path id="square" style="visibility:hidden" d="M25.508,12.011 L576.715,12.011 L576.715,584.766 L25.508,584.766 L25.508,12.011 z"/>
<path id="square2" style="visibility:hidden" d="M25.508,12.011 H576.715 V584.766 H25.508 V12.011z"/>
<path id="cat" style="visibility:hidden" d="M519.8,118.6C518.4,90.8,483.3,78,460,82.5c-51.1,9.7-59.4,67.2-48.3,109.4c5.4,20.5,15.1,42.7,13.6,64.3
c-1.3,19.5-7.8,39.2-20.7,54.1c1-0.1,2.2-0.3,3.2-0.4c-1,0.1-2.2,0.3-3.2,0.4c-12.9,2-25.3,7.4-29.6,9.6
c-0.9-13.3-1.8-24.5-2.3-31.9c-0.4-10.3-0.8-18.6-1.1-23.9c-1-12.6-15.9-25.3-28.2-33.7c-8.8-6-16.5-9.8-16.5-9.8
c13.8-10.2,19.8-17.6,21.6-23.9c2.3-8,4.3-35.1,4.3-35.1s1.1-6,1.1-15.2c0-11.6-2-22.6-5.7-32.9h0.1c0,0,25.4-45.8,14.7-60.1
c-8.9-11.7-46.3,16.7-46.3,16.7c-16.3-12.6-36.9-20.2-59.1-20.2c-6,0-11.9,0.5-17.7,1.7c0,0-7.4-41.3-27.3-39.7
c-19.8,1.7-29.3,72.8-29.3,72.8l0.1,0.1c-8.3,9.9-14.7,21.6-18.4,34.3c0,0-11.2,26.4-10.3,42.7c0.9,16.2,15.9,31.2,25.6,42.3
l18.9,19.1c0,0,2.8,3.1,6.9,6.9c-0.4,0.3-3.1,1.5-7,3.8c-11.1,6.4-31.5,20.5-36,41.5c-0.4,1.9-0.8,4-1,6.1
c-1.7,12.8-1.4,30.1-0.4,46.6c-5.9-4.1-25.5-15.8-40.3-4.3c-0.6,0.5-1.1,0.9-1.8,1.4c-16.5,13.9-25.4,34.4-25.4,53.8
c0,9.7,3.7,29.1,12,50.4c1,2.8,2.3,5.6,3.6,8.4c4.6,10.3,10.2,20.8,17.2,30.6c6.8,9.7,14.8,18.6,24.1,26c0,0-24.2,13.8-33,32.7
s-6.6,28.1,3.3,29.7c10.1,1.7,57.1-21.8,57.1-21.8c-0.6,2.9-1.5,6.1-2.6,9.6c-5.7,9.7-12.8,22.2-7.3,31.4c1.8,2.9,4.8,5.6,9.8,7.7
c20.8,8.8,41.2,2.3,50.8-8.4c2.9-3.2,4.8-6.6,5.6-10.3c1.1-6.1,1-19.3,0.5-34.3c0,0,39.5,9.9,74.9-4c2.9,21.4,5.5,38.8,6.1,43.2
c0.1,0.9,0.4,1.7,0.6,2.4c2,4.5,9.9,17.5,34.8,14.5c12.6-1.5,19.4-7.8,22.8-12.8c1.1-1.7,1.9-3.4,2.2-5.4c0.1-1.1,0.1-2.4-0.1-3.6
c-0.8-1.8-1.5-4.1-2.3-6.8c-3.1-8.5-7.7-21.6-10.7-33h0.1c0,0,1.3,0.3,3.4,0.8c11.7,2.8,50.3,11.5,53.1,9.3
c3.3-2.4,5.7-10.6,2.6-24.2c-3.8-16.5-38.5-24.7-38.5-24.7s3.7-4.8,9.2-12.5c14.2-19.8,40.4-58.3,46.4-80.4
c7.7-27.9,9.3-58.7-4.2-74.9c20.3-37.8,27.5-78.3,15.1-120c-5.4-18-21.7-63.1,0.9-75.9c8.9-5,25.9-8.4,30.1,4.7
c0,0-7.8,8.7-9.2,14.4c-1.3,5.9-1.9,16.2,14,18.1C502.4,162.3,521.4,150.6,519.8,118.6z"/>
<path id="square3" style="visibility:hidden" d="M25.508,12.011 L576.715,12.011 V584.766 L25.508,584.766 V12.011 z"/>
<path id="star2" style="visibility:hidden" d="M301.113,12.011l99.25,179.996l201.864,38.778L461.706,380.808
l25.508,203.958l-186.101-87.287L115.01,584.766l25.507-203.958L0,230.785l201.86-38.778L301.113,12.011z"/>
</svg>
<div class="example-buttons">
<a id="morphBtn2" class="btn btn-green" href="javascript:void(0)">Start</a>
</div>
</div>
<p>Did you catch the cat?</p>
<h3>Subpath Example</h3>
<p>In other cases, you may want to morph paths that have subpaths. Let's have a look at the following paths:</p>
<pre><code class="language-markup">&lt;svg id="multi-morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
&lt;path id="w1" d="M412.23 511.914c-47.708-24.518-94.086-36.958-137.88-36.958-5.956 0-11.952 0.18-17.948 0.708-55.88 4.624-106.922 19.368-139.75 30.828-8.708 3.198-17.634 6.576-26.83 10.306l-89.822 311.394c61.702-22.832 116.292-33.938 166.27-33.938 80.846 0 139.528 30.208 187.992 61.304 22.962-77.918 78.044-266.09 94.482-322.324-11.95-7.284-24.076-14.57-36.514-21.32z
m116.118 79.156l-90.446 314.148c26.832 15.372 117.098 64.05 186.212 64.05 55.792 0 118.252-14.296 190.834-43.792l86.356-301.976c-58.632 18.922-114.876 28.52-167.464 28.52-95.95 0-163.114-31.098-205.492-60.95z
m-235.526-222.28c77.118 0.798 134.152 30.208 181.416 60.502l92.752-317.344c-19.546-11.196-70.806-39.094-107.858-48.6-24.386-5.684-50.02-8.616-77.204-8.616-51.796 0.976-108.388 13.946-172.888 39.8l-88.44 310.596c64.808-24.436 120.644-36.34 172.086-36.34 0.046 0.002 0.136 0.002 0.136 0.002z
m731.178-170.666c-58.814 22.832-116.208 34.466-171.028 34.466-91.686 0-159.292-31.802-203.094-62.366l-91.95 318.236c61.746 39.708 128.29 59.878 198.122 59.878 56.948 0 115.94-13.68 175.462-40.688l-0.182-2.222 3.734-0.886 88.936-306.418z"/>
&lt;path id="w2" d="M0 187.396l367.2-50.6v354.798h-367.2v-304.2z
m0 649.2v-299.798h367.2v350.398z
m407.6 56v-355.798h488.4v423.2z
m0-761.2l488.4-67.4v427.6h-488.4v-360.2z"/>
&lt;/svg>
</code></pre>
<p>As you can see, both these paths have subpaths, and this component will only animate the first subpath from both paths. To animate them all there are a few easy steps required in preparation for
the animation, so here's a quick guide:</p>
<ol>
<li>Use the <a href="https://thednp.github.io/svg-path-commander/">SVGPathCommander demo page</a> to split your path string into multiple sub-path strings. It's <b>important</b> to do this to avoid
inconsistencies with shapes having relative sub-path commands. You can also use the utility to reverse paths if required.</li>
<li>Create a new <b>&lt;path&gt;</b> shape for each sub-path string from <b>M</b> to <b>Z</b> path commands. See the sample code below.</li>
<li>Give the new paths an <b>id="uniqueID"</b> attribute so you can target them easily. You could use relevant namespace to help you better understand positioning. EG: <b>id="square-top-left"</b>
or <b>id="left-eye"</b></li>
<li>In the browser console inspect with your mouse all paths from both starting and ending shapes and determine which shapes should morph to which. The idea is to produce a morphing animation
where points from each shape travel the least possible distance, however this is where you can get creative, as shown in one of the examples below.</li>
<li>If the number of the starting and ending shapes are not equal, you can consider either duplicating one of the subpath shapes close to it's corresponding subpath shape or creating a sample
shape close to the corresponding subpath shape.</li>
<li>Update the <b>id</b> attribute for all starting and ending shapes to match positions and make it easier to work with the tween objects.</li>
<li>Optional: set a <b>fill</b> attribute for each new shape if you like, normally you coulnd't have done it with the original paths.</li>
<li>Create your tween objects and get to animating and tweaking.</li>
</ol>
<p>For our example here, this is the end result markup for the shapes to be used for morphing animation:</p>
<pre><code class="language-markup">&lt;svg id="multi-morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 550 550">
&lt;path id="w11" d="M206.115,255.957c-23.854-12.259-47.043-18.479-68.94-18.479c-2.978,0-5.976,0.09-8.974,0.354 c-27.94,2.312-53.461,9.684-69.875,15.414c-4.354,1.599-8.817,3.288-13.415,5.152L0,414.096 c30.851-11.416,58.146-16.969,83.135-16.969c40.423,0,69.764,15.104,93.996,30.652c11.481-38.959,39.022-133.045,47.241-161.162 C218.397,262.975,212.334,259.332,206.115,255.957z"/>
&lt;path id="w12" d="M264.174,295.535l-45.223,157.074c13.416,7.686,58.549,32.024,93.105,32.024 c27.896,0,59.127-7.147,95.417-21.896l43.179-150.988c-29.316,9.461-57.438,14.26-83.732,14.26 C318.945,326.01,285.363,310.461,264.174,295.535z"/>
&lt;path id="w13" d="M146.411,184.395c38.559,0.399,67.076,15.104,90.708,30.251l46.376-158.672c-9.772-5.598-35.403-19.547-53.929-24.3c-12.193-2.842-25.01-4.308-38.602-4.308c-25.898,0.488-54.194,6.973-86.444,19.9 L60.3,202.564c32.404-12.218,60.322-18.17,86.043-18.17C146.366,184.395,146.411,184.395,146.411,184.395L146.411,184.395z"/>
&lt;path id="w14" d="M512,99.062c-29.407,11.416-58.104,17.233-85.514,17.233c-45.844,0-79.646-15.901-101.547-31.183L278.964,244.23 c30.873,19.854,64.146,29.939,99.062,29.939c28.474,0,57.97-6.84,87.73-20.344l-0.091-1.111l1.867-0.443L512,99.062z"/>
&lt;path id="w21" style="visibility:hidden" d="M192 471.918l-191.844-26.297-0.010-157.621h191.854z"/>
&lt;path id="w22" style="visibility:hidden" d="M479.999 288l-0.063 224-255.936-36.008v-187.992z"/>
&lt;path id="w23" style="visibility:hidden" d="M0.175 256l-0.175-156.037 192-26.072v182.109z"/>
&lt;path id="w24" style="visibility:hidden" d="M224 69.241l255.936-37.241v224h-255.936z"/>
&lt;/svg>
</code></pre>
<p>The graphic on the left side of the below example is exactly for the above markup, no option needed out of the box nearly perfect animation, while the right side example showcases a different or
perhaps more creative example of this morph animation:</p>
<div class="featurettes">
<svg class="example-box-model example-box" id="multi-morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 550 550">
<path id="w11" fill="#e91b1f" d="M206.115,255.957c-23.854-12.259-47.043-18.479-68.94-18.479c-2.978,0-5.976,0.09-8.974,0.354 c-27.94,2.312-53.461,9.684-69.875,15.414c-4.354,1.599-8.817,3.288-13.415,5.152L0,414.096 c30.851-11.416,58.146-16.969,83.135-16.969c40.423,0,69.764,15.104,93.996,30.652c11.481-38.959,39.022-133.045,47.241-161.162 C218.397,262.975,212.334,259.332,206.115,255.957z"/>
<path id="w12" fill="#FF5722" d="M264.174,295.535l-45.223,157.074c13.416,7.686,58.549,32.024,93.105,32.024 c27.896,0,59.127-7.147,95.417-21.896l43.179-150.988c-29.316,9.461-57.438,14.26-83.732,14.26 C318.945,326.01,285.363,310.461,264.174,295.535z"/>
<path id="w13" fill="#4CAF50" d="M146.411,184.395c38.559,0.399,67.076,15.104,90.708,30.251l46.376-158.672c-9.772-5.598-35.403-19.547-53.929-24.3c-12.193-2.842-25.01-4.308-38.602-4.308c-25.898,0.488-54.194,6.973-86.444,19.9 L60.3,202.564c32.404-12.218,60.322-18.17,86.043-18.17C146.366,184.395,146.411,184.395,146.411,184.395L146.411,184.395z"/>
<path id="w14" fill="#2196F3" d="M512,99.062c-29.407,11.416-58.104,17.233-85.514,17.233c-45.844,0-79.646-15.901-101.547-31.183L278.964,244.23 c30.873,19.854,64.146,29.939,99.062,29.939c28.474,0,57.97-6.84,87.73-20.344l-0.091-1.111l1.867-0.443L512,99.062z"/>
<path id="w21" style="visibility:hidden" d="M192 471.918l-191.844-26.297-0.010-157.621h191.854z"/>
<path id="w22" style="visibility:hidden" d="M479.999 288l-0.063 224-255.936-36.008v-187.992z"/>
<path id="w23" style="visibility:hidden" d="M0.175 256l-0.175-156.037 192-26.072v182.109z"/>
<path id="w24" style="visibility:hidden" d="M224 69.241l255.936-37.241v224h-255.936z"/>
</svg>
<svg class="example-box-model example-box" id="multi-morph-example-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 550 550">
<path id="s11" fill="#e91b1f" d="M206.115,255.957c-23.854-12.259-47.043-18.479-68.94-18.479c-2.978,0-5.976,0.09-8.974,0.354 c-27.94,2.312-53.461,9.684-69.875,15.414c-4.354,1.599-8.817,3.288-13.415,5.152L0,414.096 c30.851-11.416,58.146-16.969,83.135-16.969c40.423,0,69.764,15.104,93.996,30.652c11.481-38.959,39.022-133.045,47.241-161.162 C218.397,262.975,212.334,259.332,206.115,255.957z"/>
<path id="s12" fill="#FF5722" d="M264.174,295.535l-45.223,157.074c13.416,7.686,58.549,32.024,93.105,32.024 c27.896,0,59.127-7.147,95.417-21.896l43.179-150.988c-29.316,9.461-57.438,14.26-83.732,14.26 C318.945,326.01,285.363,310.461,264.174,295.535z"/>
<path id="s13" fill="#4CAF50" d="M146.411,184.395c38.559,0.399,67.076,15.104,90.708,30.251l46.376-158.672c-9.772-5.598-35.403-19.547-53.929-24.3c-12.193-2.842-25.01-4.308-38.602-4.308c-25.898,0.488-54.194,6.973-86.444,19.9 L60.3,202.564c32.404-12.218,60.322-18.17,86.043-18.17C146.366,184.395,146.411,184.395,146.411,184.395L146.411,184.395z"/>
<path id="s14" fill="#2196F3" d="M512,99.062c-29.407,11.416-58.104,17.233-85.514,17.233c-45.844,0-79.646-15.901-101.547-31.183L278.964,244.23 c30.873,19.854,64.146,29.939,99.062,29.939c28.474,0,57.97-6.84,87.73-20.344l-0.091-1.111l1.867-0.443L512,99.062z"/>
<path id="s21" style="visibility:hidden" d="M192 471.918l-191.844-26.297-0.010-157.621h191.854z"/>
<path id="s22" style="visibility:hidden" d="M479.999 288l-0.063 224-255.936-36.008v-187.992z"/>
<path id="s23" style="visibility:hidden" d="M0.175 256l-0.175-156.037 192-26.072v182.109z"/>
<path id="s24" style="visibility:hidden" d="M224 69.241l255.936-37.241v224h-255.936z"/>
</svg>
<div class="example-buttons">
<a id="multiMorphBtn" class="btn btn-olive" href="javascript:void(0)">Start</a>
</div>
</div>
<p>As you can imagine, it's quite hard if not impossible to code something that would do all this work automatically. Perhaps in the future we could have dedicated AI powered APIs to train and
program for this work, but until then, it's up to you to learn, observe, adapt and tweak in order to get the most out of this component.</p>
<h3>Intersecting Paths Example</h3>
<p>The last morph example is a bit more complex as the paths have intersecting subpaths with different positions as well as different amounts of subpaths. In this case you can manually clone one or
more subpaths in a way that the number of starting shapes is equal to the number of ending shapes, as well as making sure the starting shapes are close to their corresponding ending shapes; at this point
you should be just like in the previous examples.</p>
<p>You need to inspect the markup here in your browser console to get an idea on how the shapes have been arranged, we have used a <code>&lt;mask&gt;</code> where we included the subpaths of both start
and end shape, just to get the same visual as the original paths.</p>
<div class="featurettes">
<svg class="example-box-model example-box" id="multi-morph-example-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 513">
<defs>
<mask id="symbol">
<rect width="100%" height="100%" fill="#fff"></rect>
<path id="symbol-left" fill="#000" d="M155.889 333.394h-55.632c-3.351 0-5.854-1.504-7.271-3.792-1.467-2.379-1.542-5.464 0-8.534l59.11-104.313c0.063-0.114 0.063-0.19 0-0.316l-37.615-65.116c-1.556-3.098-1.783-6.157-0.316-8.534 1.417-2.301 4.235-3.477 7.586-3.477h55.632c8.535 0 12.72 5.499 15.489 10.431 0 0 38.020 66.33 38.249 66.696-2.252 3.97-60.059 106.21-60.059 106.21-2.844 5.131-6.852 10.745-15.173 10.745z"></path>
<path id="symbol-left-clone" fill="#000" d="M155.889 333.394h-55.632c-3.351 0-5.854-1.504-7.271-3.792-1.467-2.379-1.542-5.464 0-8.534l59.11-104.313c0.063-0.114 0.063-0.19 0-0.316l-37.615-65.116c-1.556-3.098-1.783-6.157-0.316-8.534 1.417-2.301 4.235-3.477 7.586-3.477h55.632c8.535 0 12.72 5.499 15.489 10.431 0 0 38.020 66.33 38.249 66.696-2.252 3.97-60.059 106.21-60.059 106.21-2.844 5.131-6.852 10.745-15.173 10.745z"></path>
<path id="symbol-right" fill="#000" d="M418.956 75.269l-123.176 217.79c-0.075 0.115-0.075 0.255 0 0.367l78.431 143.295c1.556 3.084 1.593 6.221 0.113 8.597-1.415 2.288-4.033 3.552-7.383 3.552h-55.57c-8.522 0-12.783-5.663-15.54-10.596 0 0-78.848-144.646-79.050-145.023 3.944-6.98 123.797-219.523 123.797-219.523 2.984-5.362 6.587-10.596 14.894-10.596h56.203c3.351 0 5.981 1.265 7.396 3.553 1.466 2.376 1.428 5.511-0.115 8.584z"></path>
<path id="eye-right" style="visibility: hidden;" d="M352 128c17.673 0 32 21.49 32 48s-14.327 48-32 48-32-21.49-32-48 14.327-48 32-48z"></path>
<path id="eye-left" style="visibility: hidden;" d="M176 156.031c29.823 0 51 11.166 51 28.641 0 3.699 1.906 21.497-0.085 24.797-7.414-12.288-27.405-21.094-50.915-21.094s-43.501 8.806-50.915 21.094c-1.991-3.3-0.085-21.098-0.085-24.797 0-17.475 21.177-28.641 51-28.641z"></path>
<path id="mouth" style="visibility: hidden;" d="M250.172 416c-59.621 0-111.929-32.14-141.446-80.476 35.205 27.53 97.267 32.905 162.644 19.989 70.124-13.853 124.555-45.771 144.227-88.297-10.827 83.98-80.759 148.784-165.425 148.784z"></path>
</mask>
</defs>
<path id="rectangle-container" fill="#2196F3" mask="url(#symbol)" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
<path id="circle-container" style="visibility: hidden;" d="M0,256a256,256 0 1,0 512,0a256,256 0 1,0 -512,0"></path>
</svg>
<svg class="example-box-model example-box" id="multi-morph-example-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 513">
<defs>
<mask id="symbol1">
<rect width="100%" height="100%" fill="#fff"></rect>
<path id="symbol-left1" fill="#000" d="M155.889 333.394h-55.632c-3.351 0-5.854-1.504-7.271-3.792-1.467-2.379-1.542-5.464 0-8.534l59.11-104.313c0.063-0.114 0.063-0.19 0-0.316l-37.615-65.116c-1.556-3.098-1.783-6.157-0.316-8.534 1.417-2.301 4.235-3.477 7.586-3.477h55.632c8.535 0 12.72 5.499 15.489 10.431 0 0 38.020 66.33 38.249 66.696-2.252 3.97-60.059 106.21-60.059 106.21-2.844 5.131-6.852 10.745-15.173 10.745z"></path>
<path id="sample-shape" fill="#000" d="M250 450 L250 450"></path>
<path id="symbol-right1" fill="#000" d="M418.956 75.269l-123.176 217.79c-0.075 0.115-0.075 0.255 0 0.367l78.431 143.295c1.556 3.084 1.593 6.221 0.113 8.597-1.415 2.288-4.033 3.552-7.383 3.552h-55.57c-8.522 0-12.783-5.663-15.54-10.596 0 0-78.848-144.646-79.050-145.023 3.944-6.98 123.797-219.523 123.797-219.523 2.984-5.362 6.587-10.596 14.894-10.596h56.203c3.351 0 5.981 1.265 7.396 3.553 1.466 2.376 1.428 5.511-0.115 8.584z"></path>
<path id="eye-right1" style="visibility: hidden;" d="M352 128c17.673 0 32 21.49 32 48s-14.327 48-32 48-32-21.49-32-48 14.327-48 32-48z"></path>
<path id="eye-left1" style="visibility: hidden;" d="M176 156.031c29.823 0 51 11.166 51 28.641 0 3.699 1.906 21.497-0.085 24.797-7.414-12.288-27.405-21.094-50.915-21.094s-43.501 8.806-50.915 21.094c-1.991-3.3-0.085-21.098-0.085-24.797 0-17.475 21.177-28.641 51-28.641z"></path>
<path id="mouth1" style="visibility: hidden;" d="M250.172 416c-59.621 0-111.929-32.14-141.446-80.476 35.205 27.53 97.267 32.905 162.644 19.989 70.124-13.853 124.555-45.771 144.227-88.297-10.827 83.98-80.759 148.784-165.425 148.784z"></path>
</mask>
</defs>
<path id="rectangle-container1" fill="#9C27B0" mask="url(#symbol1)" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
<path id="circle-container1" style="visibility: hidden;" d="M0,256a256,256 0 1,0 512,0a256,256 0 1,0 -512,0"></path>
</svg>
<div class="example-buttons">
<a id="compliMorphBtn" class="btn btn-red" href="javascript:void(0)">Start</a>
</div>
</div>
<p>The example on the left side showcases the cloning of one of the shapes to match the amount of starting and ending shapes, while the right side showcases
using a sample shape, somewhere close to its corresponding end shape, a much better animation, but in the end, it's up to you and your need on preparing,
analyzing as well as deciding on how to optimize these cases.</p>
<h3>Notes</h3>
<ul>
<li>Starting with KUTE.js version 2.0.14 the component implements <a href="https://github.com/thednp/svg-path-commander">SVGPathCommander</a> for path processing, solving previous issues with over-optimized
path strings among other issues. You can try the <a href="https://thednp.github.io/svg-path-commander/">SVGPathCommander demo page</a> to prepare your path strings.</li>
<li>Since <b>SVG Morph</b> animation works only with <code>path</code> elements, you might need a <code>convertToPath</code> feature, so
<a href="https://thednp.github.io/svg-path-commander/convert.html" target="_blank">grab one here</a>.</li>
<li>Both SVG morph components will always animate first sub-path from both starting and ending shapes, and for any case hopefully this demo will guide you in mastering the technique.</li>
<li>In some cases your start and end shapes don't have a very close size, you can use your vector graphics editor of choice or <a href="https://github.com/Waest/SVGPathConverter">SVGPathCommander</a>
to apply a scale transformation to your shapes' path commands.</li>
<li>The morphing animation is expensive so try to optimize the number of morph animations that run at the same time. When morphing sub-paths/multi-paths instead of cloning shapes to have same number
of shapes in both starting and ending shapes, you should also consider a fade and/or scale animation to improve the overal animation performance, mobile devices still don't do very much, regardless
of the advertising.</li>
<li>Large displays would need best resolution possible so a small <code>morphPrecision</code> value (1-10) would be required, assuming performant hardware are powering the displays. For small displays
you can get quite comfortable with almost any value, including the default value.</li>
<li>With all the tools at hand, you can also try to use a <code>morphPrecision</code> value for every resolution. Take some time to experiement, you might find a better <code>morphPrecision</code>
value you can use for any particular device and / or resolution.</li>
<li>The animation performance is the same for both <code>.to()</code> and <code>.fromTo()</code> methods, but the ones that use the second method will start faster, because the values have been prepared
already and for the first method the processing of the two paths happens on tween <code>.start()</code> call, thus delaying the animation, so keep that in mind when working with syncing multiple tweens,
the <code>.to()</code> based morph will always start later. Of course this assumes the you cache the tween objects first and start the animation later, if not (you start the animation on object creation),
both methods will be delayed.</li>
<li>The <b>SVG Morph</b> component uses approximatelly the same algorithm as D3.js for determining the coordinates for interpolation, the visual presentation is more natural compared to the other component,
it might be a better solution for your applications.</li>
<li>Make sure to check the <a href="assets/js/svgMorph.js" target="_blank">svgMorph.js</a> for a full code review.</li>
<li>This component should ignore the <code>fill-rule="evenodd"</code> specific SVG attribute, but you can make sure you check your shapes in that regard as well.</li>
<li>This component is bundled with the official <i>kute.js</i> distribution file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/svgMorph.js"></script>
</body>
</html>

389
svgTransform.html Normal file
View file

@ -0,0 +1,389 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The SVG Transform component for KUTE.js enables animation for the transform presentation attribute.">
<meta name="keywords" content="svg transform,cross-browser svg transform,svg animation,kute,kute.js,tweening engine,animation engine,animation,javascript animation,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js SVG Transform</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li class="active"><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">SVG Transform</h2>
<p class="condensed lead">The component that covers <i>transform</i> animation on <b>SVGElement</b> targets, solves browser inconsistencies and provides a similar visual presentation as
with other transform based components on non-<b>SVGElements</b> targets.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns margin-bottom">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate 2D transform functions on SVG elements on any SVG enabled browser.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>SVG Transform</b> component enables animation for the <b>transform</b> presentation attribute on any <b>SVGElement</b> target.</p>
<p>The <b>SVG Transform</b> is an important part of the SVG components for some reasons:</p>
<ul>
<li>It was developed to solve most browser inconsistencies of the time for transform animation. Nowadays modern browsers are Chromium browsers that work with regular 2D
transform functions.</li>
<li>The unique way to normalize translation to produce the kind of animation that is just as consistent as for CSS3 transforms on non-<b>SVGElement</b> targets.</li>
<li>The value processing is consistent with the current <a href="https://www.w3.org/TR/SVG/coords.html#EstablishingANewUserSpace">W3 draft</a>.</li>
</ul>
<p>Keep in mind that the <b>transform</b> attribute accepts no measurement units such as degrees or pixels, but it expects rotation / skew angles to be in degrees, and
translations in lengths measured around the parent <b>&lt;svg&gt;</b> element viewBox attribute.</p>
</div>
</div>
<div class="columns">
<div class="col3">
<h3 class="border text-right">Options</h3>
<p class="condensed text-right">Keep everything under control and handle any situation with a single option.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The only component that keeps the <b>transformOrigin</b> option because it's required to compute transform functions in the SVG
cooordinates system.</p>
<ul>
<li><kbd>transformOrigin: <b class='text-olive'>['50%','50%']</b></kbd> sets the much needed origin. Eg: <b>transformOrigin:[50,50]</b>. The default
value is <b>50% 50%</b> of the target element box, which is contrary with the SVG draft.</li>
</ul>
<p>Keep in mind that the component will disregard the current SVG default origin of <i>0px 0px</i> of the target's parent, even if the browsers' default
<b>transformOrigin</b> have been normalized over the years.</p>
<p>The <b>transformOrigin</b> tween option can also be used to set coordinates of a parent <b>&lt;svg&gt;</b> element (in the second example below).
Values like <i>top left</i> values are also accepted, but will take the target element's box as a reference, not the parent's box.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>2D Transform</h3>
<ul>
<li><kbd class="bg-olive">translate</kbd> function applies horizontal and / or vertical translation. EG. <code>translate:150</code> to translate a shape 150px to the right or
<code>translate:[-150,200]</code> to move the element to the left by 150px and to bottom by 200px. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-olive">rotate</kbd> function applies rotation to a shape on the Z axis. Eg. <code>rotate:150</code> will rotate a shape clockwise by 150 degrees around it's own center or around
the <code>transformOrigin: '450 450'</code> set tween option coordinate of the parent element. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-olive">skewX</kbd> function used to apply a skew transformation on the X axis. Eg. <code>skewX:25</code> will skew a shape by 25 degrees. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-olive">skewY</kbd> function used to apply a skew transformation on the Y axis. Eg. <code>skewY:25</code> will skew a shape by 25 degrees. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-olive">scale</kbd> function used to apply a single value size transformation. Eg. <code>scale:0.5</code> will scale a shape to half of it's initial size. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-red">matrix</kbd> function is not supported, but the Transform Matrix covers you there, if you'll read below.</li>
</ul>
<h3>Examples</h3>
<p>As explained with the <a href="transformMatrix.html">Transform Matrix</a> component, the <b>DOMMatrix</b> API will replace <b>webkitCSSMatrix</b> and <b>SVGMatrix</b> and on this page we intend to put
the two components head to head, the elements on the left will be using <b>Transform Matrix</b> component and equivalent 2D transform functions, while the elements on the right will be using 2D functions of
the <b>SVG Transform</b> component.</p>
<p>The <b>SVG Transform</b> component comes with a reliable set of scripts that work on all browsers, making use of the <b>SVGMatrix</b> API for some origin calculation, the <code>transform</code> presentation
attribute and the <code class="bg-indigo">svgTransform</code> tween property with a familiar and very easy notation:</p>
<pre><code class="language-javascript">// using the svgTransform property works in all SVG enabled browsers
var tween2 = KUTE.to(
'shape', // target
{ // to
svgTransform: {
translate: [150,100],
rotate: 45,
skewX: 15, skewY: 20,
scale: 1.5
}
}
);
// transformMatrix can animate SVGElement targets on modern browsers
// requires adding styling like `transform-origin:50% 50%` to the target element
var tween1 = KUTE.to(
'shape', // target
{ // to
transform: {
translate3d: [150,100,0],
rotate3d: [0,0,45],
skew: [15,20],
scale3d: [1.5,1.5,1]
}
}
);
</code></pre>
<p>Let's see some examples and explain each case.</p>
<h4>SVG Rotation</h4>
<p>Our first chapter of the SVG transform is all about rotations, perhaps the most important part here. The <code class="bg-indigo">svgTransform</code> will only accept single value
for the angle value <code>rotate: 45</code>, the rotation will go around the shape's center point by default, again, contrary to the browsers' default value and you can set a <code>transformOrigin</code>
tween option to override the behavior.</p>
<p>The argument for this implementation is that this is something you would expect from regular HTML elements rotation and probably most needed, not to mention the amount of savings in the codebase department.
Let's have a look at a quick demo:</p>
<div class="featurettes">
<svg id="svgRotate" class="example-box-model example-box" style="width:320px; overflow: visible;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1085 513">
<path class="bg-olive" style="transform-origin: 25% 50%;" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
<path class="bg-blue" transform="translate(580)" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
</svg>
<div class="example-buttons">
<a id="rotateBtn" class="btn btn-red" href="javascript:void(0)">Start</a>
</div>
</div>
<p>For the first element, the Transform Matrix creates the rotation animation via <code>rotate3d[0,0,360]</code> tween property around the element center coordinate, as we've set <i>transform-origin:25% 50%</i>
to the element's style; this animation doesn't work in IE browsers, while in older versions Firefox the animation is inconsistent. The second element uses the <code>rotate: 360</code> function of the SVG Transform
component and the rotation animation is around the element's own central point without any option, an animation that DO WORK in all SVG enabled browsers.</p>
<p>When for non-SVG elements' transform we could have used values such as <i>center bottom</i> as <code>transformOrigin</code> (also not supported in all modern browsers for SVGs), the entire processing falls
to the browser, however when it comes to SVGs our component here will compute the <code>transformOrigin</code> tween option value accordingly to use the shape's <code>.getBBox()</code> value to determine
for instance the coordinates for <i>25% 75%</i> position or <i>center top</i>.</p>
<p>In other cases you may want to rotate shapes around the center point of the parent <code>&lt;svg></code> or <code>&lt;g></code> element, and we use it's <code>.getBBox()</code> to determine the <i>50% 50%</i>
coordinate, so here's how to deal with it:</p>
<pre><code class="language-javascript">// rotate around parent svg's "50% 50%" coordinate as transform-origin
// get the bounding box of the parent element
var svgBB = element.ownerSVGElement.getBBox(); // returns an object of the parent &lt;svg> element
// we need to know the current translate position of the element [x,y]
// in our case is:
var translation = [580,0];
// determine the X point of transform-origin for 50%
var OriginX = svgBB.width * 50 / 100 - translation[0];
// determine the Y point of transform-origin for 50%
var OriginY = svgBB.height * 50 / 100 - translation[1];
// set your rotation tween with "50% 50%" transform-origin of the parent &lt;svg> element
var rotationTween = KUTE.to(element, {svgTransform: {rotate: 150}}, { transformOrigin: [OriginX, OriginY]} );
</code></pre>
<div class="featurettes">
<svg id="svgRotate1" class="example-box-model example-box" style="width:320px; overflow: visible;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1085 513">
<path class="bg-olive" style="transform-origin: 50% 50%;" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
<path class="bg-blue" transform="translate(580)" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
</svg>
<div class="example-buttons">
<a id="rotateBtn1" class="btn btn-red" href="javascript:void(0)">Start</a>
</div>
</div>
<p>Same as the above example, the first element is rotated by the <b>Transform Matrix</b> component and is using <i>transform-origin: 50% 50%;</i> styling, while the second element is rotated by the <b>SVG Transform</b>
component with the above calculated transform-origin.</p>
<h4>SVG Translation</h4>
<p>In this example we'll have a look at translations, so when setting <code>translate: [150,0]</code>, the first value is X (horizontal) coordinate to which the shape will translate to and the second value is
Y (vertical) coordinate for translation. When <code>translate: 150</code> notation is used, the script will understand that's the X value and the Y value is 0 just like for the regular HTML elements
transformation. Let's have a look at a quick demo:</p>
<div class="featurettes">
<svg id="svgTranslate" class="example-box-model example-box" style="width:320px; overflow: visible;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1085 513">
<path class="bg-green" style="transform-origin: 25% 50%;" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
<path class="bg-orange" transform="translate(580)" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
</svg>
<div class="example-buttons">
<a id="translateBtn" class="btn btn-blue" href="javascript:void(0)">Start</a>
</div>
</div>
<p>The first element uses the Transform Matrix <code>translate3d: [580,0,0]</code> function, while the second tween uses the <code>translate: [0,0]</code> as <code class="bg-indigo">svgTransform</code> value.
For the second example the values are unitless and are relative to the <code>viewBox</code> attribute.</p>
<h4>SVG Skew</h4>
<p>For skews we have: <code>skewX: 25</code> or <code>skewY: -25</code> as SVGs don't support the <code>skew: [X,Y]</code> function. Here's a quick demo:</p>
<div class="featurettes">
<svg id="svgSkew" class="example-box-model example-box" style="width:320px; overflow: visible;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1085 513">
<path class="bg-yellow" style="transform-origin: 25% 50%;" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
<path class="bg-indigo" transform="translate(580)" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
</svg>
<div class="example-buttons">
<a id="skewBtn" class="btn btn-red" href="javascript:void(0)">Start</a>
</div>
</div>
<p>The first tween skews the shape on both X and Y axes in a chain via Transform Matrix <code>skew:[-15,-15]</code> function and the second tween skews the shape on X and Y axes via the <code class="bg-indigo">svgTransform</code> functions <code>skewX:15</code> and
<code>skewY:15</code> tween properties. You will notice translation kicking in to set the transform origin.</p>
<h4>SVG Scaling</h4>
<p>Another transform example for SVGs is the scale. Unlike translations, for scale animation the component only accepts single value like <code>scale: 1.5</code>, for both X (horizontal) axis and Y (vertical) axis,
to keep it simple and even if SVGs do support <code>scale(X,Y)</code>. But because the scaling on SVGs depends very much on the shape's position, the script will always try to adjust the translation to
make the animation look as we would expect. A quick demo:</p>
<div class="featurettes">
<svg id="svgScale" class="example-box-model example-box" style="width:320px; overflow: visible;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1085 513">
<path class="bg-lime" style="transform-origin: 25% 50%;" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
<path class="bg-olive" transform="translate(580)" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
</svg>
<div class="example-buttons">
<a id="scaleBtn" class="btn btn-pink" href="javascript:void(0)">Start</a>
</div>
</div>
<p>The first tween scales the shape at <code>scale: 1.5</code> via <b>Transform Matrix</b> component and it's <code>scale3d:[1.5,1.5,1]</code> function, and the second tween scales down the shape at <code>scale: 0.5</code>
value via <code class="bg-indigo">svgTransform</code>. If you inspect the elements, you will notice for the second shape translation is involved, and this is to keep <code>transform-origin</code> at an expected
<i>50% 50%</i> of the shape box. A similar case as with the skews.</p>
<h4>Mixed SVG Transform Functions</h4>
<p>Our last transform example for SVG Transform is the mixed transformation. Just like for the other examples the component will try to adjust the rotation <code>transform-origin</code> to make it look as you would expect it
from regular HTML elements. Let's combine 3 functions at the same time and see what happens:</p>
<div class="featurettes">
<svg id="svgMixed" class="example-box-model example-box" style="width: 320px; overflow: visible;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1085 513" xmlns:xml="http://www.w3.org/XML/1998/namespace" xml:space="preserve" version="1.1">
<path class="bg-green" style="transform-origin: 25% 50%;" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
<path class="bg-indigo" transform="translate(580)" d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"></path>
</svg>
<div class="example-buttons">
<a id="mixedBtn" class="btn btn-teal" href="javascript:void(0)">Start</a>
</div>
</div>
<p>Both shapes are scaled at <code>scale: 1.5</code>, translated to <code>translate: 250</code> and skewed at <code>skewX: -15</code>. If you inspect the elements, you will notice the second shape's translation is
different from what we've set in the tween object, and this is to keep <code>transform-origin</code> at an expected <i>50% 50%</i> value. This means that the component will also compensate rotation transform origin
when skews are used, so that both CSS3 transform property and SVG transform attribute have an identical animation.</p>
<h4>Chained SVG Transform</h4>
<p>The <b>SVG Transform</b> does not work with SVG specific chained transform functions right away (do not confuse with tween chain), Ana Tudor explains best <a href="https://css-tricks.com/transforms-on-svg-elements/">here</a>,
but if your SVG elements only use this feature to set a custom <code>transform-origin</code>, it should look like this:</p>
<pre><code class="language-markup">&lt;svg>
&lt;circle transform="translate(150,150) rotate(45) scale(1.2) translate(-150,-150)" r="20">&lt;/circle>
&lt;/svg>
</code></pre>
<p>In this case I would recommend using the values of the first translation as <code>transformOrigin</code> for your tween built with the <code>.fromTo()</code> method like so:</p>
<pre><code class="language-javascript">// a possible workaround for animating a SVG element that uses chained transform functions
KUTE.fromTo(element,
{svgTransform : { translate: 0, rotate: 45, scale: 0.5 }}, // we asume the current translation is zero on both X &amp; Y axis
{svgTransform : { translate: 450, rotate: 0, scale: 1.5 }}, // we will translate the X to a 450 value and scale to 1.5
{transformOrigin: [150,150]} // tween options use the transform-origin of the target SVG element
).start();
</code></pre>
<p>Before you hit the <kbd>Start</kbd> button, make sure to check the <code>transform</code> attribute value. The below tween will reset the element's transform attribute to original value when the animation is complete.</p>
<div class="featurettes">
<svg id="svgChained" class="example-box-model example-box" style="overflow: visible;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 513 513" xmlns:xml="http://www.w3.org/XML/1998/namespace" xml:space="preserve" version="1.1">
<path class="bg-blue"
d="M426.671 0h-341.328c-46.937 0-85.343 38.405-85.343 85.345v341.311c0 46.969 38.406 85.344 85.343 85.344h341.328c46.938 0 85.329-38.375 85.329-85.345v-341.31c0-46.94-38.391-85.345-85.329-85.345z"
transform="translate(256,256) rotate(45) scale(0.5) translate(-256,-256)"></path>
</svg>
<div class="example-buttons">
<a id="chainedBtn" class="btn btn-lime" href="javascript:void(0)">Start</a>
</div>
</div>
<p>This way we make sure to count the real current transform-origin and produce a consistent animation with the SVG coordinate system, just as the above example showcases.</p>
<h3>Notes</h3>
<ul>
<li>The <b>SVG Transform</b> component is successfuly handling all possible combinations of transform functions, and <b>always uses same order of transform functions</b>: <code>translate</code>,
<code>rotate</code>, <code>skewX</code>, <code>skewY</code> and <code>scale</code> to keep animation consistent and with same aspect as for CSS3 transforms on non-SVG elements.</li>
<li>Keep in mind that the SVG transform functionss will use the center of a shape as transform origin by default, contrary to the SVG draft.</li>
<li>Keep in mind the adjustments required for rotations, remember the <code>.getBBox()</code> method, it's really useful to set custom <code>transform-origin</code>.</li>
<li>By default browsers use <code>overflow: hidden</code> for <code>&lt;svg></code> so child elements are partialy/completely hidden while animating. You might want to set <code>overflow: visible</code>
or some browser specific tricks if that is the case.</li>
<li>When using <code>viewBox="0 0 500 500"</code> attribute for <code>&lt;svg></code> and no <code>width</code> and/or <code>height</code> attribute(s), means that you expect the SVG to be scalable and most
Internet Explorer versions simply don't work. You might want to <a href="https://css-tricks.com/scale-svg/" target="_blank">check this tutorial</a>.</li>
<li>In other cases when you need maximum control and precision or when shapes are already affected by translation, you might want to use the <code>.fromTo()</code> method with all proper values.</li>
<li>Also the <code class="bg-indigo">svgTransform</code> tween property does not support 3D transforms, because they are not supported in all SVG enabled browsers.</li>
<li>The <b>SVG Transform</b> component cannot work with the <code>transformOrigin</code> set to an <b>SVGElement</b> via CSS, you must always use a it's specific option.</li>
<li>The component can be combined with the <a href="htmlAttributes.html">HTML Attributes</a> component to enable even more advanced/complex animations for SVG elements.</li>
<li>Keep in mind that older browsers like Internet Explorer 8 and below as well as stock browser from Android 4.3 and below <a href="http://caniuse.com/#search=svg" target="_blank">do not support inline SVG</a>
so make sure to fiter your SVG tweens properly.</li>
<li>While you can still use regular CSS3 transforms for SVG elements, everything is fine with Google Chrome, Opera and other webkit browsers, but older Firefox versions struggle with the percentage based
<code>transformOrigin</code> values and ALL Internet Explorer versions have no implementation for CSS3 transforms on SVG elements, which means that the SVG Transform component will become a fallback
component to handle legacy browsers in the future. Guess who's taking over :)</li>
<li>This component is bundled with the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/svgTransform.js"></script>
</body>
</html>

158
textProperties.html Normal file
View file

@ -0,0 +1,158 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Text Properties component for KUTE.js allows you to animate CSS properties related to typography on most browsers.">
<meta name="keywords" content="text properties,font-size,line-height,letter-spacing,kute.js,animation,javascript animation,tweening engine,animation engine,JavaScript,Native JavaScript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Text Properties</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<style></style>
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li class="active"><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Text Properties</h2>
<p class="condensed lead">The component that animates the typographic CSS properties of a target content <b>Element</b> on most browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Animate the text size or spacing properties of a target text element.</p>
</div>
<div class="col9 border">
<p class="condensed lead">The KUTE.js <b>Text Properties</b> component enables animation for typography related CSS properties of content element targets
on most browsers.</p>
<p>This small and simple component can be used to create various attention seekers for any content elements such as <b>HTMLHeadingElement</b>,
<b>HTMLParagraphElement</b>, <b>HTMLUListElement</b> or any other, as well as for entire content blocks.</p>
<p>You can either animate an entire string or content block or split your string into words or letters and create a simple animation with one or more of
the following properties:</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>Supported Properties</h3>
<ul>
<li><kbd class="bg-olive">fontSize</kbd> allows you to animate the <code>font-size</code> for a target element.</li>
<li><kbd class="bg-olive">lineHeight</kbd> allows you to animate the <code>line-height</code> for a target element.</li>
<li><kbd class="bg-olive">letterSpacing</kbd> allows you to animate the <code>letter-spacing</code> for a target element.</li>
<li><kbd class="bg-olive">wordSpacing</kbd> allows you to animate the <code>word-spacing</code> for a target element.</li>
</ul>
<h3>Example</h3>
<pre><code class="language-javascript">let tween1 = KUTE.to('selector1',{fontSize:'200%'})
let tween2 = KUTE.to('selector1',{lineHeight:24})
let tween3 = KUTE.to('selector1',{letterSpacing:50})
let tween3 = KUTE.to('selector1',{wordSpacing:50})
</code></pre>
<div id="textProperties" class="featurettes" style="height: 152px">
<h1 class="example-item">Howdy!</h1>
<div class="example-buttons"><a class="btn btn-pink" href="javascript:void(0)">Start</a></div>
</div>
<h3>Notes</h3>
<ul>
<li>Be sure to check the <a href="./assets/js/textProperties.js">textProperties.js</a> for a more in-depth review of the above example.</li>
<li>Similar to box model properties, the text properties are also layout modifiers, they will push the layout around forcing unwanted re-paint work. To avoid re-paint, you
can use a fixed height for the target element's container, as we used in our example here, or set your text to <code>position:absolute</code>.</li>
<li>The component is only included in the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/textProperties.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>

261
textWrite.html Normal file
View file

@ -0,0 +1,261 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Text Write component for KUTE.js enables animation via string manipulation.">
<meta name="keywords" content="text write,number increase,number,number decrease,kute,kute.js,animation,javascript animation,tweening engine,animation engine,Javascript,Native Javascript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js TextWrite</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
<style>
.text-example {
margin: 0 0 20px;
font-size: 28px;
line-height: 1.5;
white-space: nowrap;
}
.red {
color: red
}
</style>
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li class="active"><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Text Write</h2>
<p class="condensed lead">The component that enables a unique animation by manipulating the string content of <b>Element</b> targets on most browsers.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">Manipulate string contents with ease.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>Text Write</b> component enables animation for content <b>Element</b> targets by manipulating their string contents.</p>
<p><b>The component provides two properties:</b></p>
<ul>
<li><b>number: NUMBER</b> - interpolate the string numbers by increasing or decreasing their values</li>
<li><b>text: STRING</b> - will add/remove a content string one character at a time</li>
</ul>
<p>This <b>text</b> property comes with an additional tween option called <b>textChars</b> for the scrambling text character, with the following expected values:</p>
<ul>
<li><b>alpha</b> use lowercase alphabetical characters, the default value</li>
<li><b>upper</b> use UPPERCASE alphabetical characters</li>
<li><b>numeric</b> use numerical characters</li>
<li><b>symbols</b> use symbols such as #, $, %, etc.</li>
<li><b>all</b> use all alpha numeric and symbols.</li>
<li><b>YOUR CUSTOM STRING</b> use your own custom characters; eg: <b>'KUTE.JS IS #AWESOME'</b>.</li>
</ul>
<p>It's always best to wrap your target number in a <b>&lt;span id="uniqueID"&gt;</b> for the <b>number</b> property and content targets should be split into
multiple parts for the <b>text</b> property if the target has child contents, as we will see in the examples below.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h2>Examples</h2>
<p>The effect of these two properties is very popular, so let's go through some quick examples to explain the workflow for the best possible outcome. We will try to focus
on the <b>text</b> property a bit more because we can optimize the content targets for a great visual experience.</p>
<h3>Number Property</h3>
<p>As discussed above, the target number need to be wrapped in a tag of choice with a unique ID so we can target it.</p>
<pre><code class="language-markup">// the target number is wrapped in a &lt;span&gt; tag with a unique ID
&lt;p class="text-example">Total number of lines: &lt;span id="myNumber"&gt;0&lt;/span&gt;&lt;/p&gt;
</code></pre>
<pre><code class="language-javascript">// sample tween object with "number" property
// this assumes it will start from current number which is different from 1550
var myNumberTween = KUTE.to('#myNumber', {number: 1550});
</code></pre>
<p>The above should work like this:</p>
<div class="featurettes">
<p class="text-example">Total number of lines: <span id="numText">0</span></p>
<div class="example-buttons">
<a id="numBtn" class="btn btn-orange" href="javascript:void(0)">Start</a>
</div>
</div>
<p>The button action will toggle the <code>valuesEnd</code> value for the <code>number</code> property, because tweening a number to itself would produce no effect.</p>
<h3>Text Property</h3>
<p>Let's try a quick example and analyze the current outcome. Be aware that the example involves using child contents for the values, which is something we need to
handle in a special way to optimize the visual experience.</p>
<pre><code class="language-javascript">// sample tween object with "text" property
var myTextTween = KUTE.to('selector', {text: 'A text string with &lt;span&gt;child content&lt;/span&gt; should do.'});
</code></pre>
<div class="featurettes">
<p class="text-example" id="headText">Click the <strong>Start</strong> button on the right.</p>
<div class="example-buttons">
<a id="headBtn" class="btn btn-blue" href="javascript:void(0)">Start</a>
</div>
</div>
<p>So targets with child elements don't animate very well it seems. We could probably split the starting content and end content into multiple parts, set a tween object
for each parth with delays and other settings, but <b>Text Write</b> component comes with a powerful utility you can use to ease your work in these instances.</p>
<p>The <b>createTextTweens()</b> utility will do it all for you: split text strings, set tween objects, but let's see some sample code:</p>
<pre><code class="language-javascript">// grab the parent of the content segments
var textTarget = document.getElementById('textExample');
// make a reversed array with its child contents
var tweenObjects = KUTE.Util.createTextTweens(
textTarget,
'This text has a &lt;a href="index.html"&gt;link to homepage&lt;/a&gt; inside.',
options
);
// start whenever you want
tweenObjects.start();
</code></pre>
<p>Now let's see how we doin:</p>
<div class="featurettes">
<p class="text-example" id="textExample">Click the <strong>Start</strong> button on the right.</p>
<div class="example-buttons">
<a id="textExampleBtn" class="btn btn-blue" href="javascript:void(0)">Start</a>
</div>
</div>
<p>There are some <b>considerations</b> for the <b>createTextTweens(target,newText,options)</b> utility:</p>
<ul>
<li>The utility will replace the target content with <b>&lt;span&gt;</b> parts or the children's <b>tagName</b>s, then for the <b>newText</b> content will
create similar parts but empty. Also the number of the parts of the target content doesn't have to be the same as for the new content.</li>
<li>The utility returns an <b>Array</b> of tween objects, which is similar but independent from <a href="tweenCollection.html">tweenCollection</a> objects.</li>
<li>The returned <b>Array</b> itself has a <b>start()</b> "method" you can call on all the tweens inside.</li>
<li>The utility will assign <b>playing: <i>boolean</i></b> property to the target content <b>Element</b> to prevent unwanted animation interruptions or glitches.</li>
<li>While you can set various tween options like <b>easing</b>, <b>duration</b> or the component specific <b>textChars</b> option, the <b>delay</b> option is handled
by the utility automatically.</li>
<li>The utility has a special handling for the <b>duration</b> tween option. You can either set a fixed duration like <b>1000</b>, which isn't recommended, or <b>auto</b>
which will allow the utility the ability to determine a duration for each text part</li>
<li>When the animation of the last text part is complete, the target content <b>Element</b>.innerHTML will be set to the original un-split <b>newText</b>.</li>
<li>Using <b>yoyo</b> tween option is not recommended because it doesn't produce a desirable effect.</li>
<li>The utility will not work properly with targets that have a deeper structure than level 1, which means that for instance
<i>&lt;span&gt;Text &lt;span&gt;sample&lt;/span&gt;&lt;/span&gt;</i> may not be processed properly.</li>
</ul>
<h3>Combining Both</h3>
<div class="featurettes">
<div class="columns">
<div class="col">
<p class="text-example" id="comNum">0</p>
</div>
<div class="col9" style="text-align: left">
<p class="text-example" id="comText">Clicks so far</p>
</div>
</div>
<div class="example-buttons">
<a id="comBtn" class="btn btn-olive" href="javascript:void(0)">Start</a>
</div>
</div>
<p>In this example we've used the <code>textChars</code> option with <code>symbols</code> and <code>all</code> values respectively, but combining the two text properties and some other KUTE.js
features can really spice up some content. Have fun!</p>
<h2>Notes</h2>
<ul>
<li>Keep in mind that the <code>yoyo</code> tween option will NOT un-write / delete the string character by character for the <b>text</b> property, but will write the previous text instead.</li>
<li>For a full code review, check out the <a href="./assets/js/textWrite.js">./assets/js/textWrite.js</a> example source code.</li>
<li>The component is only included in the <i>demo/src/kute-extra.js</i> file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/scripts.js"></script>
<script src="./assets/js/textWrite.js"></script>
</body>
</html>

300
transformFunctions.html Normal file
View file

@ -0,0 +1,300 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The Transform Functions component for KUTE.js enable regular transform animations.">
<meta name="keywords" content="css3 transform,transform functions,transform,kute,kute.js,animation,javascript animation,tweening engine,animation engine,JavaScript,Native JavaScript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Transform Functions</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li class="active"><a href="transformFunctions.html">Transform Functions</a></li>
<li><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Transform Functions</h2>
<p class="condensed lead">The component covers most important 2D and 3D <i>transform</i> functions as described in the <a href="http://www.w3.org/TR/css3-transforms/" target="_blank">W3 specification</a>,
completelly reworked for improved performance and faster value processing.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">The component to cover animation for most <b>transform</b> functions with improved performance and faster value processing.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>Transform Functions</b> enables animation for the CSS3 <b>transform</b> style on <b>Element</b> targets on modern browsers. For specific legacy browsers there is another
component called <b>Transform Legacy</b> you will find in the source folders.</p>
<p>Starting with KUTE.js version 2.0, you can set the <b>perspective</b> function as a tween property, while you can still rely on a parent's perspective but for less performance.</p>
<p>All the previous perspective related options have been removed. The <b>transform</b> CSS3 property itself no longer uses preffixes like <b>webkit</b>, <b>moz</b> or <b>ms</b> since all major
browsers are standardized.</p>
<p>In comparison with previous versions, the component expects that input values are already <b>px</b> and <b>deg</b> based and no longer transforms <b>%</b> percent based values into <b>px</b> based or <b>rad</b>
based angles into <b>deg</b> based. This makes the execution faster and more consistent.</p>
<p>The component will stack all transform functions for translations, rotations and skews to shorthand functions to optimize performance and minimize value processing.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>3D Transform</h3>
<ul>
<li><kbd class="bg-blue">perspective</kbd> function creates a 3D perspective for a target element transformation. EG. <code>perspective:400</code> to apply a 400px perspective. <kbd class="bg-lime">IE10+</kbd></li>
<li><kbd class="bg-blue">translateX</kbd> function is for horizontal translation. EG. <code>translateX:150</code> to translate an element 150px to the right. <kbd class="bg-lime">IE10+</kbd></li>
<li><kbd class="bg-blue">translateY</kbd> function is for vertical translation. EG. <code>translateY:-250</code> to translate an element 250px towards the top. <kbd class="bg-lime">IE10+</kbd></li>
<li><kbd class="bg-blue">translateZ</kbd> function is for translation on the Z axis in a given 3D field. EG. <code>translateZ:-250</code> to translate an element 250px away from the viewer, making it
appear smaller. This function can be combined with the <code>perspective</code> function to take effect or the parent's perspective; the smaller perspective value, the deeper translation. <kbd class="bg-lime">IE10+</kbd></li>
<li><kbd class="bg-blue">translate3d</kbd> function is for movement on all axes 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. When third value is used, it requires using a <code>perspective</code>. <kbd class="bg-lime">IE10+</kbd></li>
<li><kbd class="bg-blue">rotateX</kbd> function 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. Requires perspective.
<kbd class="bg-lime">IE10+</kbd></li>
<li><kbd class="bg-blue">rotateY</kbd> function 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.
Requires perspective. <kbd class="bg-lime">IE10+</kbd></li>
<li><kbd class="bg-blue">rotateZ</kbd> function 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 on X axis.
<kbd class="bg-lime">IE10+</kbd></li>
<li><kbd class="bg-blue">rotate3d</kbd> is a <b>tween property</b>, which combines the above <code>rotateX</code>, <code>rotateY</code>, and <code>rotateZ</code> functions and rotates an element on all axes. Obviously this is NOT
equivalent with the <code>rotate3d(vectorX,vectorY,vectorZ,angle)</code> shorthand function, this is only an optimization implemented for performance reasons and hopefully for your convenience.
Eg. <code>rotate3d:[-150,80,90]</code> will rotate an element counter-clockwise by 150 degrees on X axis, 80 degrees on Y axis and 90 degrees on Z axis. The X and Y axis require a <code>perspective</code>.
<kbd class="bg-lime">IE10+</kbd></li>
<li><kbd class="bg-red">matrix3d</kbd> and <kbd class="bg-red">scale3d</kbd> functions are not supported by this component, but they are implemented in the <a href="transformMatrix.html">transformMatrix</a> component.</li>
</ul>
<h3>2D Transform</h3>
<ul>
<li><kbd class="bg-blue">translate</kbd> function is for movement on X and Y axis. EG. <code>translate:[-150,200]</code> to translate an element 150px to the left, 200px to the bottom. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-blue">rotate</kbd> function rotates an element on the Z axis. Eg. <code>rotate:250</code> will rotate an element clockwise by 250 degrees. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-blue">skewX</kbd> function will apply a shear on X axis to a target element. Eg. <code>skewX:50</code> will skew a target element on X axis by 50 degrees. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-blue">skewY</kbd> function will apply a shear on X axis to a target element. Eg. <code>skewX:50</code> will skew a target element on X axis by 50 degrees. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-blue">skew</kbd> function will apply a shear on both X and Y axes to a target element. Eg. <code>skew:[50,50]</code> will skew a target element on X axis by 50 degrees and 50 degrees on Y axis.
<kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-blue">scale</kbd> function will scale a target element on all axes. Eg. <code>scale:1.5</code> will scale up a target element by 50%. <kbd class="bg-lime">IE9+</kbd></li>
<li><kbd class="bg-red">matrix</kbd> is not supported by this component, but is implemented in the <a href="transformMatrix.html">transformMatrix</a> component.</li>
</ul>
<p>As a quick note, all input values for <kbd class="bg-blue">translate</kbd>, <kbd class="bg-blue">rotate</kbd> or single axis translation, skew or rotation will be all stacked into <kbd class="bg-blue">translate3d</kbd>,
<kbd class="bg-blue">skew</kbd> and <kbd class="bg-blue">rotate3d</kbd> respectivelly; this is to further improve performance on modern browsers.</p>
<h3>Translations</h3>
<pre><code class="language-javascript">var tween1 = KUTE.fromTo('selector1',{translate:0},{translate:250}); // or translate:[x,y] for both axes
var tween2 = KUTE.fromTo('selector2',{translateX:0},{translateX:-250});
var tween3 = KUTE.fromTo('selector3',{translate3d:[0,0,0]},{translate3d:[0,250,0]});
var tween4 = KUTE.fromTo('selector4',{perspective:400,translateY:0},{perspective:200,translateY:-100});
</code></pre>
<div id="translate-examples" class="featurettes">
<div class="example-item example-box bg-indigo">2D</div>
<div class="example-item example-box bg-olive">X</div>
<div class="example-item example-box bg-pink">Y</div>
<div class="example-item example-box bg-red">Z</div>
<div class="example-buttons">
<a class="btn btn-blue" href="javascript:void(0)">Start</a>
</div>
</div>
<p>As you can see in your browsers console, for all animations <code>translate3d</code> is used, as explained above. 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.</p>
<h3>Rotations</h3>
<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',{perspective:100,rotate3d:[0,0,0]},{perspective:100,rotate3d:[0,160,0]});
var tween4 = KUTE.fromTo('selector4',{rotateZ:0},{rotateZ:360});
</code></pre>
<div id="rotExamples" class="featurettes">
<div class="example-item example-box bg-blue">2D</div>
<div class="example-item example-box bg-indigo">X</div>
<div class="example-item example-box bg-olive">Y</div>
<div class="example-item example-box bg-pink">Z</div>
<div class="example-buttons">
<a class="btn btn-green" href="javascript:void(0)">Start</a>
</div>
</div>
<p>The <code>rotateX</code> and <code>rotateY</code> are 3D based rotations, so they require a perspective in order to make the browser render proper 3D layers, but in the example they animate different because only the second, Y axis, uses the
<code>perspective</code> function. 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.</p>
<h3>Skews</h3>
<pre><code class="language-javascript">var tween1 = KUTE.fromTo('selector1',{skewX:0},{skewX:20});
var tween2 = KUTE.fromTo('selector2',{skew:[0,0]},{skew:[0,45]});
</code></pre>
<div id="skewExamples" class="featurettes">
<div class="example-item example-box bg-teal">X</div>
<div class="example-item example-box bg-green">Y</div>
<div class="example-buttons">
<a class="btn btn-yellow" href="javascript:void(0)">Start</a>
</div>
</div>
<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
{pespective:200,translateX:0, rotateX:0, rotateY:0, rotateZ:0}, // from
{pespective:200,translateX:250, rotateX:360, rotateY:15, rotateZ:5} // to
);
var tween2 = KUTE.fromTo(
'selector2', // element
{translateX:0, rotateX:0, rotateY:0, rotateZ:0}, // from
{translateX:-250, rotateX:360, rotateY:15, rotateZ:5} // to
);
</code></pre>
<div id="mixTransforms" class="featurettes" style="perspective: 400px;">
<div class="example-item example-box bg-pink" style="line-height: 50px; font-size: 25px;">self perspective 200px</div>
<div class="example-item example-box bg-orange" style="line-height: 50px; font-size: 25px;">parent perspective 400px</div>
<div class="example-buttons">
<a class="btn btn-olive" href="javascript:void(0)">Start</a>
</div>
</div>
<p>Note in this example, the first tween object uses the element's <code>perspective</code> while the second relies on the parent's perspective.</p>
<h3>Chained Transformations</h3>
<p>KUTE.js has the ability to stack transform functions in a way to improve performance and optimize your workflow. In that idea the <code>.to()</code> method can be the right choice for most of your
animation needs and especially to link animations together because it has the ability to check the current values of the transform functions found in the element's inline styling, mostly from previous
tween animation, and use them as start values for the next animation. OK now, let's see a side by side comparison with 4 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-gray" style="font-size: 30px">TO</div>
<div class="example-item example-box bg-blue" style="font-size: 30px">TO</div>
<div class="example-buttons">
<a class="btn btn-blue" href="#">Start</a>
</div>
</div>
<h4>Observations</h4>
<ul>
<li>The example hopefully demostrates what the animation looks like with different combinations of transform functions and how to combine them to optimize your workflow, size on disk as well as to how
to link animations together in a smooth continuous animation.</li>
<li>No matter the input values, the component will always stack translations into <code>translate3d</code> and rotations into <code>rotate3d</code>.</li>
<li>The first box uses a regular <code class="bg-gray">.fromTo()</code> object, from point A to B and back to A, with the exact coordinates we want.</li>
<li>The second box is also using <code class="bg-olive">.fromTo()</code> object, but using all values for all tweens at all times, so we gave the animation a sense of continuity.</li>
<li>The third box uses the <code class="bg-gray">.to()</code> method, and will try and continue animation from last animation, but we "forgot" to keep track on the rotation of the X axis.</li>
<li>The last box also uses the <code class="bg-blue">.to()</code> method, and uses all values and reproduce the animation of the second box exactly, but with nearly half the code.</li>
</ul>
<h3>Notes</h3>
<ul>
<li>This demo page should work with IE10+ browsers.</li>
<li>The order of the transform functions/properties is always the same: <code>perspective</code>, <code>translation</code>, <code>rotation</code>, <code>skew</code>, <code>scale</code>, this way we can prevent
jumpy/janky animations; one of the reasons is consistency in all transform based components and another reason is the order of execution from the draft for
<a href="https://drafts.csswg.org/css-transforms-2/#recomposing-to-a-3d-matrix">matrix3d recomposition</a>.</li>
<li>Tests reveal that an element's own perspective produce better performance than using the parent's perspective. Also having both will severelly punish the animation performance, so keep that in mind
when you work on optimizing your code. </li>
<li>Use single axis transform functions like <code>translateX</code> when you want to animate the Y and Z axes back to ZERO, but in a convenient way.</li>
<li>Use shorthand functions like <code>translate3d</code> when you want to animate / keep multiple axes.</li>
<li>Shorthand functions like <code>translate3d</code> or <code>rotate3d</code> tween property generally not only improve performance, but will also minimize the code size. Eg. <code>translateX:150</code>,
<code>translateY:200</code>, <code>translateZ:50</code> => <code>translate3d:[150,200,50]</code> is quite the difference.</li>
<li>On larger amount of elements animating chains, the <code>.fromTo()</code> method is fastest, and you will have more work to do as well, but will eliminate any delay / syncronization issue that may occur.</li>
<li>This component is bundled with the <i>demo/src/kute-base.js</i> and the standard <i>kute.js</i> distribution files.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- <script src="./src/polyfill-legacy.min.js"></script> -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute.min.js"></script>
<!-- <script src="../dist/kute.js"></script> -->
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/transformFunctions.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>

214
transformMatrix.html Normal file
View file

@ -0,0 +1,214 @@
<!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, minimum-scale=1.0">
<meta name="description" content="The transformFunctions component for KUTE.js to enable your regular transform animations.">
<meta name="keywords" content="css3 transform matrix,transform,matrix3d,kute,kute.js,animation,javascript animation,tweening engine,animation engine,JavaScript,Native JavaScript,vanilla javascript,jQuery">
<meta name="author" content="dnp_theme">
<link rel="shortcut icon" href="./assets/img/favicon.ico">
<link rel="apple-touch-icon" href="./assets/img/apple-touch-icon.png">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,800|Roboto+Condensed:400,800" rel="stylesheet">
<title>KUTE.js Transform Matrix</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">
<!-- Synthax highlighter -->
<link href="./assets/css/prism.css" rel="stylesheet">
</head>
<body>
<div class="site-wrapper">
<div class="navbar-wrapper">
<div class="content-wrap">
<nav class="navbar">
<a href="index.html"><h1>KUTE.<span>js</span></h1></a>
<div class="nav-wrapper d-flex align-items-center justify-content-between">
<ul class="nav">
<li class="btn-group active"><a href="#" data-function="toggle">Components <span class="caret"></span></a>
<ul class="subnav">
<li><a href="transformFunctions.html">Transform Functions</a></li>
<li class="active"><a href="transformMatrix.html">Transform Matrix</a></li>
<li><a href="svgTransform.html">SVG Transform</a></li>
<li><a href="svgMorph.html">SVG Morph</a></li>
<li><a href="svgCubicMorph.html">SVG Cubic Morph</a></li>
<li><a href="svgDraw.html">SVG Draw</a></li>
<li><a href="filterEffects.html">Filter Effects</a></li>
<li><a href="borderRadius.html">Border Radius</a></li>
<li><a href="htmlAttributes.html">HTML Attributes</a></li>
<li><a href="shadowProperties.html">Shadow Properties</a></li>
<li><a href="colorProperties.html">Color Properties</a></li>
<li><a href="boxModel.html">Box Model</a></li>
<li><a href="clipProperty.html">Clip Property</a></li>
<li><a href="backgroundPosition.html">Background Position</a></li>
<li><a href="textProperties.html">Text Properties</a></li>
<li><a href="opacityProperty.html">Opacity Property</a></li>
<li><a href="scrollProperty.html">Scroll Property</a></li>
<li><a href="textWrite.html">Text Write</a></li>
</ul>
</li>
<li><a href="https://github.com/thednp/kute.js/wiki">Wiki</a></li>
</ul>
<ul id="share">
<li>
<a class="facebook-link" 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">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M1008 511.996c0 247.56-181.381 452.76-418.5 490v-346.62h115.561l22-143.381h-137.561v-93.1c0-39.221 19.221-77.461 80.82-77.461h62.561v-122s-56.762-9.68-111.041-9.68c-113.34 0-187.34 68.66-187.34 192.961v109.279h-126v143.381h126v346.62c-237.12-37.24-418.5-242.44-418.5-490 0-274 222-496 496-496s496 222 496 496z" fill="currentColor"></path></svg>
</a>
</li>
<li>
<a class="twitter-link" target="_blank" href="https://twitter.com/intent/tweet?text=Spread the word about %23KUTEJS animation engine by @dnp_theme and download here http://thednp.github.io/kute.js/index.html" title="Share KUTE.js on Twitter">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><path class="icon-demo" d="M886.579 306.995c0.41 8.294 0.563 16.691 0.563 24.986 0 255.488-194.406 549.99-549.888 549.99-109.21 0-210.739-32-296.294-86.886 15.155 1.792 30.515 2.714 46.08 2.714 90.624 0 173.926-30.925 240.026-82.688-84.531-1.587-155.955-57.395-180.531-134.195 11.776 2.202 23.91 3.379 36.352 3.379 17.664 0 34.765-2.304 50.944-6.707-88.422-17.818-155.034-95.898-155.034-189.594 0-0.819 0-1.587 0-2.406 26.061 14.49 55.91 23.194 87.552 24.218-51.866-34.714-86.016-93.798-86.016-160.922 0-35.379 9.523-68.608 26.214-97.178 95.283 116.992 237.773 193.894 398.387 201.984-3.277-14.182-4.966-28.877-4.966-44.083 0-106.701 86.477-193.178 193.229-193.178 55.603 0 105.83 23.398 141.107 60.979 43.981-8.704 85.35-24.781 122.726-46.899-14.438 45.107-45.107 82.995-84.992 106.906 39.117-4.71 76.288-15.002 111.002-30.413-25.907 38.81-58.675 72.806-96.461 99.994z" fill="currentColor"></path></svg>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="content-wrap">
<h2 class="head-title">Transform Matrix</h2>
<p class="condensed lead">The component covers all 3D <i>transform</i> functions and renders the update with either <i>matrix()</i> or <i>matrix3d()</i> functions, depending on the
functions used and their values. The notation is also fairly easy to use and familiar with other components.</p>
</div>
<div class="featurettes dark">
<div class="content-wrap">
<div class="columns">
<div class="col3">
<h3 class="border text-right">Overview</h3>
<p class="condensed text-right">The brand new component to enable complex <b>transform</b> animations of the future.</p>
</div>
<div class="col9 border">
<p class="lead condensed">The KUTE.js <b>Transform Matrix</b> component covers animation for the CSS3 <b>transform</b> style on <b>Element</b> targets but with a different implementation.</p>
<ul>
<li>The notation is a little different because we have a different supported functions/properties set, and the value processing function needs to differentiate the two components.</li>
<li>The 2D transform functions like <b>rotate</b>, <b>translate</b> or <b>scale</b> have been dropped to enable faster value processing and improved performance. The component is
geared towards the future of web development with this very specific purpose in mind.</li>
<li>Most importantly we have the update function which implements the <a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix">DOMMatrix()</a> API for smooth animation at no
performance cost, which is different from other libraries that use a <b>webkitCSSMatrix</b> polyfill and lose performance.</li>
<li>The script is robust, simple and light in size. It's simply a matter of taste when choosing between the two transform components.</li>
</ul>
<p>The component was developed for more complex transform animations and comes with additional supported transform functions. According to the W3 draft, the <b>DOMMatrix</b> API will merge the
fallback <b>webkitCSSMatrix</b> API and the <b>SVGMatrix</b> API together, so awesome is yet to come.</p>
<p>Due to execution complexity and other performance considerations, and similar to the <a href="transformFunctions.html">Transform Functions</a> component, this component provides support for a custom
<b>rotate3d[X,Y,Z]</b> tween property which is different from CSS3 standard <b>rotate3d(x,y,z,Angle)</b> shorthand function.</p>
<p>In certain situations you can also use functions like <b>scaleX</b>, <b>rotateY</b> or <b>translateZ</b> for convenience, but the component will always stack translations
into <b>translate3d</b>, all scale axes into <b>scale3d</b>, all rotations into <b>rotate3d</b> and both skews into <b>skew</b>.</p>
</div>
</div>
</div>
</div>
<div class="content-wrap">
<h3>3D Transform</h3>
<ul>
<li><kbd class="bg-indigo">perspective</kbd> function creates a 3D perspective for a target element transformation. EG. <code>perspective:400</code> to apply a 400px perspective.</li>
<li><kbd class="bg-indigo">translateX</kbd> function is for horizontal translation. EG. <code>translateX:150</code> to translate an element 150px to the right.</li>
<li><kbd class="bg-indigo">translateY</kbd> function is for vertical translation. EG. <code>translateY:-250</code> to translate an element 250px towards the top.</li>
<li><kbd class="bg-indigo">translateZ</kbd> function is for translation on the Z axis in a given 3D field. EG. <code>translateZ:-250</code> to translate an element 250px away from the viewer, making it
appear smaller. This function can be combined with the <code>perspective</code> function to take effect or the parent's perspective; the smaller perspective value, the deeper translation.</li>
<li><kbd class="bg-indigo">translate3d</kbd> shorthand function is for translation on all the axes 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. When third value is used, it requires using a <code>perspective</code>.</li>
<li><kbd class="bg-indigo">rotateX</kbd> function 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 on X axis.
Requires perspective.</li>
<li><kbd class="bg-indigo">rotateY</kbd> function 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 on Y axis.
Requires perspective.</li>
<li><kbd class="bg-indigo">rotateZ</kbd> function rotates an element on the Z axis and is the equivalent of the 2D rotation. Eg. <code>rotateZ:90</code> will rotate an element clockwise by 90 degrees on Z axis.</li>
<li><kbd class="bg-indigo">rotate3d</kbd> is a <b>tween property</b>, which combines the above <code>rotateX</code>, <code>rotateY</code>, and <code>rotateZ</code> functions and rotates an element on all axes.
Eg. <code>rotate3d:[250,-150,90]</code> will produce the same effect as the three above combined. The X and Y axes require a <code>perspective</code>.</li>
<li><kbd class="bg-indigo">skewX</kbd> function will apply a shear to a target element on the X axis. Eg. <code>skewX:50</code> will skew the element by 50 degrees on X axis.</li>
<li><kbd class="bg-indigo">skewY</kbd> function will apply a shear to a target element on the Y axis. Eg. <code>skewY:-50</code> will skew the element by -50 degrees on Y axis.</li>
<li><kbd class="bg-indigo">skew</kbd> shorthand function will apply a shear on both X and Y axes to a target element. Eg. <code>skew:[50,50]</code> will skew a target element on X axis by 50 degrees and 50 degrees on Y axis.</li>
<li><kbd class="bg-indigo">scaleX</kbd> function will scale the X axis of a target element. Eg. <code>scaleX:1.5</code> will increase the scale of a target element on the X axis by 50%.</li>
<li><kbd class="bg-indigo">scaleY</kbd> function will scale the Y axis of a target element. Eg. <code>scaleY:0.5</code> will decrease the scale of a target element on the Y axis by 50%.</li>
<li><kbd class="bg-indigo">scaleZ</kbd> function will scale the Z axis of a target element. Eg. <code>scaleZ:0.75</code> will decrease the scale of a target element on the Z axis by 25%.</li>
<li><kbd class="bg-indigo">scale3d</kbd> function will scale a target element on all axes. Eg. <code>scale3d:[1.5,0.5,0.75]</code> will produce the same effect as the 3 above combined.</li>
<li><kbd class="bg-blue">matrix</kbd> and <kbd class="bg-blue">matrix3d</kbd> are not supported CSS3 transform functions or tween properties, but the results of the update function.</li>
</ul>
<h3>Example</h3>
<p>Now let's have a look at the notation and a quick example:</p>
<pre><code class="language-javascript">let mx1 = KUTE.to('el1', { transform: { translate3d:[-50,-50,-50]} })
let mx2 = KUTE.to('el2', { transform: { perspective: 100, translateX: -50, rotateX:-180} })
let mx3 = KUTE.to('el3', { transform: { translate3d:[-50,-50,-50], skew:[-15,-15]} })
let mx4 = KUTE.to('el4', { transform: { translate3d:[-50,-50,-50], rotate3d:[0,-360,0], scaleX:0.5 } })
</code></pre>
<div id="matrix-examples" class="featurettes" style="perspective: 400px">
<div class="example-item example-box bg-indigo">MX1</div>
<div class="example-item example-box bg-olive">MX2</div>
<div class="example-item example-box bg-pink">MX3</div>
<div class="example-item example-box bg-red">MX4</div>
<div class="example-buttons">
<a class="btn btn-blue" href="javascript:void(0)">Start</a>
</div>
</div>
<p>So the second element uses it's own perspective but notice that the parent perspective also apply. This case must be avoided in order to keep performance in check: one perspective is best.</p>
<h3>Chained Transformations</h3>
<p>Similar to the <a href="transformFunctions.html">other component</a> the Transform Matrix component will produce the same visual experience, but with the <code>matrix3d</code> function.</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-gray" style="font-size: 30px">TO</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>
<h3>Notes</h3>
<ul>
<li>This demo page should work with IE10+ browsers.</li>
<li>Why no support for the <code>matrix3d</code> function? Simple: we can of course interpolate 16 numbers super fast, but we won't be able to rotate on any axis above 360 degrees.
As <a href="https://stackoverflow.com/a/39870758/803358">explained here</a>, surely for performance reasons the browsers won't try and compute angles above 360 degrees, but simplify
the number crunching because a 370 degree rotation is visualy identical with a 10 degree rotation.</li>
<li>The component does NOT include any scripting for matrix decomposition/unmatrix, after several years of research I came to the conclusion that there is no such thing to be reliable.
Such a feature would allow us to kick start animations directly from <code>matrix3d</code> string/array values, but considering the size of this component, I let you draw the conclusions.</li>
<li>Despite the "limitations", we have some tricks available: the <code>fromTo()</code> method will never fail and it's much better when performance and sync are a must, and for <code>to()</code>
method we're storing the values from previous animations to have them ready and available for the next chained animation.</li>
<li>The performance of this component is identical with the <b>Transform Functions</b> component, which is crazy and awesome, all that thanks to the <b>DOMMatrix</b> API built into our modern browsers.
If that's not good enough, the API will automatically switch from <code>matrix3d</code> to <code>matrix</code> and vice-versa whenever needed to save power. Neat?</li>
<li>The <code>rotate3d</code> property makes alot more sense for this component since the <b>DOMMatrix</b> <code>rotate(angleX,angleY,angleZ)</code> method works exactly the same, while the
<code>rotate3d(vectorX,vectorY,vectorZ,angle)</code> function is a thing of the past, according to <a href="https://css-tricks.com/">Chris Coyier</a> nobody use it.</li>
<li>Since the component fully utilize the <b>DOMMatrix</b> API, with fallback to each browser compatible API, some browsers still have in 2020 an incomplete CSS3Matrix API, for instance privacy browsers
like Tor won't work with rotations properly for some reason, other proprietary mobile browsers may suffer from same symptoms. In these cases a correction polyfill is required.</li>
<li>This component is bundled with the <i>demo/src/kute-extra.js</i> distribution file.</li>
</ul>
</div>
<!-- FOOTER -->
<footer>
<div class="content-wrap">
<p class="pull-right"><a id="toTop" href="#">Back to top</a></p>
<p>&copy; 2015 - 2021 &middot; <a href="https://github.com/thednp">thednp</a>.</p>
</div>
</footer>
</div>
<!-- /.site-wrapper -->
<!-- JavaScript =============================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./src/polyfill.min.js"></script>
<script src="./src/kute-extra.min.js"></script>
<script src="./assets/js/prism.js"></script>
<script src="./assets/js/transformMatrix.js"></script>
<script src="./assets/js/scripts.js"></script>
</body>
</html>