Compare commits

..

290 commits

Author SHA1 Message Date
thednp
ae0b200694 Some cleanup 2021-12-29 18:42:20 +02:00
thednp
91fb7aad8f Update svgMorph.html 2021-12-27 17:34:42 +02:00
thednp
3835b6e95c Updated to latest SVGPathCommander 2021-12-27 17:33:05 +02:00
thednp
5c8b75f15b V 2.2.0 2021-12-10 09:22:21 +02:00
thednp
8f5c58195e Update package.json 2021-12-10 09:16:06 +02:00
thednp
0dac43bc88 1 2021-12-10 09:01:35 +02:00
thednp
a17bacbd58 Update svgMorph.html 2021-12-09 00:18:36 +02:00
thednp
2a5bac2bb3 Changes V2.2.0:
* major JSDoc write up
* removed ESLint `no-bitwise` exception, it only applies to specific functions and not the entire code
* the `SVGCubicMorph` component will remove un-necessary `Z` path commands when is the case for better out of the box animation
* fixed a minor disambiguation with `filterEffects` and `drop-shadow` property and its `dropshadow` interpolation function
* TypeScript strong: all files are modules, easy to implement in any third party app
* updated `CubicBezier` and SVGPathCommander
* code cleanup
2021-12-08 23:43:31 +02:00
thednp
e5456b86e9 Changes:
* added a more consistent Typescript generate tsconfig.json
* in regards to Typescript, all internals/externals well defined
2021-11-13 18:51:59 +02:00
thednp
d96d08a36b Update 2021-11-13 12:24:30 +02:00
thednp
0290fa67cb Update package.json 2021-11-13 08:58:10 +02:00
thednp
5dfbf91ce3 Update now.js 2021-11-12 18:14:07 +02:00
thednp
c786e062c0 Test 2021-11-12 18:05:53 +02:00
thednp
cd0898b67f Test 2021-11-12 17:58:48 +02:00
thednp
b70d46d387 Changes:
* added Typescript support
* added Typescript generate `index.d.ts` script
* fixed minor `textWrite` component type error
* reworked the index source files
2021-11-12 15:30:52 +02:00
thednp
f56e19369a Update now.js
Co-Authored-By: Thamjith Thaha <jithuthaha8@gmail.com>
Co-Authored-By: Frederic R. <frederic.rousseau@storyful.com>
2021-11-10 17:09:00 +02:00
thednp
b36f26195c Attempt to address #109
Please test latest master

Co-Authored-By: Thamjith Thaha <jithuthaha8@gmail.com>
Co-Authored-By: Frederic R. <frederic.rousseau@storyful.com>
2021-11-10 17:05:07 +02:00
thednp
ebd86bf9e3 2021-05-31 08:37:02 +00:00
thednp
b0f6220413 Changes:
* updated dependencies
* ESM is now ES6+
2021-05-31 07:47:30 +00:00
thednp
0efd9a10e4 Easing 'easingCircularOut' typo. 2021-03-31 08:29:41 +00:00
thednp
2a309434c1 Fixed some IE issues with new code base. 2021-03-31 08:08:58 +00:00
thednp
a1f59fe181 2021-03-30 11:26:50 +00:00
thednp
c011a9368b 2021-03-30 11:19:27 +00:00
thednp
933d61de19 Changes:
* added ESLint and updated all code base 
* updated SVGPathCommander, CubicBezier, shorter-js, minifill
* updated polyfills
* minor CSS fixes
2021-03-30 09:23:29 +00:00
thednp
bfc3fabc92 Changes:
* updated SVGPathCommander
* fixed small typo issue with SVGDraw
* version bump
2021-01-09 13:31:00 +00:00
thednp
14585d7a51 2020-09-24 05:07:47 +00:00
thednp
2ad17fdd00 2020-09-24 04:57:49 +00:00
thednp
0b7fd91bab 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:39 +00:00
thednp
85d9c09ede Changes:
* Solved some minor issue with `pathToCurve` utility
* Updated SVGPathCommander
2020-09-02 13:26:47 +00:00
thednp
7a782229dd Changes (big update):
* updated SVGPathCommander to support a wider range of shapes, including closed/unclosed shapes
* added d3-polygon dependency for ***svgMorph*** component
* updated both ***svgMorph*** and ***svgCubicMorph*** components
* updated polyfill
* code cleanup
* documentation updates
2020-08-31 15:39:43 +00:00
thednp
730583caff 2020-08-18 12:32:22 +00:00
thednp
0528e3a0af Changes:
* updated `svg-path-commander`, solving an important path processing script `a2c` for `arcTo` path commands with `largeArcFlag` values
* solved some build tools issues (unzipped was working, zipped wasn't)
2020-08-18 12:23:26 +00:00
thednp
b0a6495748 Changes:
* replaced some path processing with SVGPathCommander
* minor improvements
2020-08-16 20:20:36 +00:00
thednp
b152aa8fa6 Solves #103 2020-08-14 11:51:10 +00:00
thednp
65a56cd338 Changes:
* KUTE.js now works when added to `<head>` but tween object initialization scripting must be added after `<body>` or when new `Element` target is appended into document
* updated `shorter-js`
2020-07-27 09:42:21 +00:00
thednp
64ac54a4d0 Changes:
* typo in svgMorph components/svgMorph.js
2020-07-03 09:25:03 +00:00
thednp
da4a2108f8 2020-07-02 10:57:32 +00:00
thednp
6bfa00da75 Changes:
* Added a Spicr demo to the index.page.
* Some demo updates
2020-07-02 10:50:04 +00:00
thednp
ce0a5192b3 2020-06-24 05:45:15 +00:00
thednp
072a61533c 2020-06-24 05:39:57 +00:00
thednp
9d9e02fa65 Allow transform components to work with pre-processed values 2020-06-23 22:08:42 +00:00
thednp
3be6838993 2020-06-23 22:00:15 +00:00
thednp
610ae90742 2020-06-23 21:59:48 +00:00
thednp
ffa69326af 2020-06-23 16:41:57 +00:00
thednp
000af8a625 2020-06-23 16:38:58 +00:00
thednp
3ce5b8b590 2020-06-20 10:24:37 +00:00
thednp
591871079b
Add files via upload 2020-06-20 10:13:17 +00:00
thednp
0e2da1baa1 2020-06-20 10:08:45 +00:00
thednp
ac5c5355b7 2020-06-20 10:07:50 +00:00
thednp
2119e600ef 2020-06-20 10:07:20 +00:00
thednp
f1dbb2d996 2020-06-20 09:31:19 +00:00
thednp
af00968b58 Code cleanup 2020-06-20 09:23:25 +00:00
thednp
be367debe0 Changes:
* updated `shorter-js`
* improved scrollProperty for lighter size
2020-06-18 08:25:35 +00:00
thednp
5603a3bc8e 2020-06-16 15:22:17 +00:00
thednp
4d5c37e958 2020-06-16 15:17:53 +00:00
thednp
0e7e4ce817 Changes:
* added a proper BASE version for all components
* replaced transformFunctions with transformMatrix in index-base.js
* fixed crossBrowserMove.js sample component
* demo fixes
2020-06-16 14:40:58 +00:00
thednp
fed9662776 Minor changes 2020-06-12 08:04:59 +00:00
thednp
62d5ae1f83 Changes:
* some reorganizing of the index files
* demo fixes
2020-06-12 06:13:10 +00:00
thednp
12ad62fd09 2020-06-11 15:41:55 +00:00
thednp
e6a776770d Changes:
* Removed `scrollProperty` from official build , thanks to `scroll-behavior: smooth`
* Code Cleanup
2020-06-11 15:32:05 +00:00
thednp
95947f5af8 2020-06-11 05:05:52 +00:00
thednp
7a39544cf0 Changes:
* demo updates
* README.md updates
* code cleanup
2020-06-11 05:03:44 +00:00
thednp
645089f77a 2020-06-10 14:33:11 +00:00
thednp
f3d0789447 2020-06-10 13:40:52 +00:00
thednp
0435d00b11 Changes:
* fixed polyfill 
* fixed IE10+ issues with scroll 
* reworked files and folders structure of the sources
* solved some demo issues
* code cleanup
* version bump
2020-06-10 13:24:42 +00:00
thednp
b3ba7299a0 2020-06-09 21:34:22 +00:00
thednp
3cd0db546f 2020-06-09 20:46:23 +00:00
thednp
c8b6d85ea0 2020-06-09 20:23:18 +00:00
thednp
9212dcaeec 2020-06-09 20:21:51 +00:00
thednp
db2595d8d0 Changes in relation to #97 2020-06-09 20:06:26 +00:00
thednp
00fbc38624 Added a simple example for #96 2019-11-07 17:49:12 +02:00
thednp
c16efd44d6 2019-02-10 13:56:02 +02:00
thednp
c753ade57c Bump version 2019-02-01 12:48:31 +02:00
thednp
7d7bd32572 Removed jQuery plugin from documentation 2019-02-01 12:42:34 +02:00
thednp
7105d48d41 Changes:
* Removed jQuery plugin, moved into experiments branch
* Updated demo pages
* Updated build script
* Updated dist files
2019-02-01 12:04:45 +02:00
thednp
f296ffcd56 Trying to solve scroll with EDGE/Safari 2018-11-05 13:27:05 +02:00
thednp
ccd505f6d8 Cleanup 2018-10-19 08:56:08 +03:00
thednp
fafbf484df Another typo. 2018-10-19 08:47:48 +03:00
thednp
207597efe7 Typo 2018-10-18 12:09:24 +03:00
thednp
c48200ae47 Fix SVG Plugin function getPolyLength for <polyline> elements. 2018-10-18 11:47:40 +03:00
thednp
1434ac02fb Added callback reference #73 2018-07-19 09:25:27 +03:00
thednp
3c829c3475 A possible fix for #81 2018-07-19 08:39:09 +03:00
thednp
65278aed53 Bump version. 2017-10-05 13:01:59 +03:00
thednp
4b78605396 Update start.html 2017-10-05 12:57:15 +03:00
thednp
9cc657b7bf Update dist files. 2017-10-05 12:55:27 +03:00
thednp
c36e4d1967 2017-10-03 01:32:29 +03:00
thednp
e0d52535f6 2017-10-03 01:32:00 +03:00
thednp
73adb8344f 2017-10-03 01:10:01 +03:00
thednp
f85ecef387 Bump version 2017-09-29 01:21:32 +03:00
thednp
92a37f453b Update README.md 2017-09-29 01:09:09 +03:00
thednp
751c2e5263 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:16 +03:00
thednp
ba6c529146 Update README.md 2017-09-11 23:08:22 +03:00
thednp
16a3eb387c Update Twitter share links. 2017-09-08 11:43:17 +03:00
thednp
40fd867115 A better typo. 2017-05-29 20:37:42 +03:00
thednp
ba91cd6630 Improvement for https://github.com/thednp/kute.js/issues/63 2017-05-29 16:03:57 +03:00
thednp
2cb0800aed Changes:
* code cleanup, more readable code in plugins
* documentation fixes, the easing selectors fixed
2017-02-02 01:23:19 +02:00
thednp
3215d770b4 Changes:
* improved `selector` utility
* improved/simplified `getPrefix()` utility
* improve code readability for the core engine
* improved demos
2017-01-31 19:15:15 +02:00
thednp
38fcf9c127 Merge pull request #54 from danielosborn/master
Corrected UMD wrappers in plugins files to match the kute-jquery wrap…

Thanks @danielosborn
2017-01-27 20:11:03 +02:00
Daniel Osborn
a8ca9a5317 Corrected UMD wrappers in plugins files to match the kute-jquery wrapper. Changed the require checks from 'kute.js' to './kute.js' to look for the actual files. The kute-jquery already used this method and would successfully compile while the other plugins would not compile and throw an error: 'Cannot find module kute.js' 2017-01-27 10:16:14 -07:00
thednp
b6c64774aa Changes:
* Disabled SVG Plugin related scripts on IE8
* Some documentation fine tuning
2017-01-23 18:54:57 +02:00
thednp
4b2cfda1c2 Minor documentation fixes:
* Documentation updates
* Fixed navigation on IE8
2017-01-23 15:55:12 +02:00
thednp
e0bc5cf8a2 Some minor documentation fixes. 2017-01-14 23:07:43 +02:00
thednp
132a6246c0 Fixed missing default value for repeatDelay. 2017-01-14 22:03:18 +02:00
thednp
9348792e2d 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
0433d479d7 Mostly doc updates 2016-12-20 22:06:23 +02:00
thednp
eee3554bd0 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
0e917b933b 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
842f12bcf1 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
b8fc991476 LOL 2016-12-11 04:24:18 +02:00
thednp
095078005f typo 2016-12-11 03:58:47 +02:00
thednp
fc75dd130f 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
308ee60bf5 Issue with text plugin demo 2016-11-30 18:48:20 +02:00
thednp
2679a232be Small typo with Attributes plugin 2016-11-30 18:18:53 +02:00
thednp
67c47a6f08 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
70ee2a448a Testing new build. 2016-11-28 03:07:16 +02:00
thednp
1a44fbe465 2016-11-26 19:00:32 +02:00
thednp
a92a45f77f 2016-11-26 18:31:59 +02:00
thednp
c3b06308c3 2016-11-26 18:24:30 +02:00
thednp
d92fed514e 2016-11-26 18:22:38 +02:00
thednp
032f047c6c 2016-11-26 18:15:00 +02:00
thednp
f01ed026a6 2016-11-26 18:00:23 +02:00
thednp
72a915c051 Documentation updates and performance test page reworked with safety features. 2016-11-26 17:47:17 +02:00
thednp
7aa15a43b5 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
bda5756889 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
545e253a30 2016-11-23 20:47:09 +02:00
thednp
124a0521d1 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
de86e786c4 Merge pull request #44 from virajsoni06/patch-1
Updating UglifyJS version to make it work with bower
2016-10-17 15:17:28 +03:00
Viraj Soni
de2fe03985 Updating UglifyJS version to make it work with bower 2016-10-17 17:21:46 +05:30
thednp
21210c2dd7 Removed some recursion from plugins. 2016-10-13 15:32:23 +03:00
thednp
72dea56f33 Minor issue with trueColor fixed after previously changed. 2016-10-13 06:09:23 +03:00
thednp
a6c0be41df Type 2016-10-13 05:46:00 +03:00
thednp
0b8d77c19b 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
35a4cdb8c0 Docs 2016-10-11 11:19:45 +03:00
thednp
e61bc99ec4 docs 2016-10-10 02:34:32 +03:00
thednp
0bebda1eff docs 2016-10-09 07:58:02 +03:00
thednp
e165c10d40 Small fix to prevent Uncaught RangeError: Maximum call stack size exceeded error. 2016-10-09 06:10:41 +03:00
thednp
927bb7e9c0 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
6b5623b20a Related to CommonJS https://github.com/thednp/kute.js/issues/40#issuecomment-252348599 2016-10-07 23:10:34 +03:00
thednp
ccb5e6ba73 Attempting to fix https://github.com/thednp/kute.js/issues/40 2016-10-07 22:59:35 +03:00
thednp
eb9926c028 Typo 2016-10-04 14:41:36 +03:00
thednp
f22be9f8b4 Documentation typo and README updates 2016-10-04 14:39:34 +03:00
thednp
1b061eb9a3 2016-10-03 19:42:44 +03:00
thednp
975216e633 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
b267bd0422 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
ff5d6d139b Type 2016-09-24 12:12:29 +03:00
thednp
a16720199a 2016-09-24 11:02:21 +03:00
thednp
f2eff7ddbe 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
877005df3b 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
3d7f6721b9 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
97b4fe4dcf 2016-09-23 00:43:58 +03:00
thednp
3a1f0b20e7 2016-09-22 21:11:57 +03:00
thednp
5947a72e74 More experiments. 2016-09-22 20:58:25 +03:00
thednp
c83fbc8862 2016-09-22 16:20:30 +03:00
thednp
576ce620df Experimenting with exporting stuff to KUTE object, suspecting a bug with Google Chrome 2016-09-22 15:24:49 +03:00
thednp
1fb54ed2d2 Register additional interpolate functions into the object 2016-09-22 14:46:03 +03:00
thednp
b67960952e Type 2016-09-22 14:42:06 +03:00
thednp
728af0a801 Code cleanup 2016-09-22 05:26:43 +03:00
thednp
2960ff6d73 Update package.json 2016-09-21 02:42:03 +03:00
thednp
1288e1ec89 Testing the build.js 2016-09-21 02:03:57 +03:00
thednp
5e6b933bec Update package.json 2016-09-21 01:34:20 +03:00
thednp
4b42fa40e4 Create build.js 2016-09-21 01:07:50 +03:00
thednp
cc332f0745 Minor fix/improvement with Attributes Plugin regarding current attribute value suffix. 2016-09-20 23:32:11 +03:00
thednp
b83bb95a1e 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
56a0045f89 Minor fix 2016-09-20 06:52:42 +03:00
thednp
d1e016185b 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
c6e7caabc6 Now the Attributes Plugin should be able to handle properties like 'stroke-width' or fillOpacity 2016-09-20 06:30:53 +03:00
thednp
df9554252c Hopefully fixing https://github.com/thednp/kute.js/issues/35 2016-09-19 20:17:17 +03:00
thednp
9cb1753073 Docs update 2016-09-18 01:16:02 +03:00
thednp
ed9f814594 Decreased default morphPrecision from 25 to 15 for better visual. 2016-09-18 01:07:15 +03:00
thednp
f631185602 Replaced prototype with regular object for AttrPlugin I hope it's for better performance 2016-09-18 01:03:06 +03:00
thednp
c37c404dfe Update README.md 2016-09-13 17:14:47 +03:00
thednp
b2c7ab6564 Missing share icons in svg.html page 2016-09-12 17:47:42 +03:00
thednp
e49bce0e20 Update package.json 2016-09-12 17:41:50 +03:00
thednp
1fbfbc58c7 Update bower.json 2016-09-12 17:41:34 +03:00
thednp
3819cd0f3a 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
ee713e86c4 Quick docs update 2016-09-07 19:09:41 +03:00
thednp
a30eab2ff9 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
3e1eb06d26 Update README.md 2016-08-22 17:26:14 +03:00
thednp
984fa6a5f1 Update bower.json 2016-08-22 17:24:36 +03:00
thednp
f46e780271 Update package.json 2016-08-22 17:24:11 +03:00
thednp
645a0027b8 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
67c441ccab https://github.com/thednp/kute.js/issues/32 2016-08-22 02:21:37 +03:00
thednp
fa5d69ed3e * Added SVG Transforms for SVG Plugin
* Documentation/demo updates
2016-08-22 01:45:23 +03:00
thednp
362293626f Added support for stroking animation via draw for <ellipse>, some demo improvements. 2016-08-21 00:11:42 +03:00
thednp
ef5da213c1 2016-08-20 16:46:16 +03:00
thednp
6c8b49ea8a Small demo improvements. 2016-08-20 16:44:53 +03:00
thednp
f3414f6551 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
a514d71f61 2016-08-19 01:30:41 +03:00
thednp
571b96e2a9 2016-08-19 01:12:53 +03:00
thednp
4faa433429 Fixed Angular related issue with SVG Plugin.
https://github.com/thednp/kute.js/issues/29
2016-08-18 22:28:15 +03:00
thednp
7873233e39 Some documentation updates and social sharing fixes. 2016-08-17 23:40:42 +03:00
thednp
028ed99e64 Documentation updates, now we have cdnjs repository.
https://cdnjs.com/libraries/kute.js
2016-08-16 19:24:13 +03:00
thednp
10d47b89da Update bower.json 2016-07-25 18:38:49 +03:00
thednp
4fca28e269 Update package.json 2016-07-25 18:38:37 +03:00
thednp
dc17bd3ed5 2016-03-28 16:07:31 +03:00
thednp
053a1bc2f9 Update kute-svg.min.js 2016-03-27 23:32:10 +03:00
thednp
e33733f4f3 Added a codepen example for SVG, plus more SEO improvements. 2016-03-27 16:20:24 +03:00
thednp
92060dcaab Some SEO fixes. 2016-03-26 21:27:48 +02:00
thednp
cb48bf3c90 Minor issue with opacity, scale. 2016-03-25 19:56:46 +02:00
thednp
a1e983c8a2 Delete kute-timeline.js 2016-03-25 11:43:48 +02:00
thednp
b24989dd71 Merge pull request #19 from dalisoft/patch-5
Create kute-timeline.js
2016-03-25 11:41:01 +02:00
dalisoft
63ab15de08 Create kute-timeline.js
```html

<!DOCTYPE html><html class=''>
<head>


<style class="cp-pen-styles">
.dv {
  width: 100px; height: 100px; float: left; 
  text-align: center; line-height: 100px; 
  margin: 20px 20px 20px 0;
  background: #0cf;
  position: relative;
}
</style>
</head><body>

<div class="dv"></div>
<div class="dv"></div>
<div class="dv"></div>
<div class="dv"></div>
<div class="dv"></div>


<script src='kute.js'></script>
<script src='kute-timeline.js'></script>
<script>

	var tl = new KUTE.Timeline();
		tl.fromTo('.dv', { rotate : 0 }, { rotate : 45 }, { easing : { rotate : 'easingBounceInOut' }, offset : { rotate : 200 } })
		tl.to('.dv', { left : 200 }, { easing : { left : 'easingElasticInOut'}, offset: 300 });
		tl.to('.dv', { top : 200 }, { easing : { top : 'easingElasticInOut' }, offset: 300, duration : 1000 });
		tl.to('.dv', { width : 45 }, { easing : { width : 'easingElasticInOut' }, offset: 200, duration : 1000 });
		tl.to('.dv', { height : 45 }, { easing : { height : 'easingElasticInOut' }, offset: 200, duration : 1000 });
		
</script>
</body></html>
```
2016-03-25 14:19:32 +05:00
thednp
40fb142db5 Update README.md 2016-03-24 22:54:06 +02:00
thednp
01189cb038 Update README.md 2016-03-24 22:49:22 +02:00
thednp
ba5a405627 Update README.md 2016-03-24 22:46:59 +02:00
thednp
688b036437 Update README.md 2016-03-24 22:45:53 +02:00
thednp
ba21f97e34 Update README.md 2016-03-24 22:44:21 +02:00
thednp
f4e58a5126 2016-03-24 14:49:42 +02:00
thednp
162803f6c8 2016-03-24 14:48:26 +02:00
thednp
f4576d4bca Update package.json 2016-03-24 14:31:50 +02:00
thednp
7527628aef Update bower.json 2016-03-24 14:31:29 +02:00
thednp
6176a75fe1 Update package.json 2016-03-24 14:30:56 +02:00
thednp
5bbb709361 Update bower.json 2016-03-24 14:30:07 +02:00
thednp
2564472f53 Final version 1.5 commit. 2016-03-24 14:27:27 +02:00
thednp
97b6608392 Update README.md 2016-03-24 12:57:02 +02:00
thednp
92f8dcc338 Update README.md 2016-03-23 15:43:00 +02:00
thednp
49a418b24e Update README.md 2016-03-23 15:24:58 +02:00
thednp
d24f73d811 Update README.md 2016-03-23 15:20:11 +02:00
thednp
35dc80161b minor IE8 demo fix 2016-03-19 10:08:34 +02:00
thednp
41e87cc4b2 2016-03-18 19:18:55 +02:00
thednp
bf2574d082 Update README.md 2016-03-18 19:13:28 +02:00
thednp
aa59078591 Added Text Plugin, updated docs 2016-03-18 16:23:23 +02:00
thednp
83ab68ad74 2016-03-17 16:54:13 +02:00
thednp
afdfa1ae49 typo 2016-03-17 09:00:32 +02:00
thednp
3a7857bbe5 2016-03-16 16:28:07 +02:00
thednp
dc820c5654 The 1.5 first commit, still testing, changelog in the comments 2016-03-16 15:44:23 +02:00
thednp
320cc59b05 2016-03-16 15:42:03 +02:00
thednp
05bad2c336 2016-02-06 01:05:18 +02:00
thednp
b31ed62fe6 2016-02-06 00:32:31 +02:00
thednp
ca7fc23fcc 2016-02-06 00:19:14 +02:00
thednp
b3be076328 Update package.json 2016-02-06 00:12:54 +02:00
thednp
859e8a7fb2 Update bower.json 2016-02-06 00:12:51 +02:00
thednp
b1550f1111 Update package.json 2016-02-06 00:10:02 +02:00
thednp
12512274aa 1.0.1 first commit
* new changes to the prototype to allow more flexibility and performance
* introducing 2 new methods .allTo() and .allFromTo for collections of elements
* added a new tween option for the new methods called offset to set a delay between animations of these collections of elements
* removed deprecated method .Animate()
* improved performance for the render functions
* added support for transformOrigin tween setting
* documentation updates
* 'fixed' the additional tools UMD scripting
2016-02-05 23:19:34 +02:00
thednp
057cabde2a 2016-02-04 15:29:27 +02:00
thednp
0276f0ef74 Update README.md 2016-02-01 21:01:43 +02:00
thednp
2ebb6df047 Update README.md 2016-01-22 00:46:51 +02:00
thednp
36f97142fe Update README.md 2016-01-15 01:17:18 +02:00
thednp
acfce66a51 Update README.md 2015-12-30 23:04:39 +02:00
thednp
2075084410 Update README.md
some updates and fixes for the documentation.
2015-12-30 22:32:35 +02:00
thednp
eb73a1ba4f Update README.md 2015-12-30 18:23:16 +02:00
thednp
e181788367 Update README.md 2015-12-30 18:21:55 +02:00
thednp
e8e2698ea2 Update api.html 2015-12-30 01:50:12 +02:00
thednp
32a741ab20 Update package.json 2015-12-30 00:32:38 +02:00
thednp
480ece6a9c Update bower.json 2015-12-30 00:32:16 +02:00
thednp
026f4201ae Update kute.min.js 2015-12-20 23:06:08 +02:00
thednp
6872923046 Update kute.min.js 2015-12-20 23:02:22 +02:00
thednp
40f121ab8e Update kute.js 2015-11-19 12:30:34 +02:00
thednp
934d666859 Update kute.js
Improvements according to Dav's suggestion https://github.com/thednp/kute.js/pull/11
2015-11-19 11:40:13 +02:00
thednp
976fc30493 Update README.md 2015-11-02 11:58:02 +02:00
thednp
6181d45689 Update bower.json 2015-11-02 01:25:45 +02:00
thednp
e9a4daa8be Update package.json 2015-11-02 01:24:55 +02:00
thednp
50291a49a5 Merge pull request #9 from IngwiePhoenix/master
UMD, NPM + Bower
2015-11-02 01:14:07 +02:00
Ingwie Phoenix
462a4d254b Ignoring PKM files. 2015-11-01 21:55:45 +01:00
Ingwie Phoenix
189241b87c jQuery added as dependency. 2015-11-01 21:55:32 +01:00
Ingwie Phoenix
e2aa72e14b NPM/Bower and UMD support.
- Supports `require()` and `define()` style loading.
- Is available on Bower through Git tags. Not yet via NPM. (run `npm publish` inside the project to do so)
- README updated with hint of usability with module loaders

In the code:
- Implemented UMD method, using AMD in first instance.
- Error is thrown is the root KuteJS could not be found.

What is missing:
- Sub-modules should export their factory rather than doing this on their own.
2015-11-01 21:51:51 +01:00
thednp
37348c3609 Update README.md 2015-10-30 08:28:08 +02:00
thednp
5c80b15fb7 Update README.md 2015-10-30 08:18:39 +02:00
thednp
b041dfea55 Update README.md 2015-10-30 08:07:00 +02:00
thednp
0bde518b4f Update README.md 2015-10-30 08:06:11 +02:00
thednp
03b1511580 Update README.md 2015-10-30 08:04:38 +02:00
thednp
ce5a8c83b9 2015-10-26 13:04:58 +02:00
thednp
402edc2b35 2015-10-26 12:04:54 +02:00
thednp
3c7d277ca1 Update kute.min.js 2015-10-26 11:19:53 +02:00
thednp
8e21120720 Update kute.js
Added better legacy browser detection, without `documentdocumentElement.className`
2015-10-26 11:19:10 +02:00
thednp
ef92d0938b 2015-10-26 08:36:48 +02:00
thednp
a6dc3fd339 Update README.md 2015-10-21 11:19:04 +03:00
thednp
ecd63491e3 fixed tween.min.js file 2015-10-18 20:38:49 +03:00
thednp
69f7757ce0 2015-10-18 18:52:36 +03:00
thednp
b8e7af39fa 2015-10-18 10:19:08 +03:00
thednp
b99fb1b38c 2015-10-18 09:42:40 +03:00
thednp
ad727aad34 Added some more features, a changelog will come with the tagged release. 2015-10-18 09:40:11 +03:00
thednp
15df42234c Update kute.jquery.js 2015-08-04 05:56:16 +03:00
thednp
6d60e6d436 Update kute.jquery.js 2015-07-06 16:17:38 +03:00
thednp
ef8b8d1726 Update README.md 2015-05-21 18:31:07 +03:00
thednp
dafded11c5 Update README.md 2015-05-21 18:30:41 +03:00
thednp
e0ea467152 Update kute.min.js 2015-05-03 05:17:44 +03:00
thednp
5525e0774d Update kute.full.min.js 2015-05-03 05:16:52 +03:00
thednp
bffc33ee1e Merge pull request #7 from dalisoft/performance-optimization
Performance optimization is a much needed fix for the reported issue
https://github.com/thednp/kute.js/issues/5
2015-05-03 04:46:32 +03:00
Shavkatov Davlat Talatovich
b052b7f2f4 Update kute.js 2015-05-03 06:43:18 +05:00
Shavkatov Davlat Talatovich
ae8d72159e Update kute.full.js 2015-05-03 06:40:25 +05:00
Shavkatov Davlat Talatovich
e1acdfd42d Update kute.full.js 2015-05-03 06:32:53 +05:00
Shavkatov Davlat Talatovich
9007ce79ed Update kute.js 2015-05-03 06:29:22 +05:00
thednp
5aea8340fe Merge pull request #3 from dalisoft/patch-1
Mini issue fix
2015-04-29 14:21:29 +03:00
Shavkatov Davlat Talatovich
587f4c0de2 Mini issue fix
Mini issue fix for jQuery plug-in example
2015-04-29 11:57:57 +05:00
thednp
fa56bbfbf4 Update kute.min.js 2015-04-29 03:30:33 +03:00
thednp
5e5e95108c Update kute.full.min.js 2015-04-29 03:29:54 +03:00
thednp
9ca0ba1e75 Update kute.full.js 2015-04-29 03:28:44 +03:00
thednp
5d58a5bffd Update kute.js
Small typo fixed, also rearranged transform propertied by vendor to increase performance.
2015-04-29 03:28:14 +03:00
thednp
25cc86e192 Update README.md 2015-04-24 21:03:31 +03:00
211 changed files with 19963 additions and 14 deletions

41
.eslintrc Normal file
View file

@ -0,0 +1,41 @@
{
"extends": [
// Extend the airbnb eslint config
"airbnb-base"
// Vue
// "plugin:vue/vue3-recommended"
],
// "parser": "vue-eslint-parser",
// "parser": "eslint-plugin-vue",
"parserOptions": {
"sourceType": "module"
},
// ESLint will not look in parent folders for eslint configs
"root": false,
// An environment defines global variables that are predefined.
"env": {
"browser": true,
"es6": true,
"node": true
},
// Rule overrides
"rules": {
// Disable no-restricted-globals for global objects
"no-restricted-globals": 0,
// Disable no-params-reassign for properties
// "no-param-reassign": ["error", { "props": false }],
// Allow strict mode (we are not dealing with modules)
// "strict": [0],
// Allow use of "private methods" - impossible to satisfy
"no-underscore-dangle": 0
// Disable alert rule till we have a CE in place
// "no-alert": 0
// Allow extensions on imports
// "import/extensions": 0,
// Allow exporting mutable 'let' binding
// "import/no-mutable-exports": 0,
// Allow no named as default / member
// "import/no-named-as-default": 0,
// "import/no-named-as-default-member": 0
}
}

8
.gitignore vendored
View file

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

5
.npmignore Normal file
View file

@ -0,0 +1,5 @@
node_modules/
demo/
experiments/
package-lock.json
.gitignore

22
LICENSE Normal file
View file

@ -0,0 +1,22 @@
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.

62
README.md Normal file
View file

@ -0,0 +1,62 @@
# KUTE.js
A modern JavaScript animation engine built on ES6+ standards with strong TypeScript definitions and most essential features for the web with easy to use methods to set up high performance, cross-browser animations. The focus is code quality, flexibility, performance and size.
[![NPM Version](https://img.shields.io/npm/v/kute.js.svg?style=flat-square)](https://www.npmjs.com/package/kute.js)
[![NPM Downloads](https://img.shields.io/npm/dm/kute.js.svg?style=flat-square)](http://npm-stat.com/charts.html?package=kute.js)
[![jsDeliver](https://data.jsdelivr.com/v1/package/npm/kute.js/badge)](https://www.jsdelivr.com/package/npm/kute.js)
[![CDNJS](https://img.shields.io/cdnjs/v/kute.js.svg?style=flat-square)](https://cdnjs.com/libraries/kute.js)
KUTE.js packs a series of components for presentation attributes, SVG transform, draw SVG strokes and path morphing, text string write up or number countdowns, plus additional CSS properties like colors, border-radius or typographic properties.
For components documentation, examples and other cool tips, check the [demo](http://thednp.github.io/kute.js/).
# Components
KUTE.js includes 18 components, but not all of them are bundled with the default distribution package:
* [backgroundPosition](http://thednp.github.io/kute.js/backgroundPosition.html) - enables the animation for the `backgroundPosition` CSS property
* [borderRadius](http://thednp.github.io/kute.js/borderRadius.html) - enables the animation for all the **borderRadius** properties
* [boxModel](http://thednp.github.io/kute.js/boxModel.html) - enables the animation for the **boxModel** properties like `top` , `left`, `width`, etc
* [clipProperty](http://thednp.github.io/kute.js/clipProperty.html) - enables the animation for the `clip` property
* [colorProperties](http://thednp.github.io/kute.js/colorProperties.html) - enables the animation for the **color** properties like `color`, `backgroundColor`
* [filterEffects](http://thednp.github.io/kute.js/filterEffects.html) - enables the animation for the `filter` property
* [htmlAttributes](http://thednp.github.io/kute.js/htmlAttributes.html) - enables the animation for any numeric as well as some color based **HTML Attributes**
* [opacityProperty](http://thednp.github.io/kute.js/opacityProperty.html) - enables the animation for the `opacity` property
* [scrollProperty](http://thednp.github.io/kute.js/scrollProperty.html) - enables the animation for the window/Element `scrollTop` Object property
* [shadowProperties](http://thednp.github.io/kute.js/shadowProperties.html) - enables the animation for the **shadowProperties** properties: `textShadow` &amp; `boxShadow`
* [svgCubicMorph](http://thednp.github.io/kute.js/svgCubicMorph.html) - enables the animation for the `d` Presentation Attribute of the `<path>` SVGElement targets; this implements some [Raphael.js](https://dmitrybaranovskiy.github.io/raphael/) functionality
* [svgMorph](http://thednp.github.io/kute.js/svgMorph.html) - enables the animation for the `d` Presentation Attribute of the `<path>` SVGElement targets; this component implements some [D3.js](https://github.com/d3/d3) and [flubber](https://github.com/veltman/flubber) functionality
* [svgDraw](http://thednp.github.io/kute.js/svgDraw.html) - enables the animation for the `strokeDasharray` and `strokeDashoffset` CSS properties specific to `<path>` SVGElement
* [svgTransform](http://thednp.github.io/kute.js/svgTransform.html) - enables the animation for the `transform` presentation attribute
* [textProperties](http://thednp.github.io/kute.js/textProperties.html) - enables the animation for numeric `HTMLTextElement` related CSS properties like `fontSize` or `letterSpacing`
* [textWrite](http://thednp.github.io/kute.js/textWrite.html) - enables the animation for the content of various strings
* [transformFunctions](http://thednp.github.io/kute.js/transformFunctions.html) - enables the animation for the `transform` CSS3 property, the default component bundled with the official build
* transformLegacy - enables the animation for the `transform` CSS3 property on legacy browsers IE9+, not included with the official build, but can be used in your custom builds
* [transformMatrix](http://thednp.github.io/kute.js/transformMatrix.html) - enables the animation for the `transform` CSS3 property; this component implements `DOMMatrix()` API and is super light
All above mentioned components have a BASE version which doesn't include value processing, and their purpose is to provide a way to ship your super light version of your application.
# Wiki
For a complete developer guide, usage and stuff like npm, visit [the wiki](https://github.com/thednp/kute.js/wiki).
# Browser Support
KUTE.js is redeveloped for maximum performance on modern browsers. Some legacy browsers might some help, so give them a small polyfill set with most essential features required by KUTE.js to work, powered by [minifill](https://github.com/thednp/minifill), try it. For broader projects you might want to consider <a href="https://cdn.polyfill.io/v2/docs/">polyfills</a>.
# Special Thanks
* [Mike Bostock](https://bost.ocks.org/mike/) for his awesome [D3.js](https://github.com/d3/d3), one of the sources for our reworked [SVGMorph](http://thednp.github.io/kute.js/svgMorph.html) component.
* [Noah Veltman](https://github.com/veltman) for his awesome [flubber](https://github.com/veltman/flubber), another one of the sources for the SVGMorph component.
* [Andrew Willems](https://stackoverflow.com/users/5218951/andrew-willems) for his awesome [Stackoverflow answer](https://stackoverflow.com/questions/35560989/javascript-how-to-determine-a-svg-path-draw-direction) resulting in the creation of our [SVGCubicMorph](http://thednp.github.io/kute.js/svgCubicMorph.html) component.
* [Dmitry Baranovskiy](https://dmitry.baranovskiy.com/) for his awesome [Raphael.js](https://dmitrybaranovskiy.github.io/raphael/), another source for our SVGCubicMorph component.
* [@dalisoft](https://github.com/dalisoft) contributed a great deal to the performance and functionality of previous versions of KUTE.js.
# Contributions
* [Contributors &amp; Collaborators](https://github.com/thednp/kute.js/graphs/contributors)
# License
[MIT License](https://github.com/thednp/kute.js/blob/master/LICENSE)

View file

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 997 B

After

Width:  |  Height:  |  Size: 997 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Before After
Before After

View file

@ -1,5 +1,5 @@
/*!
* KUTE.js Base v2.2.2 (http://thednp.github.io/kute.js)
* KUTE.js Base v2.2.3 (http://thednp.github.io/kute.js)
* Copyright 2015-2021 © thednp
* Licensed under MIT (https://github.com/thednp/kute.js/blob/master/LICENSE)
*/
@ -876,7 +876,7 @@
return new TweenConstructor(selector(element), startObject, endObject, options);
}
var version = "2.2.2";
var version = "2.2.3";
// @ts-ignore

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
/*!
* KUTE.js Extra v2.2.2 (http://thednp.github.io/kute.js)
* KUTE.js Extra v2.2.3 (http://thednp.github.io/kute.js)
* Copyright 2015-2021 © thednp
* Licensed under MIT (https://github.com/thednp/kute.js/blob/master/LICENSE)
*/
@ -5689,7 +5689,7 @@
Components[component] = new AnimationDevelopment(compOps);
});
var version = "2.2.2";
var version = "2.2.3";
// @ts-ignore

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4621
dist/kute.esm.js vendored Normal file

File diff suppressed because it is too large Load diff

2
dist/kute.esm.min.js vendored Normal file

File diff suppressed because one or more lines are too long

4675
dist/kute.js vendored Normal file

File diff suppressed because it is too large Load diff

2
dist/kute.min.js vendored Normal file

File diff suppressed because one or more lines are too long

140
dist/polyfill.js vendored Normal file
View file

@ -0,0 +1,140 @@
/*!
* KUTE.js Polyfill v2.1.1-alpha1 (http://thednp.github.io/kute.js)
* Copyright 2015-2021 © thednp
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
"use strict";
if (!Array.from) {
Array.from = (function () {
var toStr = Object.prototype.toString;
var isCallable = function (fn) {
return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
};
var toInteger = function (value) {
var number = Number(value);
if (isNaN(number)) { return 0; }
if (number === 0 || !isFinite(number)) { return number; }
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function (value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
return function from(arrayLike/*, mapFn, thisArg */) {
var C = this, items = Object(arrayLike);
if (arrayLike == null) {
throw new TypeError('Array.from requires an array-like object - not null or undefined');
}
var mapFn = arguments.length > 1 ? arguments[1] : void undefined, T;
if (typeof mapFn !== 'undefined') {
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
}
var len = toLength(items.length);
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
var k = 0;
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k += 1;
}
A.length = len;
return A;
}
}());
}
// https://github.com/jonathantneal/array-flat-polyfill/blob/master/src/polyfill-flat.js
if (!Array.prototype.flat) {
Object.defineProperty(Array.prototype, 'flat', {
configurable: true,
value: function flat () {
var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]);
return depth ? Array.prototype.reduce.call(this, function (acc, cur) {
if (Array.isArray(cur)) {
acc.push.apply(acc, flat.call(cur, depth - 1));
} else {
acc.push(cur);
}
return acc;
}, []) : Array.prototype.slice.call(this);
},
writable: true
});
}
if (!Array.prototype.includes) {
Array.prototype.includes = function(searchElement /*, fromIndex*/ ) {
var O = Object(this);
var len = parseInt(O.length) || 0;
if (len === 0) {
return false;
}
var n = parseInt(arguments[1]) || 0;
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) {k = 0;}
}
var currentElement;
while (k < len) {
currentElement = O[k];
if (searchElement === currentElement ||
(searchElement !== searchElement && currentElement !== currentElement)) {
return true;
}
k++;
}
return false;
};
}
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
if (search instanceof RegExp) {
throw TypeError('first argument must not be a RegExp');
}
if (start === undefined) { start = 0; }
return this.indexOf(search, start) !== -1;
};
}
if (!Number.isFinite) {
Number.isFinite = function(value) {
return typeof value === 'number'
&& isFinite(value);
};
}
if (!Number.isInteger) {
Number.isInteger = function(value) {
return typeof value === 'number'
&& isFinite(value)
&& Math.floor(value) === value;
};
}
if (!Number.isNaN) {
Number.isNaN = function(value) {
return typeof value === 'number'
&& value !== value;
};
}

3
dist/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});

80
package.json Normal file
View file

@ -0,0 +1,80 @@
{
"name": "kute.js",
"version": "2.2.3",
"description": "JavaScript animation engine",
"main": "dist/kute.min.js",
"module": "dist/kute.esm.js",
"jsnext": "src/index.js",
"types": "types/index.d.ts",
"files": [
"dist",
"types",
"src"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"help": "rollup --help",
"build1": "npm-run-all --parallel copy-build build-*",
"build": "npm run lint:js && npm-run-all --parallel copy-build build-*",
"custom": "rollup -c --environment",
"fix:js": "eslint src/ --config .eslintrc --fix",
"lint:js": "eslint src/ --config .eslintrc",
"copy-build": "rollup --environment OUTPUTFILE:demo/src/kute.min.js,DIST:standard,MIN:true,FORMAT:umd -c",
"build-standard": "rollup --environment DIST:standard,MIN:false,FORMAT:umd -c",
"build:ts": "tsc -d",
"build-standard-min": "rollup --environment DIST:standard,MIN:true,FORMAT:umd -c",
"build-standard-esm": "rollup --environment DIST:standard,MIN:false,FORMAT:esm -c",
"build-standard-esm-min": "rollup --environment DIST:standard,MIN:true,FORMAT:esm -c",
"build-base": "rollup --environment OUTPUTFILE:demo/src/kute-base.js,DIST:base,MIN:false,FORMAT:umd -c",
"build-base-min": "rollup --environment OUTPUTFILE:demo/src/kute-base.min.js,DIST:base,MIN:true,FORMAT:umd -c",
"build-extra": "rollup --environment OUTPUTFILE:demo/src/kute-extra.js,DIST:extra,MIN:false,FORMAT:umd -c",
"build-extra-min": "rollup --environment OUTPUTFILE:demo/src/kute-extra.min.js,DIST:extra,MIN:true,FORMAT:umd -c",
"polyfill": "npm-run-all --parallel polyfill-unminified polyfill-minified copy-polyfill copy-polyfill-legacy",
"copy-polyfill-legacy": "rollup --environment INPUTFILE:src/util/polyfill-legacy.js,OUTPUTFILE:demo/src/polyfill-legacy.min.js,MIN:true -c rollup.polyfill.js",
"copy-polyfill": "rollup --environment OUTPUTFILE:demo/src/polyfill.min.js,MIN:true -c rollup.polyfill.js",
"polyfill-unminified": "rollup --environment MIN:false -c rollup.polyfill.js",
"polyfill-minified": "rollup --environment MIN:true -c rollup.polyfill.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/thednp/kute.js.git"
},
"keywords": [
"kute.js",
"svg morph",
"svg transform",
"css3 transform",
"matrix transform",
"tweening engine",
"animation engine",
"javascript animation engine",
"javascript animation",
"animation",
"native javascript"
],
"author": "thednp",
"license": "MIT",
"bugs": {
"url": "https://github.com/thednp/kute.js/issues"
},
"homepage": "http://thednp.github.io/kute.js",
"dependencies": {
"cubic-bezier-easing": "^1.0.18",
"minifill": "^0.0.16",
"shorter-js": "^0.2.6",
"svg-path-commander": "0.1.23"
},
"devDependencies": {
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"eslint": "^7.22.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-vue": "^7.7.0",
"npm-run-all": "^4.1.5",
"rollup": "^2.38.4",
"rollup-plugin-terser": "^7.0.2",
"typescript": "^4.5.2"
}
}

58
rollup.config.js Normal file
View file

@ -0,0 +1,58 @@
'use strict'
import buble from '@rollup/plugin-buble'
import {terser} from 'rollup-plugin-terser'
import node from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
import * as pkg from "./package.json"
let INPUTFILE = process.env.INPUTFILE
let OUTPUTFILE = process.env.OUTPUTFILE
const DIST = process.env.DIST // base|standard|extra
const NAME = DIST.charAt(0).toUpperCase() + DIST.slice(1); // Base|Standard|Extra
const MIN = process.env.MIN === 'true' // true/false|unset
const FORMAT = process.env.FORMAT // umd|iife|esm
const year = (new Date).getFullYear()
const banner =
`/*!
* KUTE.js ${NAME} v${pkg.version} (${pkg.homepage})
* Copyright 2015-${year} © ${pkg.author}
* Licensed under MIT (https://github.com/thednp/kute.js/blob/master/LICENSE)
*/`
const miniBanner = `// KUTE.js ${NAME} v${pkg.version} | ${pkg.author} © ${year} | ${pkg.license}-License`
INPUTFILE = INPUTFILE ? INPUTFILE : (DIST === 'standard' ? 'src/index.js' : 'src/index-'+DIST+'.js')
OUTPUTFILE = OUTPUTFILE ? OUTPUTFILE : ('dist/kute'+(DIST!=='standard'?'-'+DIST:'')+(FORMAT==='esm'?'.esm':'')+(MIN?'.min':'')+'.js')
const OUTPUT = {
file: OUTPUTFILE,
format: FORMAT, // or iife
}
const PLUGINS = [
node({mainFields: ['jsnext','module'], dedupe: ['svg-path-commander']}) ,
json(),
]
if (FORMAT!=='esm'){
PLUGINS.push(buble({objectAssign: 'Object.assign'}));
}
if (MIN){
PLUGINS.push(terser({output: {preamble: miniBanner}}));
} else {
OUTPUT.banner = banner;
}
if (FORMAT!=='esm') {
OUTPUT.name = 'KUTE';
}
export default [
{
input: INPUTFILE,
output: OUTPUT,
plugins: PLUGINS
}
]

54
rollup.polyfill.js Normal file
View file

@ -0,0 +1,54 @@
'use strict'
import buble from '@rollup/plugin-buble'
import node from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
import {terser} from 'rollup-plugin-terser'
import * as pkg from "./package.json";
// set headers
const year = (new Date).getFullYear()
const banner = `/*!
* KUTE.js Polyfill v${pkg.version} (${pkg.homepage})
* Copyright 2015-${year} © ${pkg.author}
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/
"use strict";`
const miniBanner = `// KUTE.js Polyfill v${pkg.version} | ${year} © ${pkg.author} | ${pkg.license}-License
"use strict";`
// set config
const MIN = process.env.MIN === 'true' // true/false|unset
const FORMAT = 'esm' // umd|iife|esm|cjs
const INPUTFILE = process.env.INPUTFILE ? process.env.INPUTFILE : 'src/util/polyfill.js'
const OUTPUTFILE = process.env.OUTPUTFILE ? process.env.OUTPUTFILE : 'dist/polyfill'+(MIN?'.min':'')+'.js'
const OUTPUT = {
file: OUTPUTFILE,
format: FORMAT, // or iife
}
const PLUGINS = [
node(),
json(),
buble(),
]
if (MIN){
PLUGINS.push(terser({output: {preamble: miniBanner}}));
} else {
OUTPUT.banner = banner;
}
// if (FORMAT!=='esm') {
// OUTPUT.name = 'BSN';
// }
export default [
{
input: INPUTFILE,
output: OUTPUT,
plugins: PLUGINS
}
]

137
src/animation/animation.js Normal file
View file

@ -0,0 +1,137 @@
import supportedProperties from '../objects/supportedProperties';
import defaultValues from '../objects/defaultValues';
import defaultOptions from '../objects/defaultOptions';
import prepareProperty from '../objects/prepareProperty';
import prepareStart from '../objects/prepareStart';
import onStart from '../objects/onStart';
import onComplete from '../objects/onComplete';
import crossCheck from '../objects/crossCheck';
import linkProperty from '../objects/linkProperty';
import Util from '../objects/util';
import Interpolate from '../objects/interpolate';
/**
* Animation Class
*
* Registers components by populating KUTE.js objects and makes sure
* no duplicate component / property is allowed.
*/
export default class Animation {
/**
* @constructor
* @param {KUTE.fullComponent} Component
*/
constructor(Component) {
try {
if (Component.component in supportedProperties) {
throw Error(`KUTE - ${Component.component} already registered`);
} else if (Component.property in defaultValues) {
throw Error(`KUTE - ${Component.property} already registered`);
}
} catch (e) {
throw Error(e);
}
const propertyInfo = this;
const ComponentName = Component.component;
// const Objects = { defaultValues, defaultOptions, Interpolate, linkProperty, Util }
const Functions = {
prepareProperty, prepareStart, onStart, onComplete, crossCheck,
};
const Category = Component.category;
const Property = Component.property;
const Length = (Component.properties && Component.properties.length)
|| (Component.subProperties && Component.subProperties.length);
// single property
// {property,defaultvalue,defaultOptions,Interpolate,functions}
// category colors, boxModel, borderRadius
// {category,properties,defaultvalues,defaultOptions,Interpolate,functions}
// property with multiple sub properties. Eg transform, filter
// {property,subProperties,defaultvalues,defaultOptions,Interpolate,functions}
// property with multiple sub properties. Eg htmlAttributes
// {category,subProperties,defaultvalues,defaultOptions,Interpolate,functions}
// set supported category/property
supportedProperties[ComponentName] = Component.properties
|| Component.subProperties || Component.property;
// set defaultValues
if ('defaultValue' in Component) { // value 0 will invalidate
defaultValues[Property] = Component.defaultValue;
// minimal info
propertyInfo.supports = `${Property} property`;
} else if (Component.defaultValues) {
Object.keys(Component.defaultValues).forEach((dv) => {
defaultValues[dv] = Component.defaultValues[dv];
});
// minimal info
propertyInfo.supports = `${Length || Property} ${Property || Category} properties`;
}
// 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((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((ofn) => {
// !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 component interpolation functions
if (Component.Interpolate) {
Object.keys(Component.Interpolate).forEach((fni) => {
const compIntObj = Component.Interpolate[fni];
if (typeof (compIntObj) === 'function' && !Interpolate[fni]) {
Interpolate[fni] = compIntObj;
} else {
Object.keys(compIntObj).forEach((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((fnu) => {
if (!Util[fnu]) Util[fnu] = Component.Util[fnu];
});
}
return propertyInfo;
}
}

View file

@ -0,0 +1,97 @@
import supportedProperties from '../objects/supportedProperties';
import defaultOptions from '../objects/defaultOptions';
import onStart from '../objects/onStart';
import onComplete from '../objects/onComplete';
import linkProperty from '../objects/linkProperty';
import Util from '../objects/util';
import Interpolate from '../objects/interpolate';
/**
* 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.
*/
export default class AnimationBase {
/**
* @class
* @param {KUTE.baseComponent} Component
*/
constructor(Component) {
const ComponentName = Component.component;
// const Objects = { defaultValues, defaultOptions, Interpolate, linkProperty }
const Functions = { onStart, onComplete };
const Category = Component.category;
const 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((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((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((fni) => {
const compIntObj = Component.Interpolate[fni];
if (typeof (compIntObj) === 'function' && !Interpolate[fni]) {
Interpolate[fni] = compIntObj;
} else {
Object.keys(compIntObj).forEach((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((fnu) => {
if (!Util[fnu]) Util[fnu] = Component.Util[fnu];
});
}
return { name: ComponentName };
}
}

View file

@ -0,0 +1,137 @@
import prepareProperty from '../objects/prepareProperty';
import prepareStart from '../objects/prepareStart';
import onStart from '../objects/onStart';
import onComplete from '../objects/onComplete';
import crossCheck from '../objects/crossCheck';
import Interpolate from '../objects/interpolate';
import Animation from './animation';
/**
* Animation Development Class
*
* Registers components by populating KUTE.js objects and makes sure
* no duplicate component / property is allowed.
*
* In addition to the default class, this one provides more component
* information to help you with custom component development.
*/
export default class AnimationDevelopment extends Animation {
/**
*
* @param {KUTE.fullComponent} args
*/
constructor(Component) {
super(Component);
const propertyInfo = this;
// const Objects = { defaultValues, defaultOptions, Interpolate, linkProperty, Util }
const Functions = {
prepareProperty, prepareStart, onStart, onComplete, crossCheck,
};
const Category = Component.category;
const Property = Component.property;
const Length = (Component.properties && Component.properties.length)
|| (Component.subProperties && Component.subProperties.length);
// set defaultValues
if ('defaultValue' in Component) { // value 0 will invalidate
propertyInfo.supports = `${Property} property`;
propertyInfo.defaultValue = `${(`${Component.defaultValue}`).length ? 'YES' : 'not set or incorrect'}`;
} else if (Component.defaultValues) {
propertyInfo.supports = `${Length || Property} ${Property || Category} properties`;
propertyInfo.defaultValues = Object.keys(Component.defaultValues).length === Length ? 'YES' : 'Not set or incomplete';
}
// set additional options
if (Component.defaultOptions) {
propertyInfo.extends = [];
Object.keys(Component.defaultOptions).forEach((op) => {
propertyInfo.extends.push(op);
});
if (propertyInfo.extends.length) {
propertyInfo.extends = `with <${propertyInfo.extends.join(', ')}> new option(s)`;
} else {
delete propertyInfo.extends;
}
}
// set functions
if (Component.functions) {
propertyInfo.interface = [];
propertyInfo.render = [];
propertyInfo.warning = [];
Object.keys(Functions).forEach((fnf) => {
if (fnf in Component.functions) {
if (fnf === 'prepareProperty') propertyInfo.interface.push('fromTo()');
if (fnf === 'prepareStart') propertyInfo.interface.push('to()');
if (fnf === 'onStart') propertyInfo.render = 'can render update';
} else {
if (fnf === 'prepareProperty') propertyInfo.warning.push('fromTo()');
if (fnf === 'prepareStart') propertyInfo.warning.push('to()');
if (fnf === 'onStart') propertyInfo.render = 'no function to render update';
}
});
if (propertyInfo.interface.length) {
propertyInfo.interface = `${Category || Property} can use [${propertyInfo.interface.join(', ')}] method(s)`;
} else {
delete propertyInfo.uses;
}
if (propertyInfo.warning.length) {
propertyInfo.warning = `${Category || Property} can't use [${propertyInfo.warning.join(', ')}] method(s) because values aren't processed`;
} else {
delete propertyInfo.warning;
}
}
// register Interpolation functions
if (Component.Interpolate) {
propertyInfo.uses = [];
propertyInfo.adds = [];
Object.keys(Component.Interpolate).forEach((fni) => {
const compIntObj = Component.Interpolate[fni];
// register new Interpolation functions
if (typeof (compIntObj) === 'function') {
if (!Interpolate[fni]) {
propertyInfo.adds.push(`${fni}`);
}
propertyInfo.uses.push(`${fni}`);
} else {
Object.keys(compIntObj).forEach((sfn) => {
if (typeof (compIntObj[sfn]) === 'function' && !Interpolate[fni]) {
propertyInfo.adds.push(`${sfn}`);
}
propertyInfo.uses.push(`${sfn}`);
});
}
});
if (propertyInfo.uses.length) {
propertyInfo.uses = `[${propertyInfo.uses.join(', ')}] interpolation function(s)`;
} else {
delete propertyInfo.uses;
}
if (propertyInfo.adds.length) {
propertyInfo.adds = `new [${propertyInfo.adds.join(', ')}] interpolation function(s)`;
} else {
delete propertyInfo.adds;
}
} else {
propertyInfo.critical = `For ${Property || Category} no interpolation function[s] is set`;
}
// set component util
if (Component.Util) {
propertyInfo.hasUtil = Object.keys(Component.Util).join(',');
}
return propertyInfo;
}
}

View file

@ -0,0 +1,57 @@
import defaultValues from '../objects/defaultValues';
import getStyleForProperty from '../process/getStyleForProperty';
import numbers from '../interpolation/numbers';
import trueDimension from '../util/trueDimension';
import { onStartBgPos } from './backgroundPositionBase';
// Component Functions
/**
* Returns the property computed style.
* @param {string} prop the property
* @returns {string} the property computed style
*/
function getBgPos(prop/* , value */) {
return getStyleForProperty(this.element, prop) || defaultValues[prop];
}
/**
* Returns the property tween object.
* @param {string} _ the property name
* @param {string} value the property value
* @returns {number[]} the property tween object
*/
function prepareBgPos(/* prop, */_, value) {
if (value instanceof Array) {
const x = trueDimension(value[0]).v;
const y = trueDimension(value[1]).v;
return [!Number.isNaN(x * 1) ? x : 50, !Number.isNaN(y * 1) ? y : 50];
}
let posxy = value.replace(/top|left/g, 0)
.replace(/right|bottom/g, 100)
.replace(/center|middle/g, 50);
posxy = posxy.split(/(,|\s)/g);
posxy = posxy.length === 2 ? posxy : [posxy[0], 50];
return [trueDimension(posxy[0]).v, trueDimension(posxy[1]).v];
}
// All Component Functions
const bgPositionFunctions = {
prepareStart: getBgPos,
prepareProperty: prepareBgPos,
onStart: onStartBgPos,
};
// Component Full Object
const BackgroundPosition = {
component: 'backgroundPositionProp',
property: 'backgroundPosition',
defaultValue: [50, 50],
Interpolate: { numbers },
functions: bgPositionFunctions,
Util: { trueDimension },
};
export default BackgroundPosition;

View file

@ -0,0 +1,26 @@
import KEC from '../objects/kute';
import numbers from '../interpolation/numbers';
// Component Functions
/**
* Sets the property update function.
* @param {string} prop the property name
*/
export function onStartBgPos(prop) {
if (this.valuesEnd[prop] && !KEC[prop]) {
KEC[prop] = (elem, a, b, v) => {
/* eslint-disable -- no-bitwise & no-param-reassign impossible to satisfy */
elem.style[prop] = `${(numbers(a[0], b[0], v) * 100 >> 0) / 100}% ${((numbers(a[1], b[1], v) * 100 >> 0) / 100)}%`;
/* eslint-enable -- no-bitwise & no-param-reassign impossible to satisfy */
};
}
}
// Component Base Object
const BackgroundPositionBase = {
component: 'baseBackgroundPosition',
property: 'backgroundPosition',
Interpolate: { numbers },
functions: { onStart: onStartBgPos },
};
export default BackgroundPositionBase;

View file

@ -0,0 +1,58 @@
import defaultValues from '../objects/defaultValues';
import getStyleForProperty from '../process/getStyleForProperty';
import trueDimension from '../util/trueDimension';
import units from '../interpolation/units';
import { radiusOnStartFn } from './borderRadiusBase';
// Component Properties
const radiusProps = [
'borderRadius',
'borderTopLeftRadius', 'borderTopRightRadius',
'borderBottomLeftRadius', 'borderBottomRightRadius'];
const radiusValues = {};
radiusProps.forEach((x) => { radiusValues[x] = 0; });
// Component Functions
const radiusOnStart = {};
radiusProps.forEach((tweenProp) => {
radiusOnStart[tweenProp] = radiusOnStartFn;
});
/**
* Returns the current property computed style.
* @param {string} tweenProp the property name
* @returns {string} the property computed style
*/
export function getRadius(tweenProp) {
return getStyleForProperty(this.element, tweenProp) || defaultValues[tweenProp];
}
/**
* Returns the property tween object.
* @param {string} value the property value
* @returns {{v: number, u: string}} the property tween object
*/
export function prepareRadius(/* tweenProp, */_, value) {
return trueDimension(value);
}
// All Component Functions
export const radiusFunctions = {
prepareStart: getRadius,
prepareProperty: prepareRadius,
onStart: radiusOnStart,
};
// Full Component
const BorderRadius = {
component: 'borderRadiusProperties',
category: 'borderRadius',
properties: radiusProps,
defaultValues: radiusValues,
Interpolate: { units },
functions: radiusFunctions,
Util: { trueDimension },
};
export default BorderRadius;

View file

@ -0,0 +1,43 @@
import KEC from '../objects/kute';
import units from '../interpolation/units';
/* borderRadius = {
category: 'borderRadius',
properties : [..],
defaultValues: {..},
interpolation: {units}
} */
// Component Properties
const radiusProps = [
'borderRadius',
'borderTopLeftRadius', 'borderTopRightRadius',
'borderBottomLeftRadius', 'borderBottomRightRadius',
];
// Component Functions
/**
* Sets the property update function.
* @param {string} tweenProp the property name
*/
export function radiusOnStartFn(tweenProp) {
if (tweenProp in this.valuesEnd && !KEC[tweenProp]) {
KEC[tweenProp] = (elem, a, b, v) => {
// eslint-disable-next-line no-param-reassign -- impossible to satisfy
elem.style[tweenProp] = units(a.v, b.v, b.u, v);
};
}
}
const radiusOnStart = {};
radiusProps.forEach((tweenProp) => {
radiusOnStart[tweenProp] = radiusOnStartFn;
});
// Base Component
const BorderRadiusBase = {
component: 'baseBorderRadius',
category: 'borderRadius',
Interpolate: { units },
functions: { onStart: radiusOnStart },
};
export default BorderRadiusBase;

View file

@ -0,0 +1,57 @@
import defaultValues from '../objects/defaultValues';
import getStyleForProperty from '../process/getStyleForProperty';
import trueDimension from '../util/trueDimension';
import numbers from '../interpolation/numbers';
import { boxModelOnStart } from './boxModelBase';
// Component Properties
const boxModelProperties = ['top', 'left', 'width', 'height', 'right', 'bottom', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight',
'padding', 'paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight',
'margin', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight',
'borderWidth', 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth', 'borderLeftWidth', 'outlineWidth'];
const boxModelValues = {};
boxModelProperties.forEach((x) => { boxModelValues[x] = 0; });
// Component Functions
/**
* Returns the current property computed style.
* @param {string} tweenProp the property name
* @returns {string} computed style for property
*/
function getBoxModel(tweenProp) {
return getStyleForProperty(this.element, tweenProp) || defaultValues[tweenProp];
}
/**
* Returns the property tween object.
* @param {string} tweenProp the property name
* @param {string} value the property value
* @returns {number} the property tween object
*/
function prepareBoxModel(tweenProp, value) {
const boxValue = trueDimension(value); const
offsetProp = tweenProp === 'height' ? 'offsetHeight' : 'offsetWidth';
return boxValue.u === '%' ? (boxValue.v * this.element[offsetProp]) / 100 : boxValue.v;
}
const boxPropsOnStart = {};
boxModelProperties.forEach((x) => { boxPropsOnStart[x] = boxModelOnStart; });
// All Component Functions
const boxModelFunctions = {
prepareStart: getBoxModel,
prepareProperty: prepareBoxModel,
onStart: boxPropsOnStart,
};
// Component Full Component
const BoxModel = {
component: 'boxModelProperties',
category: 'boxModel',
properties: boxModelProperties,
defaultValues: boxModelValues,
Interpolate: { numbers },
functions: boxModelFunctions,
};
export default BoxModel;

View file

@ -0,0 +1,37 @@
import KEC from '../objects/kute';
import numbers from '../interpolation/numbers';
// Component Functions
/**
* Sets the update function for the property.
* @param {string} tweenProp the property name
*/
export function boxModelOnStart(tweenProp) {
if (tweenProp in this.valuesEnd && !KEC[tweenProp]) {
KEC[tweenProp] = (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
const baseBoxProps = ['top', 'left', 'width', 'height'];
const baseBoxOnStart = {};
baseBoxProps.forEach((x) => { baseBoxOnStart[x] = boxModelOnStart; });
// Component Base
const BoxModelBase = {
component: 'baseBoxModel',
category: 'boxModel',
properties: baseBoxProps,
Interpolate: { numbers },
functions: { onStart: baseBoxOnStart },
};
export default BoxModelBase;

View file

@ -0,0 +1,56 @@
import defaultValues from '../objects/defaultValues';
import getStyleForProperty from '../process/getStyleForProperty';
import trueDimension from '../util/trueDimension';
import numbers from '../interpolation/numbers';
import { boxModelOnStart } from './boxModelBase';
// Component Functions
/**
* Returns the current property computed style.
* @param {string} tweenProp the property name
* @returns {string} computed style for property
*/
function getBoxModel(tweenProp) {
return getStyleForProperty(this.element, tweenProp) || defaultValues[tweenProp];
}
/**
* Returns the property tween object.
* @param {string} tweenProp the property name
* @param {string} value the property name
* @returns {number} the property tween object
*/
function prepareBoxModel(tweenProp, value) {
const boxValue = trueDimension(value);
const offsetProp = tweenProp === 'height' ? 'offsetHeight' : 'offsetWidth';
return boxValue.u === '%' ? (boxValue.v * this.element[offsetProp]) / 100 : boxValue.v;
}
// Component Base Props
const essentialBoxProps = ['top', 'left', 'width', 'height'];
const essentialBoxPropsValues = {
top: 0, left: 0, width: 0, height: 0,
};
const essentialBoxOnStart = {};
essentialBoxProps.forEach((x) => { essentialBoxOnStart[x] = boxModelOnStart; });
// All Component Functions
const essentialBoxModelFunctions = {
prepareStart: getBoxModel,
prepareProperty: prepareBoxModel,
onStart: essentialBoxOnStart,
};
// Component Essential
const BoxModelEssential = {
component: 'essentialBoxModel',
category: 'boxModel',
properties: essentialBoxProps,
defaultValues: essentialBoxPropsValues,
Interpolate: { numbers },
functions: essentialBoxModelFunctions,
Util: { trueDimension },
};
export default BoxModelEssential;

View file

@ -0,0 +1,52 @@
import getStyleForProperty from '../process/getStyleForProperty';
import trueDimension from '../util/trueDimension';
import numbers from '../interpolation/numbers';
import { onStartClip } from './clipPropertyBase';
// Component Functions
/**
* Returns the current property computed style.
* @param {string} tweenProp the property name
* @returns {string | number[]} computed style for property
*/
function getClip(tweenProp/* , value */) {
const { element } = this;
const currentClip = getStyleForProperty(element, tweenProp);
const width = getStyleForProperty(element, 'width');
const height = getStyleForProperty(element, 'height');
return !/rect/.test(currentClip) ? [0, width, height, 0] : currentClip;
}
/**
* Returns the property tween object.
* @param {string} _ the property name
* @param {string} value the property value
* @returns {number[]} the property tween object
*/
function prepareClip(/* tweenProp, */_, value) {
if (value instanceof Array) {
return value.map((x) => trueDimension(x));
}
let clipValue = value.replace(/rect|\(|\)/g, '');
clipValue = /,/g.test(clipValue) ? clipValue.split(',') : clipValue.split(/\s/);
return clipValue.map((x) => trueDimension(x));
}
// All Component Functions
const clipFunctions = {
prepareStart: getClip,
prepareProperty: prepareClip,
onStart: onStartClip,
};
// Component Full
const ClipProperty = {
component: 'clipProperty',
property: 'clip',
defaultValue: [0, 0, 0, 0],
Interpolate: { numbers },
functions: clipFunctions,
Util: { trueDimension },
};
export default ClipProperty;

View file

@ -0,0 +1,36 @@
import KEC from '../objects/kute';
import numbers from '../interpolation/numbers';
// Component Functions
/**
* Sets the property update function.
* @param {string} tweenProp the property name
*/
export function onStartClip(tweenProp) {
if (this.valuesEnd[tweenProp] && !KEC[tweenProp]) {
KEC[tweenProp] = (elem, a, b, v) => {
let h = 0; const
cl = [];
for (h; h < 4; h += 1) {
const c1 = a[h].v;
const c2 = b[h].v;
const cu = b[h].u || 'px';
// eslint-disable-next-line no-bitwise -- impossible to satisfy
cl[h] = ((numbers(c1, c2, v) * 100 >> 0) / 100) + cu;
}
// eslint-disable-next-line no-param-reassign -- impossible to satisfy
elem.style.clip = `rect(${cl})`;
};
}
}
// Component Base
const ClipPropertyBase = {
component: 'baseClip',
property: 'clip',
// defaultValue: [0,0,0,0],
Interpolate: { numbers },
functions: { onStart: onStartClip },
};
export default ClipPropertyBase;

View file

@ -0,0 +1,65 @@
import defaultValues from '../objects/defaultValues';
import getStyleForProperty from '../process/getStyleForProperty';
import trueColor from '../util/trueColor';
import numbers from '../interpolation/numbers';
import colors from '../interpolation/colors';
import { onStartColors } from './colorPropertiesBase';
// Component Properties
// supported formats
// 'hex', 'rgb', 'rgba' '#fff' 'rgb(0,0,0)' / 'rgba(0,0,0,0)' 'red' (IE9+)
const supportedColors = [
'color', 'backgroundColor', 'outlineColor',
'borderColor', 'borderTopColor', 'borderRightColor',
'borderBottomColor', 'borderLeftColor',
];
const defaultColors = {};
supportedColors.forEach((tweenProp) => {
defaultColors[tweenProp] = '#000';
});
// Component Functions
const colorsOnStart = {};
supportedColors.forEach((x) => {
colorsOnStart[x] = onStartColors;
});
/**
* Returns the current property computed style.
* @param {string} prop the property name
* @returns {string} property computed style
*/
function getColor(prop/* , value */) {
return getStyleForProperty(this.element, prop) || defaultValues[prop];
}
/**
* Returns the property tween object.
* @param {string} _ the property name
* @param {string} value the property value
* @returns {KUTE.colorObject} the property tween object
*/
function prepareColor(/* prop, */_, value) {
return trueColor(value);
}
// All Component Functions
const colorFunctions = {
prepareStart: getColor,
prepareProperty: prepareColor,
onStart: colorsOnStart,
};
// Component Full
const colorProperties = {
component: 'colorProperties',
category: 'colors',
properties: supportedColors,
defaultValues: defaultColors,
Interpolate: { numbers, colors },
functions: colorFunctions,
Util: { trueColor },
};
export default colorProperties;

View file

@ -0,0 +1,45 @@
import KEC from '../objects/kute';
import numbers from '../interpolation/numbers';
import colors from '../interpolation/colors';
// Component Interpolation
// rgba1, rgba2, progress
// Component Properties
// supported formats
// 'hex', 'rgb', 'rgba' '#fff' 'rgb(0,0,0)' / 'rgba(0,0,0,0)' 'red' (IE9+)
const supportedColors = [
'color', 'backgroundColor', 'outlineColor',
'borderColor',
'borderTopColor', 'borderRightColor',
'borderBottomColor', 'borderLeftColor',
];
// Component Functions
/**
* Sets the property update function.
* @param {string} tweenProp the property name
*/
export function onStartColors(tweenProp) {
if (this.valuesEnd[tweenProp] && !KEC[tweenProp]) {
KEC[tweenProp] = (elem, a, b, v) => {
// eslint-disable-next-line no-param-reassign
elem.style[tweenProp] = colors(a, b, v);
};
}
}
const colorsOnStart = {};
supportedColors.forEach((x) => { colorsOnStart[x] = onStartColors; });
// Component Base
export const baseColors = {
component: 'baseColors',
category: 'colors',
// properties: supportedColors,
// defaultValues: defaultColors,
Interpolate: { numbers, colors },
functions: { onStart: colorsOnStart },
};
export default baseColors;

View file

@ -0,0 +1,95 @@
import KEC from '../objects/kute';
import getInlineStyle from '../process/getInlineStyle';
import defaultValues from '../objects/defaultValues';
import trueProperty from '../util/trueProperty';
import numbers from '../interpolation/numbers';
// Component Const
const transformProperty = trueProperty('transform');
const supportTransform = transformProperty in document.body.style ? 1 : 0;
// Component Functions
/**
* Returns the property current style.
*/
function getComponentCurrentValue(/* tweenProp, value */) {
const currentTransform = getInlineStyle(this.element);
const { left } = this.element.style;
const { top } = this.element.style;
let x = 0;
let y = 0;
if (supportTransform && currentTransform.translate) {
[x, y] = currentTransform.translate;
} else {
x = Number.isFinite(left * 1) ? left : defaultValues.move[0];
y = Number.isFinite(top * 1) ? top : defaultValues.move[1];
}
return [x, y];
}
/**
* Returns the property tween object.
* @param {string} _ property name
* @param {string} value property value
* @returns {number[]} the property tween object
*/
function prepareComponentValue(/* tweenProp */_, value) {
const x = Number.isFinite(value * 1) ? parseInt(value, 10) : parseInt(value[0], 10) || 0;
const y = parseInt(value[1], 10) || 0;
return [x, y];
}
/**
* Sets the property update function.
* @param {string} tweenProp the `path` property
*/
export function onStartComponent(tweenProp/* , value */) {
if (!KEC[tweenProp] && this.valuesEnd[tweenProp]) {
if (supportTransform) {
KEC[tweenProp] = (elem, a, b, v) => {
/* eslint-disable-next-line no-param-reassign -- impossible to satisfy */
elem.style[transformProperty] = `translate(${numbers(a[0], b[0], v)}px,${numbers(a[1], b[1], v)}px)`;
};
} else {
KEC[tweenProp] = (elem, a, b, v) => {
if (a[0] || b[0]) {
/* eslint-disable-next-line no-param-reassign -- impossible to satisfy */
elem.style.left = `${numbers(a[0], b[0], v)}px`;
}
if (a[1] || b[1]) {
/* eslint-disable-next-line no-param-reassign -- impossible to satisfy */
elem.style.top = `${numbers(a[1], b[1], v)}px`;
}
};
}
}
}
// All Component Functions
const componentFunctions = {
prepareStart: getComponentCurrentValue,
prepareProperty: prepareComponentValue,
onStart: onStartComponent,
};
// Base Component
export const baseCrossBrowserMove = {
component: 'baseCrossBrowserMove',
property: 'move',
Interpolate: { numbers },
functions: { onStart: onStartComponent },
};
// Full Component
const crossBrowserMove = {
component: 'crossBrowserMove',
property: 'move',
defaultValue: [0, 0],
Interpolate: { numbers },
functions: componentFunctions,
Util: { trueProperty },
};
export default crossBrowserMove;

View file

@ -0,0 +1,201 @@
import getStyleForProperty from '../process/getStyleForProperty';
import defaultValues from '../objects/defaultValues';
import trueColor from '../util/trueColor';
import numbers from '../interpolation/numbers';
import colors from '../interpolation/colors';
import { dropshadow, onStartFilter } from './filterEffectsBase';
/* filterEffects = {
property: 'filter',
subProperties: {},
defaultValue: {},
interpolators: {},
functions = { prepareStart, prepareProperty, onStart, crossCheck }
} */
// Component Util
/**
* Returns camelCase filter sub-property.
* @param {string} str source string
* @returns {string} camelCase property name
*/
function replaceDashNamespace(str) {
return str.replace('-r', 'R').replace('-s', 'S');
}
/**
* Returns `drop-shadow` sub-property object.
* @param {(string | number)[]} shadow and `Array` with `drop-shadow` parameters
* @returns {KUTE.filterList['dropShadow']} the expected `drop-shadow` values
*/
function parseDropShadow(shadow) {
let newShadow;
if (shadow.length === 3) { // [h-shadow, v-shadow, color]
newShadow = [shadow[0], shadow[1], 0, shadow[2]];
} else if (shadow.length === 4) { // ideal [<offset-x>, <offset-y>, <blur-radius>, <color>]
newShadow = [shadow[0], shadow[1], shadow[2], shadow[3]];
}
// make sure the values are ready to tween
for (let i = 0; i < 3; i += 1) {
newShadow[i] = parseFloat(newShadow[i]);
}
// also the color must be a rgb object
newShadow[3] = trueColor(newShadow[3]);
return newShadow;
}
/**
* Returns an array with current filter sub-properties values.
* @param {string} currentStyle the current filter computed style
* @returns {{[x: string]: number}} the filter tuple
*/
function parseFilterString(currentStyle) {
const result = {};
const fnReg = /(([a-z].*?)\(.*?\))(?=\s([a-z].*?)\(.*?\)|\s*$)/g;
const matches = currentStyle.match(fnReg);
const fnArray = currentStyle !== 'none' ? matches : 'none';
if (fnArray instanceof Array) {
for (let j = 0, jl = fnArray.length; j < jl; j += 1) {
const p = fnArray[j].trim().split(/\((.+)/);
const pp = replaceDashNamespace(p[0]);
if (pp === 'dropShadow') {
const shadowColor = p[1].match(/(([a-z].*?)\(.*?\))(?=\s(.*?))/)[0];
const params = p[1].replace(shadowColor, '').split(/\s/).map(parseFloat);
result[pp] = params.filter((el) => !Number.isNaN(el)).concat(shadowColor);
} else {
result[pp] = p[1].replace(/'|"|\)/g, '');
}
}
}
return result;
}
// Component Functions
/**
* Returns the current property computed style.
* @param {string} tweenProp the property name
* @param {string} value the property value
* @returns {string} computed style for property
*/
function getFilter(tweenProp, value) {
const currentStyle = getStyleForProperty(this.element, tweenProp);
const filterObject = parseFilterString(currentStyle);
let fnp;
Object.keys(value).forEach((fn) => {
fnp = replaceDashNamespace(fn);
if (!filterObject[fnp]) {
filterObject[fnp] = defaultValues[tweenProp][fn];
}
});
return filterObject;
}
/**
* Returns the property tween object.
* @param {string} _ the property name
* @param {string} value the property name
* @returns {KUTE.filterList} the property tween object
*/
function prepareFilter(/* tweenProp, */_, value) {
const filterObject = {};
let fnp;
// property: range | default
// opacity: [0-100%] | 100
// blur: [0-Nem] | 0
// saturate: [0-N%] | 100
// invert: [0-100%] | 0
// grayscale: [0-100%] | 0
// brightness: [0-N%] | 100
// contrast: [0-N%] | 100
// sepia: [0-N%] | 0
// 'hueRotate': [0-Ndeg] | 0
// 'dropShadow': [0,0,0,(r:0,g:0,b:0)] | 0
// url: '' | ''
Object.keys(value).forEach((fn) => {
fnp = replaceDashNamespace(fn);
if (/hue/.test(fn)) {
filterObject[fnp] = parseFloat(value[fn]);
} else if (/drop/.test(fn)) {
filterObject[fnp] = parseDropShadow(value[fn]);
} else if (fn === 'url') {
filterObject[fn] = value[fn];
// } else if ( /blur|opacity|grayscale|sepia/.test(fn) ) {
} else {
filterObject[fn] = parseFloat(value[fn]);
}
});
return filterObject;
}
/**
* Adds missing sub-properties in `valuesEnd` from `valuesStart`.
* @param {string} tweenProp the property name
*/
function crossCheckFilter(tweenProp) {
if (this.valuesEnd[tweenProp]) {
Object.keys(this.valuesStart[tweenProp]).forEach((fn) => {
if (!this.valuesEnd[tweenProp][fn]) {
this.valuesEnd[tweenProp][fn] = this.valuesStart[tweenProp][fn];
}
});
}
}
// All Component Functions
const filterFunctions = {
prepareStart: getFilter,
prepareProperty: prepareFilter,
onStart: onStartFilter,
crossCheck: crossCheckFilter,
};
// Full Component
const filterEffects = {
component: 'filterEffects',
property: 'filter',
// opacity function interfere with opacityProperty
// subProperties: [
// 'blur', 'brightness','contrast','dropShadow',
// 'hueRotate','grayscale','invert','opacity','saturate','sepia','url'
// ],
defaultValue: {
opacity: 100,
blur: 0,
saturate: 100,
grayscale: 0,
brightness: 100,
contrast: 100,
sepia: 0,
invert: 0,
hueRotate: 0,
dropShadow: [0, 0, 0, { r: 0, g: 0, b: 0 }],
url: '',
},
Interpolate: {
opacity: numbers,
blur: numbers,
saturate: numbers,
grayscale: numbers,
brightness: numbers,
contrast: numbers,
sepia: numbers,
invert: numbers,
hueRotate: numbers,
dropShadow: { numbers, colors, dropshadow },
},
functions: filterFunctions,
Util: {
parseDropShadow, parseFilterString, replaceDashNamespace, trueColor,
},
};
export default filterEffects;

View file

@ -0,0 +1,74 @@
import KEC from '../objects/kute';
import numbers from '../interpolation/numbers';
import colors from '../interpolation/colors';
// Component Interpolation
/**
* Sets the `drop-shadow` sub-property update function.
* * disimbiguation `dropshadow` interpolation function and `dropShadow` property
* @param {string} tweenProp the property name
*/
export function dropshadow(a, b, v) {
const params = [];
const unit = 'px';
for (let i = 0; i < 3; i += 1) {
// eslint-disable-next-line no-bitwise
params[i] = ((numbers(a[i], b[i], v) * 100 >> 0) / 100) + unit;
}
return `drop-shadow(${params.concat(colors(a[3], b[3], v)).join(' ')})`;
}
// Component Functions
/**
* Sets the property update function.
* @param {string} tweenProp the property name
*/
export function onStartFilter(tweenProp) {
if (this.valuesEnd[tweenProp] && !KEC[tweenProp]) {
KEC[tweenProp] = (elem, a, b, v) => {
/* eslint-disable-next-line no-param-reassign -- impossible to satisfy */
elem.style[tweenProp] = (b.url ? `url(${b.url})` : '')
/* eslint-disable no-bitwise -- impossible to satisfy */
+ (a.opacity || b.opacity ? `opacity(${((numbers(a.opacity, b.opacity, v) * 100) >> 0) / 100}%)` : '')
+ (a.blur || b.blur ? `blur(${((numbers(a.blur, b.blur, v) * 100) >> 0) / 100}em)` : '')
+ (a.saturate || b.saturate ? `saturate(${((numbers(a.saturate, b.saturate, v) * 100) >> 0) / 100}%)` : '')
+ (a.invert || b.invert ? `invert(${((numbers(a.invert, b.invert, v) * 100) >> 0) / 100}%)` : '')
+ (a.grayscale || b.grayscale ? `grayscale(${((numbers(a.grayscale, b.grayscale, v) * 100) >> 0) / 100}%)` : '')
+ (a.hueRotate || b.hueRotate ? `hue-rotate(${((numbers(a.hueRotate, b.hueRotate, v) * 100) >> 0) / 100}deg)` : '')
+ (a.sepia || b.sepia ? `sepia(${((numbers(a.sepia, b.sepia, v) * 100) >> 0) / 100}%)` : '')
+ (a.brightness || b.brightness ? `brightness(${((numbers(a.brightness, b.brightness, v) * 100) >> 0) / 100}%)` : '')
+ (a.contrast || b.contrast ? `contrast(${((numbers(a.contrast, b.contrast, v) * 100) >> 0) / 100}%)` : '')
+ (a.dropShadow || b.dropShadow ? dropshadow(a.dropShadow, b.dropShadow, v) : '');
/* eslint-enable no-bitwise -- impossible to satisfy */
};
}
}
// Base Component
const baseFilter = {
component: 'baseFilter',
property: 'filter',
// opacity function interfere with opacityProperty
// subProperties: ['blur', 'brightness','contrast','dropShadow',
// 'hueRotate','grayscale','invert','opacity','saturate','sepia','url'],
// defaultValue: {
// opacity: 100, blur: 0, saturate: 100, grayscale: 0,
// brightness: 100, contrast: 100, sepia: 0, invert: 0, hueRotate:0,
// dropShadow: [0,0,0,{r:0,g:0,b:0}], url:''
// },
Interpolate: {
opacity: numbers,
blur: numbers,
saturate: numbers,
grayscale: numbers,
brightness: numbers,
contrast: numbers,
sepia: numbers,
invert: numbers,
hueRotate: numbers,
dropShadow: { numbers, colors, dropshadow },
},
functions: { onStart: onStartFilter },
};
export default baseFilter;

View file

@ -0,0 +1,131 @@
import defaultValues from '../objects/defaultValues';
import onStart from '../objects/onStart';
import trueColor from '../util/trueColor';
import trueDimension from '../util/trueDimension';
import numbers from '../interpolation/numbers';
import colors from '../interpolation/colors';
import { attributes, onStartAttr } from './htmlAttributesBase';
// Component Name
const ComponentName = 'htmlAttributes';
// Component Properties
const svgColors = ['fill', 'stroke', 'stop-color'];
// Component Util
/**
* Returns non-camelcase property name.
* @param {string} a the camelcase property name
* @returns {string} the non-camelcase property name
*/
function replaceUppercase(a) { return a.replace(/[A-Z]/g, '-$&').toLowerCase(); }
// Component Functions
/**
* Returns the current attribute value.
* @param {string} _ the property name
* @param {string} value the property value
* @returns {{[x:string]: string}} attribute value
*/
export function getAttr(/* tweenProp, */_, value) {
const attrStartValues = {};
Object.keys(value).forEach((attr) => {
// get the value for 'fill-opacity' not fillOpacity
// also 'width' not the internal 'width_px'
const attribute = replaceUppercase(attr).replace(/_+[a-z]+/, '');
const currentValue = this.element.getAttribute(attribute);
attrStartValues[attribute] = svgColors.includes(attribute)
? (currentValue || 'rgba(0,0,0,0)')
: (currentValue || (/opacity/i.test(attr) ? 1 : 0));
});
return attrStartValues;
}
/**
* Returns the property tween object.
* @param {string} tweenProp the property name
* @param {string} attrObj the property value
* @returns {number} the property tween object
*/
export function prepareAttr(tweenProp, attrObj) { // attr (string),attrObj (object)
const attributesObject = {};
Object.keys(attrObj).forEach((p) => {
const prop = replaceUppercase(p);
const regex = /(%|[a-z]+)$/;
const currentValue = this.element.getAttribute(prop.replace(/_+[a-z]+/, ''));
if (!svgColors.includes(prop)) {
// attributes set with unit suffixes
if (currentValue !== null && regex.test(currentValue)) {
const unit = trueDimension(currentValue).u || trueDimension(attrObj[p]).u;
const suffix = /%/.test(unit) ? '_percent' : `_${unit}`;
// most "unknown" attributes cannot register into onStart, so we manually add them
onStart[ComponentName][prop + suffix] = (tp) => {
if (this.valuesEnd[tweenProp] && this.valuesEnd[tweenProp][tp] && !(tp in attributes)) {
attributes[tp] = (elem, oneAttr, a, b, v) => {
const _p = oneAttr.replace(suffix, '');
/* eslint no-bitwise: ["error", { "allow": [">>"] }] */
elem.setAttribute(_p, ((numbers(a.v, b.v, v) * 1000 >> 0) / 1000) + b.u);
};
}
};
attributesObject[prop + suffix] = trueDimension(attrObj[p]);
} else if (!regex.test(attrObj[p]) || currentValue === null
|| (currentValue !== null && !regex.test(currentValue))) {
// most "unknown" attributes cannot register into onStart, so we manually add them
onStart[ComponentName][prop] = (tp) => {
if (this.valuesEnd[tweenProp] && this.valuesEnd[tweenProp][tp] && !(tp in attributes)) {
attributes[tp] = (elem, oneAttr, a, b, v) => {
elem.setAttribute(oneAttr, (numbers(a, b, v) * 1000 >> 0) / 1000);
};
}
};
attributesObject[prop] = parseFloat(attrObj[p]);
}
} else { // colors
// most "unknown" attributes cannot register into onStart, so we manually add them
onStart[ComponentName][prop] = (tp) => {
if (this.valuesEnd[tweenProp] && this.valuesEnd[tweenProp][tp] && !(tp in attributes)) {
attributes[tp] = (elem, oneAttr, a, b, v) => {
elem.setAttribute(oneAttr, colors(a, b, v));
};
}
};
attributesObject[prop] = trueColor(attrObj[p]) || defaultValues.htmlAttributes[p];
}
});
return attributesObject;
}
// All Component Functions
const attrFunctions = {
prepareStart: getAttr,
prepareProperty: prepareAttr,
onStart: onStartAttr,
};
// Component Full
const htmlAttributes = {
component: ComponentName,
property: 'attr',
// the Animation class will need some values to validate this Object attribute
subProperties: ['fill', 'stroke', 'stop-color', 'fill-opacity', 'stroke-opacity'],
defaultValue: {
fill: 'rgb(0,0,0)',
stroke: 'rgb(0,0,0)',
'stop-color': 'rgb(0,0,0)',
opacity: 1,
'stroke-opacity': 1,
'fill-opacity': 1, // same here
},
Interpolate: { numbers, colors },
functions: attrFunctions,
// export to global for faster execution
Util: { replaceUppercase, trueColor, trueDimension },
};
export default htmlAttributes;

Some files were not shown because too many files have changed in this diff Show more