D
D
Dezzigner2016-09-07 15:27:23
JavaScript
Dezzigner, 2016-09-07 15:27:23

How to set up JS code for animation?

I asked this question -
"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 to make the animation play only when it comes into view screen?"
I received a code in response with a note -
"This animation has a launch function, you need to postpone 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
  }
});

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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2016-09-07
@Beefeater

Do you know where and what the code that performs the animation looks like?
And how to find element in Html?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question