D
D
Dezzigner2016-09-07 13:02:56
JavaScript
Dezzigner, 2016-09-07 13:02:56

How to play Canvas animation at a certain moment of scrolling?

Hello. There is a Canvas animation made in Adobe Animate CC, when the page loads, the animation plays automatically and when you get to it, you see only the picture with the final result.
How can I make the animation play only when it enters the screen view?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Zolotykh, 2016-09-07
@zolotykh

This animation has a start function, you need to delay it until the block appears in the scope.

var $animationBlock = $('_selector_to_element');
var $window = $(window);

$window.on('scroll', function(){
  if ($animationBlock.offset().top >= $window.scrollTop()){
    // animation function
  }
});

D
Dezzigner, 2016-09-07
@Dezzzigner

Excuse me, I'm an amateur in JS, to put it mildly, can you write what and where to substitute?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question