• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Scale animation to fit parent container - not window size.

New Here ,
Apr 04, 2017 Apr 04, 2017

Copy link to clipboard

Copied

Hi All,

I have an animation that I am trying to embed into a bootstrap template, but window size is being applied to the canvas rather than parent container (div).

Therefore the animation is huge and flowing outside of the column.

I have exported the animation with the following selected:

- Make responsive (by width)

- Scale to fill visible area (fit in view)

All the solutions I can find for this are based on Edge animate (bScaleToParent) and not Animate CC.

Any help would be much appreciated, thanks!

Views

4.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

New Here , Feb 24, 2018 Feb 24, 2018

Hi Ryan,

It's a rude solution but works:

You must edit the script in the html file that Animate publish whatever name you have.

//create an div with an id that wraps all animate's divs - animation container, in my case a div#parentContainer

1.-  Inside the resizeCanvas function: (at the beginning )

function resizeCanvas() {

//get the parent element

var parent = document.getElementById("parentContainer");

//you can set the width of the parent container with css, but you must add this line in order to mai

...

Votes

Translate

Translate
New Here ,
Feb 24, 2018 Feb 24, 2018

Copy link to clipboard

Copied

Hi Ryan,

It's a rude solution but works:

You must edit the script in the html file that Animate publish whatever name you have.

//create an div with an id that wraps all animate's divs - animation container, in my case a div#parentContainer

1.-  Inside the resizeCanvas function: (at the beginning )

function resizeCanvas() {

//get the parent element

var parent = document.getElementById("parentContainer");

//you can set the width of the parent container with css, but you must add this line in order to maintain the ratio in proportion with parent width of animate Stage:

//in my case my stage's size is 550x400 , add your size in the formula

parent.style.height= (parent.clientWidth * (400 / 550)+"px");

2.- in this line switch with your parent's size:

// var iw = window.innerWidth, ih=window.innerHeight; this is what we don't want

put this line instead, the parent size.

var iw = parentclientWidth, ih= parent.clientHeight;   


3.- Finally in the call of makeResponsive function, at the bottom of the script use this parameters:

makeResponsive(true,"both",true,1);


it works changing 4 lines of code in the main script of Animate CC.

Sorry for my English.


I hope it helps!
Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 21, 2018 Jun 21, 2018

Copy link to clipboard

Copied

thank you, I can confirm this works solution perfectly!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2018 Sep 19, 2018

Copy link to clipboard

Copied

Thanks luiss70215192, it works!

I was searching for this solution from ages!

Why the Hell adobe doesn't fix that?

Question: is there a way to integrate this fix in the animate html template? I'm not good as you are at programming...

Tony

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 17, 2018 Nov 17, 2018

Copy link to clipboard

Copied

Does anyone have an example of this in situ? I've tried adding/replacing the 4 lines of code. But when I do it the animation disappears completely and the width of the page explodes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

var iw = parent.clientWidth, ih= parent.clientHeight;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

Thanks for this!  This solution works perfectly to make animations respect their parent container.

 

I have created a small .php/.js script which automates this process.  If anybody would like this script, let me know and I'll send it to you.  It basically lets you drag & drop the .js and .html files that Animate generates, and then it returns two hacked .js and .html files, according to the instructions posted here, which releases the animation from the window canvas size, and allows you to place it inside of whatever parent container you want, without using iframes.

 

Without this php/js solution, Animate is useless to me, because of the 'speedbump' of having to hack the generated files that Animate publishes.

 

With this php/js script, it streamlines the process of having to manually edit the files, and it restores the standard functionality of HTML and CSS.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

Hello John, thank you very much, I would appreciate a lot your script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

Nevermind, I have tested it today and it is not working.  Maybe there was an update in the Animate software since this solution was found?  If this is really important to anyone, please explain why, and I'll find the time to update the script so it works again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

@JohnJackG 

 

exactly what are you doing and what are you trying to accomplish?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

@kglad  thanks for asking, but it's nothing I'm looking for support for, though I'll explain it since you asked.

 

@Yago268414784rud has asked me to share a script which I had made a little over a year ago, which incorporated the OP's answer into an automated webpage that uses PHP and JS to allow me to upload my Animate files, to have the script process them and 'fix' them so that I can embed them into any DOM container on any given page I'm using an Animate animation in.

 

I had typed out a response to Yago saying, "Here's the script, here's how you use it, here's how you download the files to use on your own server, etc..." and at first when I tested the script earlier today, it appeared to work fine, but when I came back and looked closer, I noticed something wasn't working right, so I took it down and made the offer that if it's something that would really help someone else, I would update the script and make it work again.

 

Hopefully, one day Adobe will update the Animate software and this kind of 'fix' won't be needed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

ok

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 15, 2023 Feb 15, 2023

Copy link to clipboard

Copied

LATEST

Thank you anyway!!! The fix explained in the post works fine, so it's solved.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 14, 2023 Feb 14, 2023

Copy link to clipboard

Copied

I got it!!!! Thank you very much @luiss70215192 !!! I'm very happy!!!! XD

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 08, 2021 Jul 08, 2021

Copy link to clipboard

Copied

After correcting the line "var iw = parent.clientWidth, ih= parent.clientHeight;" it wasn't working yet because of the last step, I just left it this way:

AdobeAn.makeResponsive(true,'both',false,1,[canvas,anim_container,dom_overlay_container]);

and everything worked like charm!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines