├── .gitignore ├── .prettierignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── package-lock.json ├── package.json ├── prettier.config.js └── src ├── animations.cjs ├── easings.js └── index.cjs /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .github 2 | node_modules 3 | package-lock.json 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.2.0 4 | 5 | - Added more accurate typings [#4](https://github.com/shoelace-style/animations/pull/4) 6 | 7 | ## 1.1.0 8 | 9 | - Added easings 10 | 11 | ## 1.0.0 12 | 13 | - Initial release using animate.css 4.1.1 14 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 A Beautiful Site, LLC 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shoelace Animations 2 | 3 | Your favorite [animate.css](https://animate.style/) effects available as ES modules for use with the [Web Animations API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API). 4 | 5 | - 🏆 ~100 quality animations 6 | - 🎾 ~30 popular easings 7 | - 🚚 Works with CDNs 8 | - 🌲 Fully tree-shakeable 9 | 10 | [Try it on JSFiddle](https://jsfiddle.net/claviska/ohjmkgb1) 11 | 12 | This module was built for [Shoelace](https://shoelace.style/), but it works well as a stand-alone library too! 13 | 14 | ## Installation 15 | 16 | ```bash 17 | npm install @shoelace-style/animations 18 | ``` 19 | 20 | ## Usage 21 | 22 | Importing all animations: 23 | 24 | ```js 25 | import * as animations from '@shoelace-style/animations'; 26 | ``` 27 | 28 | Importing individual animations: 29 | 30 | ```js 31 | import { bounce } from '@shoelace-style/animations'; 32 | ``` 33 | 34 | Importing easings: 35 | 36 | ```js 37 | import { easings } from '@shoelace-style/animations'; 38 | ``` 39 | 40 | Animating an element: 41 | 42 | ```html 43 |
44 | 45 | 56 | ``` 57 | 58 | This example uses the [jsDelivr CDN](https://www.jsdelivr.com/). To import the library locally, install it and make `node_modules/@shoelace-style/animations/dist` available to your app or bundler. 59 | 60 | ## Developers 61 | 62 | This script parses all animation stylesheets found in `node_modules/animate.css` and generates [keyframe objects](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats) that you can use with the [Web Animations API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API). As animations are tweaked and added to animate.css, the keyframes herein will be kept in sync when rerunning the script. 63 | 64 | To build the project, run: 65 | 66 | ```bash 67 | npm run build 68 | ``` 69 | 70 | This will purge and rebuild the `dist` directory. 71 | 72 | Please report all bugs and suggestions to [the issue tracker](https://github.com/shoelace-style/animations/issues). 73 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@shoelace-style/animations", 3 | "version": "1.2.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@nodelib/fs.scandir": { 8 | "version": "2.1.4", 9 | "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", 10 | "integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==", 11 | "dev": true, 12 | "requires": { 13 | "@nodelib/fs.stat": "2.0.4", 14 | "run-parallel": "^1.1.9" 15 | } 16 | }, 17 | "@nodelib/fs.stat": { 18 | "version": "2.0.4", 19 | "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz", 20 | "integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==", 21 | "dev": true 22 | }, 23 | "@nodelib/fs.walk": { 24 | "version": "1.2.6", 25 | "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz", 26 | "integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==", 27 | "dev": true, 28 | "requires": { 29 | "@nodelib/fs.scandir": "2.1.4", 30 | "fastq": "^1.6.0" 31 | } 32 | }, 33 | "aggregate-error": { 34 | "version": "3.1.0", 35 | "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", 36 | "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", 37 | "dev": true, 38 | "requires": { 39 | "clean-stack": "^2.0.0", 40 | "indent-string": "^4.0.0" 41 | } 42 | }, 43 | "animate.css": { 44 | "version": "4.1.1", 45 | "resolved": "https://registry.npmjs.org/animate.css/-/animate.css-4.1.1.tgz", 46 | "integrity": "sha512-+mRmCTv6SbCmtYJCN4faJMNFVNN5EuCTTprDTAo7YzIGji2KADmakjVA3+8mVDkZ2Bf09vayB35lSQIex2+QaQ==", 47 | "dev": true 48 | }, 49 | "array-union": { 50 | "version": "2.1.0", 51 | "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", 52 | "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", 53 | "dev": true 54 | }, 55 | "atob": { 56 | "version": "2.1.2", 57 | "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", 58 | "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", 59 | "dev": true 60 | }, 61 | "balanced-match": { 62 | "version": "1.0.0", 63 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 64 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 65 | "dev": true 66 | }, 67 | "brace-expansion": { 68 | "version": "1.1.11", 69 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 70 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 71 | "dev": true, 72 | "requires": { 73 | "balanced-match": "^1.0.0", 74 | "concat-map": "0.0.1" 75 | } 76 | }, 77 | "braces": { 78 | "version": "3.0.2", 79 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", 80 | "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", 81 | "dev": true, 82 | "requires": { 83 | "fill-range": "^7.0.1" 84 | } 85 | }, 86 | "clean-stack": { 87 | "version": "2.2.0", 88 | "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", 89 | "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", 90 | "dev": true 91 | }, 92 | "concat-map": { 93 | "version": "0.0.1", 94 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 95 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 96 | "dev": true 97 | }, 98 | "css": { 99 | "version": "3.0.0", 100 | "resolved": "https://registry.npmjs.org/css/-/css-3.0.0.tgz", 101 | "integrity": "sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ==", 102 | "dev": true, 103 | "requires": { 104 | "inherits": "^2.0.4", 105 | "source-map": "^0.6.1", 106 | "source-map-resolve": "^0.6.0" 107 | } 108 | }, 109 | "decode-uri-component": { 110 | "version": "0.2.0", 111 | "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", 112 | "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", 113 | "dev": true 114 | }, 115 | "del": { 116 | "version": "6.0.0", 117 | "resolved": "https://registry.npmjs.org/del/-/del-6.0.0.tgz", 118 | "integrity": "sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==", 119 | "dev": true, 120 | "requires": { 121 | "globby": "^11.0.1", 122 | "graceful-fs": "^4.2.4", 123 | "is-glob": "^4.0.1", 124 | "is-path-cwd": "^2.2.0", 125 | "is-path-inside": "^3.0.2", 126 | "p-map": "^4.0.0", 127 | "rimraf": "^3.0.2", 128 | "slash": "^3.0.0" 129 | } 130 | }, 131 | "dir-glob": { 132 | "version": "3.0.1", 133 | "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", 134 | "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", 135 | "dev": true, 136 | "requires": { 137 | "path-type": "^4.0.0" 138 | } 139 | }, 140 | "fast-glob": { 141 | "version": "3.2.4", 142 | "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz", 143 | "integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==", 144 | "dev": true, 145 | "requires": { 146 | "@nodelib/fs.stat": "^2.0.2", 147 | "@nodelib/fs.walk": "^1.2.3", 148 | "glob-parent": "^5.1.0", 149 | "merge2": "^1.3.0", 150 | "micromatch": "^4.0.2", 151 | "picomatch": "^2.2.1" 152 | } 153 | }, 154 | "fastq": { 155 | "version": "1.10.0", 156 | "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.10.0.tgz", 157 | "integrity": "sha512-NL2Qc5L3iQEsyYzweq7qfgy5OtXCmGzGvhElGEd/SoFWEMOEczNh5s5ocaF01HDetxz+p8ecjNPA6cZxxIHmzA==", 158 | "dev": true, 159 | "requires": { 160 | "reusify": "^1.0.4" 161 | } 162 | }, 163 | "fill-range": { 164 | "version": "7.0.1", 165 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", 166 | "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", 167 | "dev": true, 168 | "requires": { 169 | "to-regex-range": "^5.0.1" 170 | } 171 | }, 172 | "fs.realpath": { 173 | "version": "1.0.0", 174 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 175 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 176 | "dev": true 177 | }, 178 | "glob": { 179 | "version": "7.1.6", 180 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", 181 | "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", 182 | "dev": true, 183 | "requires": { 184 | "fs.realpath": "^1.0.0", 185 | "inflight": "^1.0.4", 186 | "inherits": "2", 187 | "minimatch": "^3.0.4", 188 | "once": "^1.3.0", 189 | "path-is-absolute": "^1.0.0" 190 | } 191 | }, 192 | "glob-parent": { 193 | "version": "5.1.1", 194 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", 195 | "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", 196 | "dev": true, 197 | "requires": { 198 | "is-glob": "^4.0.1" 199 | } 200 | }, 201 | "globby": { 202 | "version": "11.0.1", 203 | "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.1.tgz", 204 | "integrity": "sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==", 205 | "dev": true, 206 | "requires": { 207 | "array-union": "^2.1.0", 208 | "dir-glob": "^3.0.1", 209 | "fast-glob": "^3.1.1", 210 | "ignore": "^5.1.4", 211 | "merge2": "^1.3.0", 212 | "slash": "^3.0.0" 213 | } 214 | }, 215 | "graceful-fs": { 216 | "version": "4.2.4", 217 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", 218 | "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", 219 | "dev": true 220 | }, 221 | "ignore": { 222 | "version": "5.1.8", 223 | "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", 224 | "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", 225 | "dev": true 226 | }, 227 | "indent-string": { 228 | "version": "4.0.0", 229 | "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", 230 | "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", 231 | "dev": true 232 | }, 233 | "inflight": { 234 | "version": "1.0.6", 235 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 236 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 237 | "dev": true, 238 | "requires": { 239 | "once": "^1.3.0", 240 | "wrappy": "1" 241 | } 242 | }, 243 | "inherits": { 244 | "version": "2.0.4", 245 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 246 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 247 | "dev": true 248 | }, 249 | "is-extglob": { 250 | "version": "2.1.1", 251 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 252 | "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", 253 | "dev": true 254 | }, 255 | "is-glob": { 256 | "version": "4.0.1", 257 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", 258 | "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", 259 | "dev": true, 260 | "requires": { 261 | "is-extglob": "^2.1.1" 262 | } 263 | }, 264 | "is-number": { 265 | "version": "7.0.0", 266 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 267 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 268 | "dev": true 269 | }, 270 | "is-path-cwd": { 271 | "version": "2.2.0", 272 | "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", 273 | "integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==", 274 | "dev": true 275 | }, 276 | "is-path-inside": { 277 | "version": "3.0.2", 278 | "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.2.tgz", 279 | "integrity": "sha512-/2UGPSgmtqwo1ktx8NDHjuPwZWmHhO+gj0f93EkhLB5RgW9RZevWYYlIkS6zePc6U2WpOdQYIwHe9YC4DWEBVg==", 280 | "dev": true 281 | }, 282 | "merge2": { 283 | "version": "1.4.1", 284 | "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", 285 | "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", 286 | "dev": true 287 | }, 288 | "micromatch": { 289 | "version": "4.0.2", 290 | "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", 291 | "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", 292 | "dev": true, 293 | "requires": { 294 | "braces": "^3.0.1", 295 | "picomatch": "^2.0.5" 296 | } 297 | }, 298 | "minimatch": { 299 | "version": "3.0.4", 300 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 301 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 302 | "dev": true, 303 | "requires": { 304 | "brace-expansion": "^1.1.7" 305 | } 306 | }, 307 | "mkdirp": { 308 | "version": "1.0.4", 309 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", 310 | "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", 311 | "dev": true 312 | }, 313 | "once": { 314 | "version": "1.4.0", 315 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 316 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 317 | "dev": true, 318 | "requires": { 319 | "wrappy": "1" 320 | } 321 | }, 322 | "p-map": { 323 | "version": "4.0.0", 324 | "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", 325 | "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", 326 | "dev": true, 327 | "requires": { 328 | "aggregate-error": "^3.0.0" 329 | } 330 | }, 331 | "path-is-absolute": { 332 | "version": "1.0.1", 333 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 334 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 335 | "dev": true 336 | }, 337 | "path-type": { 338 | "version": "4.0.0", 339 | "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", 340 | "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", 341 | "dev": true 342 | }, 343 | "picomatch": { 344 | "version": "2.2.2", 345 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", 346 | "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", 347 | "dev": true 348 | }, 349 | "prettier": { 350 | "version": "2.2.1", 351 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz", 352 | "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==", 353 | "dev": true 354 | }, 355 | "reusify": { 356 | "version": "1.0.4", 357 | "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", 358 | "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", 359 | "dev": true 360 | }, 361 | "rimraf": { 362 | "version": "3.0.2", 363 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", 364 | "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", 365 | "dev": true, 366 | "requires": { 367 | "glob": "^7.1.3" 368 | } 369 | }, 370 | "run-parallel": { 371 | "version": "1.1.10", 372 | "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz", 373 | "integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==", 374 | "dev": true 375 | }, 376 | "slash": { 377 | "version": "3.0.0", 378 | "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", 379 | "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", 380 | "dev": true 381 | }, 382 | "source-map": { 383 | "version": "0.6.1", 384 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 385 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 386 | "dev": true 387 | }, 388 | "source-map-resolve": { 389 | "version": "0.6.0", 390 | "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.6.0.tgz", 391 | "integrity": "sha512-KXBr9d/fO/bWo97NXsPIAW1bFSBOuCnjbNTBMO7N59hsv5i9yzRDfcYwwt0l04+VqnKC+EwzvJZIP/qkuMgR/w==", 392 | "dev": true, 393 | "requires": { 394 | "atob": "^2.1.2", 395 | "decode-uri-component": "^0.2.0" 396 | } 397 | }, 398 | "to-regex-range": { 399 | "version": "5.0.1", 400 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 401 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 402 | "dev": true, 403 | "requires": { 404 | "is-number": "^7.0.0" 405 | } 406 | }, 407 | "wrappy": { 408 | "version": "1.0.2", 409 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 410 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 411 | "dev": true 412 | } 413 | } 414 | } 415 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@shoelace-style/animations", 3 | "description": "Your favorite animate.css effects available as ES modules for use with the Web Animations API.", 4 | "version": "1.2.0", 5 | "homepage": "https://github.com/shoelace-style/animations", 6 | "author": "Cory LaViska", 7 | "license": "MIT", 8 | "main": "dist/index.js", 9 | "module": "dist/index.js", 10 | "type": "module", 11 | "types": "dist/index.d.ts", 12 | "scripts": { 13 | "build": "node src/index.cjs", 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/shoelace-style/animations.git" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/shoelace-style/animations/issues" 22 | }, 23 | "funding": { 24 | "type": "individual", 25 | "url": "https://github.com/sponsors/claviska" 26 | }, 27 | "files": [ 28 | "dist/" 29 | ], 30 | "keywords": [ 31 | "animation", 32 | "web animations api", 33 | "animate.css" 34 | ], 35 | "dependencies": {}, 36 | "devDependencies": { 37 | "animate.css": "^4.1.1", 38 | "css": "^3.0.0", 39 | "del": "^6.0.0", 40 | "glob": "^7.1.6", 41 | "mkdirp": "^1.0.4", 42 | "prettier": "^2.2.1" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'avoid', 3 | bracketSpacing: true, 4 | htmlWhitespaceSensitivity: 'css', 5 | insertPragma: false, 6 | jsxBracketSameLine: false, 7 | jsxSingleQuote: false, 8 | printWidth: 120, 9 | proseWrap: 'preserve', 10 | quoteProps: 'as-needed', 11 | requirePragma: false, 12 | semi: true, 13 | singleQuote: true, 14 | tabWidth: 2, 15 | trailingComma: 'none', 16 | useTabs: false 17 | }; 18 | -------------------------------------------------------------------------------- /src/animations.cjs: -------------------------------------------------------------------------------- 1 | const css = require('css'); 2 | const fs = require('fs'); 3 | const glob = require('glob'); 4 | const path = require('path'); 5 | const __basedir = path.dirname(__dirname); 6 | 7 | module.exports = function () { 8 | return new Promise(resolve => { 9 | const animations = []; 10 | 11 | // Loop through all of the animation source files from animate.css 12 | glob(path.join(path.join(__basedir, 'node_modules/animate.css/source'), '**/*/*.css'), null, (err, files) => { 13 | files.map(file => { 14 | const name = path.parse(file).name; 15 | const group = path.parse(path.dirname(file)).name; 16 | const source = fs.readFileSync(file, 'utf8'); 17 | const parsed = css.parse(source); 18 | 19 | // Look for keyframe rules 20 | parsed.stylesheet.rules.map(rule => { 21 | if (rule.type !== 'keyframes') return; 22 | 23 | let keyframes = []; 24 | rule.keyframes.map(keyframe => { 25 | keyframe.values.map(value => { 26 | let offset = value; 27 | if (offset === 'from') offset = '0%'; 28 | if (offset === 'to') offset = '100%'; 29 | if (offset.indexOf('%') > -1) offset = parseFloat(offset) / 100; 30 | 31 | const properties = { offset }; 32 | 33 | keyframe.declarations.map(declaration => { 34 | let property = declaration.property; 35 | if (property === 'animation-timing-function') property = 'easing'; 36 | properties[property] = declaration.value; 37 | }); 38 | 39 | keyframes.push(properties); 40 | }); 41 | }); 42 | 43 | // Sort by offset 44 | keyframes = keyframes.sort((a, b) => { 45 | return parseFloat(a.offset) > parseFloat(b.offset) ? 1 : -1; 46 | }); 47 | 48 | animations.push({ 49 | group, 50 | name: rule.name, 51 | keyframes: keyframes 52 | }); 53 | }); 54 | }); 55 | 56 | resolve(animations); 57 | }); 58 | }); 59 | }; 60 | -------------------------------------------------------------------------------- /src/easings.js: -------------------------------------------------------------------------------- 1 | export const easings = { 2 | linear: 'linear', 3 | ease: 'ease', 4 | easeIn: 'ease-in', 5 | easeOut: 'ease-out', 6 | easeInOut: 'ease-in-out', 7 | easeInSine: 'cubic-bezier(0.47, 0, 0.745, 0.715)', 8 | easeOutSine: 'cubic-bezier(0.39, 0.575, 0.565, 1)', 9 | easeInOutSine: 'cubic-bezier(0.445, 0.05, 0.55, 0.95)', 10 | easeInQuad: 'cubic-bezier(0.55, 0.085, 0.68, 0.53)', 11 | easeOutQuad: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)', 12 | easeInOutQuad: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)', 13 | easeInCubic: 'cubic-bezier(0.55, 0.055, 0.675, 0.19)', 14 | easeOutCubic: 'cubic-bezier(0.215, 0.61, 0.355, 1)', 15 | easeInOutCubic: 'cubic-bezier(0.645, 0.045, 0.355, 1)', 16 | easeInQuart: 'cubic-bezier(0.895, 0.03, 0.685, 0.22)', 17 | easeOutQuart: 'cubic-bezier(0.165, 0.84, 0.44, 1)', 18 | easeInOutQuart: 'cubic-bezier(0.77, 0, 0.175, 1)', 19 | easeInQuint: 'cubic-bezier(0.755, 0.05, 0.855, 0.06)', 20 | easeOutQuint: 'cubic-bezier(0.23, 1, 0.32, 1)', 21 | easeInOutQuint: 'cubic-bezier(0.86, 0, 0.07, 1)', 22 | easeInExpo: 'cubic-bezier(0.95, 0.05, 0.795, 0.035)', 23 | easeOutExpo: 'cubic-bezier(0.19, 1, 0.22, 1)', 24 | easeInOutExpo: 'cubic-bezier(1, 0, 0, 1)', 25 | easeInCirc: 'cubic-bezier(0.6, 0.04, 0.98, 0.335)', 26 | easeOutCirc: 'cubic-bezier(0.075, 0.82, 0.165, 1)', 27 | easeInOutCirc: 'cubic-bezier(0.785, 0.135, 0.15, 0.86)', 28 | easeInBack: 'cubic-bezier(0.6, -0.28, 0.735, 0.045)', 29 | easeOutBack: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)', 30 | easeInOutBack: 'cubic-bezier(0.68, -0.55, 0.265, 1.55)' 31 | }; 32 | -------------------------------------------------------------------------------- /src/index.cjs: -------------------------------------------------------------------------------- 1 | const del = require('del'); 2 | const fs = require('fs'); 3 | const path = require('path'); 4 | const prettier = require('prettier'); 5 | const mkdirp = require('mkdirp'); 6 | 7 | const __basedir = path.dirname(__dirname); 8 | const parseAnimations = require('./animations.cjs'); 9 | const outputDir = path.join(__basedir, 'dist'); 10 | const prettierOptions = { 11 | parser: 'babel', 12 | printWidth: 120, 13 | singleQuote: true, 14 | trailingComma: 'none' 15 | }; 16 | 17 | // Cleanup old files 18 | del.sync(outputDir); 19 | 20 | // Create the output directories 21 | mkdirp.sync(outputDir); 22 | 23 | parseAnimations().then(animations => { 24 | // Generate animations module 25 | animations.map(animation => { 26 | const filename = path.join(outputDir, animation.group, `${animation.name}.js`); 27 | mkdirp.sync(path.dirname(filename)); 28 | 29 | const animationSource = prettier.format( 30 | `export const ${animation.name} = ${JSON.stringify(animation.keyframes)};`, 31 | prettierOptions 32 | ); 33 | fs.writeFileSync(filename, animationSource, 'utf8'); 34 | }); 35 | 36 | // Generate animations index 37 | let animationsIndexSource = ''; 38 | animations.map(animation => (animationsIndexSource += `export * from './${animation.group}/${animation.name}.js';`)); 39 | animationsIndexSource += `export { easings } from './easings/easings.js'`; 40 | animationsIndexSource = prettier.format(animationsIndexSource, prettierOptions); 41 | fs.writeFileSync(path.join(outputDir, 'index.js'), animationsIndexSource, 'utf8'); 42 | 43 | // Generate types.d.ts 44 | let typesSource = `declare module '@shoelace-style/animations' { 45 | export type Animation = Keyframe[]; 46 | export const animations: Animation[]; 47 | export const easings: { [key: string]: string }; 48 | ${animations.map(animation => `export const ${animation.name}: Animation;`).join('\n')} 49 | }`; 50 | typesSource = prettier.format(typesSource, {...prettierOptions, parser: 'babel-ts'}); 51 | fs.writeFileSync(path.join(outputDir, 'index.d.ts'), typesSource, 'utf8'); 52 | }); 53 | 54 | // Copy easings.js to dist 55 | mkdirp.sync(path.join(outputDir, 'easings')); 56 | fs.copyFileSync(path.join(__basedir, 'src/easings.js'), path.join(outputDir, 'easings/easings.js')); 57 | 58 | // Copy animate.css license to dist 59 | fs.copyFileSync(path.join(__basedir, 'node_modules/animate.css/LICENSE'), path.join(outputDir, 'LICENSE')); 60 | --------------------------------------------------------------------------------