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

How do I animate the timeline with the mouse wheel in Animate CC?

Community Beginner ,
Aug 06, 2018 Aug 06, 2018

Hi everyone! The title says it all.

My project is HTML5 Canvas

I have an animation on my main timeline and I will like to control the animation with the mouse wheel going forward and backwards, and if I don't touch the mouse wheel it won't start.

How do I do this on my action layer?

Thanks!!!

8.7K
Translate
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

Community Expert , Aug 06, 2018 Aug 06, 2018

UPDATED ANSWER (05/28/2021):

https://github.com/joao-cesar/adobe/tree/master/animate%20cc/html5_canvas/mouse_wheel_navigation

 

 

var that = this;
this.targetTimeline = this;
this.targetTimeline.loop = true;
this.targetTimeline.force = 40;
this.targetTimeline.friction = 0.9;
this.targetTimeline.minFrame = 0; // set the start range value here
this.targetTimeline.maxFrame = this.targetTimeline.totalFrames - 1; // set the end range value here

this.loopClamp = function(value, min, max)
{
	if (value
...
Translate
Community Beginner ,
Jul 16, 2023 Jul 16, 2023

Hi @JoãoCésar first of all thank you very much for your help.
Wondering about, is it possible to adjust the speed with the actual mousewheel speed? I mean, if the user scrolls fast, animation will play fast - vice versa. Thanks!

Translate
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 ,
Jul 16, 2023 Jul 16, 2023

@susegad 

 

the frequency of the wheel events can be used to determine the speed of your timeline.

 

window.addEventListener("wheel",wheelF.bind(this));

function wheelF(e){

if(e.wheelDelta<0){

whatevertimeline.gotoAndStop(whatevertimeline.currentFrame+1);  // shoud perform out of bounds check

} else {

whatevertimeline.gotoAndStop(whatevertimeline.currentFrame-1);   // shoud perform out of bounds check

}

}

Translate
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 ,
Oct 24, 2019 Oct 24, 2019

Thank You!!!!

Translate
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 31, 2020 Jul 31, 2020

How to invert mouse wheel?

Translate
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 31, 2020 Jul 31, 2020

OK, FOUND: that.targetTimeline.speed = -delta * that.force;

Translate
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 31, 2020 Jul 31, 2020

I really need a solution to make it works also with mobile swipe. Can you help me please?

Translate
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 07, 2020 Sep 07, 2020

Hi there, is there similar code to animate with page scroll rather than mouse wheel? Thanks in advance!

 

Ollie

Translate
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 ,
Sep 07, 2020 Sep 07, 2020

Hi.

 

This may be what you want.

https://github.com/joao-cesar/adobe/tree/master/animate%20cc/html5_canvas/animate_on_scroll

 

Please let us know.

 

Regards,

JC

Translate
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 07, 2020 Sep 07, 2020

Hi Joao,

 

Thank you so much for getting back to me so quickly, unfortunately this does not work in the same way. In the code you originally supplied the animation plays and reverses with the mouse scroll but not the page scroll, it would be perfect if the animation was controlled in exactly the same with but with page scroll rather than mouse scroll. Do you know of a way to do this?

 

Thanks,

Ollie

Translate
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 ,
Jan 17, 2023 Jan 17, 2023

Hi Joao,

 

I know this is an old thread so I'm hoping you're still around to assist.

 

I'm having some trouble getting this work. 

 

My clip just animates without waiting for input from the mouse wheel.

 

Looking at the working file, is the "hit" button important?

Translate
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 ,
Jan 18, 2023 Jan 18, 2023

Hi.

 

The hit instance is required for touch drag. But you can remove it and the related code if you wish.

 

And are you getting any error in the browser console (F12)?

Translate
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