├── .browserslistrc ├── _tests ├── data │ ├── animation1 │ │ ├── animation1.fla │ │ ├── animation1.html │ │ └── animation1.js │ ├── animation2 │ │ ├── animation2.fla │ │ ├── images │ │ │ └── animation2_atlas_1.png │ │ ├── animation2.html │ │ └── animation2.js │ ├── animation3 │ │ ├── animation3.fla │ │ ├── images │ │ │ └── animation3_atlas_1.png │ │ ├── animation3.html │ │ └── animation3.js │ ├── animation4 │ │ ├── animation4.fla │ │ ├── images │ │ │ └── animation4_atlas_1.png │ │ ├── animation4.html │ │ └── animation4.js │ ├── animation5 │ │ └── RENAMED.js │ └── animation6 │ │ └── blog-stoerer.js └── index.html ├── .prettierrc ├── .gitignore ├── .babelrc ├── .eslintrc.js ├── README.md └── package.json /.browserslistrc: -------------------------------------------------------------------------------- 1 | IE >= 11 2 | > 0.25% 3 | not dead -------------------------------------------------------------------------------- /_tests/data/animation1/animation1.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidhasson22321/adobe-animate-embed/HEAD/_tests/data/animation1/animation1.fla -------------------------------------------------------------------------------- /_tests/data/animation2/animation2.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidhasson22321/adobe-animate-embed/HEAD/_tests/data/animation2/animation2.fla -------------------------------------------------------------------------------- /_tests/data/animation3/animation3.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidhasson22321/adobe-animate-embed/HEAD/_tests/data/animation3/animation3.fla -------------------------------------------------------------------------------- /_tests/data/animation4/animation4.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidhasson22321/adobe-animate-embed/HEAD/_tests/data/animation4/animation4.fla -------------------------------------------------------------------------------- /_tests/data/animation2/images/animation2_atlas_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidhasson22321/adobe-animate-embed/HEAD/_tests/data/animation2/images/animation2_atlas_1.png -------------------------------------------------------------------------------- /_tests/data/animation3/images/animation3_atlas_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidhasson22321/adobe-animate-embed/HEAD/_tests/data/animation3/images/animation3_atlas_1.png -------------------------------------------------------------------------------- /_tests/data/animation4/images/animation4_atlas_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davidhasson22321/adobe-animate-embed/HEAD/_tests/data/animation4/images/animation4_atlas_1.png -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "tabWidth": 4, 4 | "printWidth": 120, 5 | "trailingComma": "none", 6 | "trailingCommaPHP": false, 7 | "phpVersion": "7.2", 8 | "arrowParens": "avoid" 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /_public/* 2 | !/_public/.gitkeep 3 | /_build/ 4 | /node_modules/ 5 | /vendor/ 6 | /logs/ 7 | /usage/ 8 | /_vue/_build/ 9 | /_js/_build/ 10 | /_tests/_build/ 11 | /package-lock.json 12 | __image_snapshots__ 13 | /.env 14 | *.css.map 15 | *.js.map 16 | *.tmp-browserify* 17 | /composer.lock -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "useBuiltIns": "usage", 7 | "corejs": { "version": "3.8", "proposals": true } 8 | } 9 | ], 10 | "@babel/preset-react" 11 | ], 12 | "plugins": [ 13 | "@babel/plugin-transform-runtime", 14 | "@babel/plugin-proposal-class-properties", 15 | "@babel/plugin-proposal-optional-chaining", 16 | "@babel/plugin-proposal-private-methods" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true, 4 | es6: true, 5 | jquery: true, 6 | amd: true, 7 | node: true 8 | }, 9 | extends: 'eslint:recommended', 10 | parserOptions: { 11 | ecmaVersion: 2021, 12 | sourceType: 'module' 13 | }, 14 | rules: { 15 | quotes: ['error', 'single', { allowTemplateLiterals: true }], 16 | semi: ['error', 'always'], 17 | 'linebreak-style': 0, 18 | 'no-console': 'off', 19 | 'no-unused-vars': 'off' 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /_tests/data/animation1/animation1.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | animation1 15 | 16 | 17 | 18 | 46 | 47 | 48 | 49 |
50 | 51 |
52 |
53 |
54 | 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🍿 adobe-animate-embed 🍿 2 | 3 | embed canvas animations generated with adobe animate the way it should be. 4 | 5 | ## supports 6 | 7 | - fully responsive to the parent container 8 | - full or partly transparent backgrounds 9 | - auto play and rewind on mouse over and out 10 | - no need to manually embed createjs (e.g. from an external cdn) 11 | - simple caching mechanism when loading published files from adobe animate 12 | - control loop, rewind and play/pause 13 | - embedding of multiple animations (from the same source) on the same page 14 | - different fps in different animations, also manually modify speed 15 | - full ie11 support 16 | 17 | ## installation 18 | 19 | ### directly 20 | 21 | ```html 22 | 23 | ``` 24 | 25 | ### library 26 | 27 | ```sh 28 | npm install adobe-animate-embed 29 | ``` 30 | 31 | ```js 32 | import aae from 'adobe-animate-embed'; 33 | ``` 34 | 35 | ## usage 36 | 37 | first create an animation in adobe animate of type [html5 canvas](https://helpx.adobe.com/animate/using/creating-publishing-html5-canvas-document.html) and publish the animation with the default values into e.g. /data/animation1/. for more information look at this [blog article](https://vielhuber.de/blog/adobe-animate-animationen-nativ-einbinden/). 38 | 39 | now prepare an empty container: 40 | 41 | ```html 42 |
43 | ``` 44 | 45 | instantiate the animation by referencing the js file from the folder created above: 46 | 47 | ```js 48 | let a1 = new aae( 49 | document.querySelector('.anim1'), // dom element, where the animation should be instantiated 50 | '/data/animation1/animation1.js' // url to the js file; can be an absolute or relative link 51 | ); 52 | ``` 53 | 54 | it's time to run the animation: 55 | 56 | ```js 57 | a1.start(); 58 | ``` 59 | 60 | by default the loop setting from the publish settings is used. 61 | however, you can change this dynamically: 62 | 63 | ```js 64 | a1.start(true); // run in loop 65 | a1.start(false); // run once 66 | ``` 67 | 68 | you even can rewind an animation and play it backwards: 69 | 70 | ```js 71 | a1.start(null, false); // run forwards 72 | a1.start(null, true); // run backwards 73 | ``` 74 | 75 | `start` immediately starts the animation. however, you can also show only the first frame: 76 | 77 | ```js 78 | a1.start(null, null, false); // no autoplay 79 | a1.resume(); 80 | ``` 81 | 82 | you can manually adjust the speed of an animation: 83 | 84 | ```js 85 | a1.start(null, null, null, 2); // play at double speed 86 | ``` 87 | 88 | often you want an animation to play when hovering an element and rewind when unhovering.\ 89 | the library provides a handy shortcut for that: 90 | 91 | ```js 92 | a1.hover(); 93 | ``` 94 | 95 | you can stop, pause or destroy the animation at any time: 96 | 97 | ```js 98 | a1.stop(); 99 | a1.pause(); 100 | a1.destroy(); 101 | ``` 102 | 103 | ## caveats 104 | 105 | - easing functions such as "elastic" are not cleanly supported by Animate CC after the export 106 | -------------------------------------------------------------------------------- /_tests/data/animation2/animation2.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | animation2 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
63 | 64 |
65 |
66 |
67 | 68 | -------------------------------------------------------------------------------- /_tests/data/animation3/animation3.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | animation3 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
63 | 64 |
65 |
66 |
67 | 68 | -------------------------------------------------------------------------------- /_tests/data/animation4/animation4.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | animation4 15 | 16 | 17 | 18 | 59 | 60 | 61 | 62 |
63 | 64 |
65 |
66 |
67 | 68 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "adobe-animate-embed", 3 | "version": "1.0.8", 4 | "main": "_build/script.js", 5 | "files": [ 6 | "_build/*.js", 7 | "adobe-animate-embed.min.js" 8 | ], 9 | "scripts": { 10 | "🔽 js 🔽": "", 11 | "js": "npm-run-all --sequential js:browserify js:minify js:babel", 12 | "js:dev": "npm-run-all --sequential js:browserify js:babel", 13 | "js:watch": "onchange ./_js/*.js ./_js/**/*.js --initial --poll 25 --delay 0 --await-write-finish 25 -- onerror \"npm run js:dev\" --title \"js:watch\" --message \"build failed\" --sound mute", 14 | "js:browserify": "browserify ./_js/script.js --outfile ./adobe-animate-embed.min.js --debug -g [ browserify-css --minify=true --stripComments=true ] --transform babelify", 15 | "js:minify": "terser --compress --mangle --output ./adobe-animate-embed.min.js ./adobe-animate-embed.min.js", 16 | "js:babel": "npx babel ./_js/ --out-dir ./_build/", 17 | " ": "", 18 | "🔽 pipelines 🔽": "", 19 | "prod": "cross-env NODE_ENV=production npm-run-all --sequential js", 20 | "dev": "cross-env NODE_ENV=development npm-run-all --parallel js:watch" 21 | }, 22 | "devDependencies": { 23 | "@babel/cli": "^7.20.7", 24 | "@babel/core": "^7.20.12", 25 | "@babel/plugin-proposal-class-properties": "^7.18.6", 26 | "@babel/plugin-proposal-object-rest-spread": "^7.20.7", 27 | "@babel/plugin-proposal-optional-chaining": "^7.20.7", 28 | "@babel/plugin-proposal-private-methods": "^7.18.6", 29 | "@babel/plugin-transform-runtime": "^7.19.6", 30 | "@babel/polyfill": "^7.12.1", 31 | "@babel/preset-env": "^7.20.2", 32 | "@babel/preset-react": "^7.18.6", 33 | "@babel/runtime": "^7.20.7", 34 | "@prettier/plugin-php": "^0.19.3", 35 | "autoprefixer": "^10.4.13", 36 | "babel-core": "^7.0.0-bridge.0", 37 | "babel-jest": "^29.3.1", 38 | "babel-plugin-array-includes": "^2.0.3", 39 | "babelify": "^10.0.0", 40 | "browser-sync": "^2.27.11", 41 | "browserify": "^17.0.0", 42 | "browserify-css": "^0.15.0", 43 | "cli-error-notifier": "^3.0.1", 44 | "concat": "^1.0.3", 45 | "core-js": "^3.27.2", 46 | "cpx": "^1.5.0", 47 | "critical": "^5.0.4", 48 | "cross-env": "^7.0.3", 49 | "cross-spawn": "^7.0.3", 50 | "cross-var": "^1.1.0", 51 | "cssnano": "^5.1.14", 52 | "del-cli": "^5.0.0", 53 | "dotenv": "^16.0.3", 54 | "element-closest": "^3.0.2", 55 | "env-cmd": "^10.1.0", 56 | "eslint": "^8.32.0", 57 | "exit": "^0.1.2", 58 | "from-env": "^1.1.4", 59 | "gulp": "^4.0.2", 60 | "gulp-autoprefixer": "^8.0.0", 61 | "gulp-babel": "^8.0.0", 62 | "gulp-clean-css": "^4.3.0", 63 | "gulp-concat": "^2.6.1", 64 | "gulp-connect": "^5.7.0", 65 | "gulp-htmlmin": "^5.0.1", 66 | "gulp-jest": "^4.0.4", 67 | "gulp-penthouse": "^0.2.0", 68 | "gulp-rename": "^2.0.0", 69 | "gulp-sass": "^5.1.0", 70 | "gulp-sourcemaps": "^3.0.0", 71 | "gulp-uglify": "^3.0.2", 72 | "gulp-vueify": "0.0.3", 73 | "highlight.js": "^11.7.0", 74 | "hlp": "^3.3.0", 75 | "html-minifier": "^4.0.0", 76 | "inline-source-cli": "^2.0.0", 77 | "ismobilejs": "^1.1.1", 78 | "jest": "^29.3.1", 79 | "jest-cli": "^29.3.1", 80 | "jest-image-snapshot": "^6.1.0", 81 | "jest-puppeteer": "^6.2.0", 82 | "mdn-polyfills": "^5.20.0", 83 | "move-file-cli": "^3.0.0", 84 | "ncp": "^2.0.0", 85 | "node-sass": "^8.0.0", 86 | "npm-check-updates": "^16.6.2", 87 | "npm-run-all": "^4.1.5", 88 | "onchange": "^7.1.0", 89 | "postcss": "^8.4.21", 90 | "postcss-cli": "^10.1.0", 91 | "postcss-tailwind-data-attr": "^1.0.7", 92 | "postcss-url": "^10.1.3", 93 | "prettier": "^2.8.3", 94 | "puppeteer": "^19.5.2", 95 | "regenerator-runtime": "^0.13.11", 96 | "replace-in-file": "^6.3.5", 97 | "rimraf": "^4.1.1", 98 | "run-sequence": "^2.2.1", 99 | "tailwindcss": "^3.2.4", 100 | "terser": "^5.16.1", 101 | "through-gulp": "^0.5.0", 102 | "uglify": "^0.1.5", 103 | "uglify-js": "^3.17.4", 104 | "vinyl-buffer": "^1.0.1", 105 | "vinyl-source-stream": "^2.0.0", 106 | "vue": "^3.2.45", 107 | "vue-template-compiler": "^2.7.14", 108 | "vueify": "^9.4.1", 109 | "vueify-insert-css": "^1.0.0", 110 | "whatwg-fetch": "^3.6.2" 111 | }, 112 | "description": "", 113 | "author": "", 114 | "license": "ISC", 115 | "dependencies": {} 116 | } 117 | -------------------------------------------------------------------------------- /_tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | . 7 | 8 | 66 | 100 | 101 | 102 |

hover example

103 |
104 | 105 |

control example

106 | start (no loop, no rewind) - 107 | start (no loop, rewind) - 108 | start (loop, no rewind) - 109 | start (loop, rewind) - 110 | start (loop, rewind, no autoplay) - 111 | hover - destroy - 112 | pause - resume - 113 | stop 114 |
115 | 116 |

other examples

117 |
121 |
122 |
123 |
124 |
125 |
126 | 127 | 128 | -------------------------------------------------------------------------------- /_tests/data/animation5/RENAMED.js: -------------------------------------------------------------------------------- 1 | (function (cjs, an) { 2 | 3 | var p; // shortcut to reference prototypes 4 | var lib={};var ss={};var img={}; 5 | lib.ssMetadata = []; 6 | 7 | 8 | (lib.AnMovieClip = function(){ 9 | this.actionFrames = []; 10 | this.ignorePause = false; 11 | this.gotoAndPlay = function(positionOrLabel){ 12 | cjs.MovieClip.prototype.gotoAndPlay.call(this,positionOrLabel); 13 | } 14 | this.play = function(){ 15 | cjs.MovieClip.prototype.play.call(this); 16 | } 17 | this.gotoAndStop = function(positionOrLabel){ 18 | cjs.MovieClip.prototype.gotoAndStop.call(this,positionOrLabel); 19 | } 20 | this.stop = function(){ 21 | cjs.MovieClip.prototype.stop.call(this); 22 | } 23 | }).prototype = p = new cjs.MovieClip(); 24 | // symbols: 25 | 26 | 27 | 28 | (lib.Tween8 = function(mode,startPosition,loop,reversed) { 29 | if (loop == null) { loop = true; } 30 | if (reversed == null) { reversed = false; } 31 | var props = new Object(); 32 | props.mode = mode; 33 | props.startPosition = startPosition; 34 | props.labels = {}; 35 | props.loop = loop; 36 | props.reversed = reversed; 37 | cjs.MovieClip.apply(this,[props]); 38 | 39 | // Ebene_1 40 | this.shape = new cjs.Shape(); 41 | this.shape.graphics.f("#00FF33").s().p("Egj5Aj6Qu3u4AA1CQAA1BO3u4QO4u3VBAAQVCAAO4O3QO3O4AAVBQAAVCu3O4Qu4O31CAAQ1BAAu4u3g"); 42 | 43 | this.timeline.addTween(cjs.Tween.get(this.shape).wait(1)); 44 | 45 | this._renderFirstFrame(); 46 | 47 | }).prototype = p = new cjs.MovieClip(); 48 | p.nominalBounds = new cjs.Rectangle(-324.9,-324.9,649.8,649.8); 49 | 50 | 51 | (lib.Tween7 = function(mode,startPosition,loop,reversed) { 52 | if (loop == null) { loop = true; } 53 | if (reversed == null) { reversed = false; } 54 | var props = new Object(); 55 | props.mode = mode; 56 | props.startPosition = startPosition; 57 | props.labels = {}; 58 | props.loop = loop; 59 | props.reversed = reversed; 60 | cjs.MovieClip.apply(this,[props]); 61 | 62 | // Ebene_1 63 | this.shape = new cjs.Shape(); 64 | this.shape.graphics.f("#00FF33").s().p("Egj4Aj5Qu4u3AA1CQAA1BO4u3QO3u4VBAAQVCAAO3O4QO4O3AAVBQAAVCu4O3Qu3O41CAAQ1BAAu3u4g"); 65 | 66 | this.timeline.addTween(cjs.Tween.get(this.shape).wait(1)); 67 | 68 | this._renderFirstFrame(); 69 | 70 | }).prototype = p = new cjs.MovieClip(); 71 | p.nominalBounds = new cjs.Rectangle(-324.9,-324.9,649.8,649.8); 72 | 73 | 74 | // stage content: 75 | (lib.TEST = function(mode,startPosition,loop,reversed) { 76 | if (loop == null) { loop = true; } 77 | if (reversed == null) { reversed = false; } 78 | var props = new Object(); 79 | props.mode = mode; 80 | props.startPosition = startPosition; 81 | props.labels = {}; 82 | props.loop = loop; 83 | props.reversed = reversed; 84 | cjs.MovieClip.apply(this,[props]); 85 | 86 | // TEST 87 | this.instance = new lib.Tween7("synched",0); 88 | this.instance.setTransform(910.75,1337.8); 89 | 90 | this.instance_1 = new lib.Tween8("synched",0); 91 | this.instance_1.setTransform(2294.65,1053.9); 92 | 93 | this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1}]},112).wait(11)); 94 | this.timeline.addTween(cjs.Tween.get(this.instance).to({_off:true,x:2294.65,y:1053.9},112,cjs.Ease.quintInOut).wait(11)); 95 | 96 | this._renderFirstFrame(); 97 | 98 | }).prototype = p = new lib.AnMovieClip(); 99 | p.nominalBounds = new cjs.Rectangle(2335.9,1779,283.6999999999998,-116.29999999999995); 100 | // library properties: 101 | lib.properties = { 102 | id: '51B2527E75494B87BE2CE32B6734DFEF', 103 | width: 3500, 104 | height: 2100, 105 | fps: 60, 106 | color: "#FFFFFF", 107 | opacity: 0.00, 108 | manifest: [], 109 | preloads: [] 110 | }; 111 | 112 | 113 | 114 | // bootstrap callback support: 115 | 116 | (lib.Stage = function(canvas) { 117 | createjs.Stage.call(this, canvas); 118 | }).prototype = p = new createjs.Stage(); 119 | 120 | p.setAutoPlay = function(autoPlay) { 121 | this.tickEnabled = autoPlay; 122 | } 123 | p.play = function() { this.tickEnabled = true; this.getChildAt(0).gotoAndPlay(this.getTimelinePosition()) } 124 | p.stop = function(ms) { if(ms) this.seek(ms); this.tickEnabled = false; } 125 | p.seek = function(ms) { this.tickEnabled = true; this.getChildAt(0).gotoAndStop(lib.properties.fps * ms / 1000); } 126 | p.getDuration = function() { return this.getChildAt(0).totalFrames / lib.properties.fps * 1000; } 127 | 128 | p.getTimelinePosition = function() { return this.getChildAt(0).currentFrame / lib.properties.fps * 1000; } 129 | 130 | an.bootcompsLoaded = an.bootcompsLoaded || []; 131 | if(!an.bootstrapListeners) { 132 | an.bootstrapListeners=[]; 133 | } 134 | 135 | an.bootstrapCallback=function(fnCallback) { 136 | an.bootstrapListeners.push(fnCallback); 137 | if(an.bootcompsLoaded.length > 0) { 138 | for(var i=0; i 0) { 127 | for(var i=0; i 0) { 346 | for(var i=0; i 0) { 660 | for(var i=0; i 0) { 660 | for(var i=0; i 0) { 660 | for(var i=0; i