A
A
Alexey Sklyarov2016-06-07 22:53:39
JavaScript
Alexey Sklyarov, 2016-06-07 22:53:39

How to execute js functions one by one for all browsers?

There is a set of simple functions that are executed after a certain period of time (each through its own). The essence of these functions is to create a simple animation of two objects, movement, adding a css animation class, and so on. All functions are in the html document itself, without connection through files. I noticed one feature that is not clear to me: in Chrome, IE, Firefox, the functions are executed in a different order.
Some of the functions are written using the Move.js library

$(document).ready(function() {
move('.home-img-animate-1').ease('in').x(1150).duration('2s').end();
move('.home-img-animate-1').set('opacity', .0).then().set('opacity', 1).duration('2s').pop().end();
move('.home-img-animate-steak').ease('in').y(-300).duration('1.5s').end();
move('.home-img-animate-steak').set('opacity', .0).then().set('opacity', 1).duration('2s').pop().end();
move('.home-img-animate-knife').ease('in').x(-300).duration('1.5s').end();
move('.home-img-animate-knife').set('opacity', .0).then().set('opacity', 1).duration('2s').pop().end();
move('.home-img-animate-2').ease('in').x(-1050).duration('2s').end();
move('.home-img-animate-2').set('opacity', .0).then().set('opacity', 1).duration('2s').pop().end();
move('.home-img-animate-3').set('opacity', .0).then().set('opacity', 1).duration('6s').pop().end();
});

The part just adds or changes classes:
function func_remove_2() {
      $( ".home-img-animate-1, .home-img-animate-2" ).removeClass( "alarm" );
    }

setTimeout(func_remove_2, 4500);

function func_2() {
  $( ".pechat" ).addClass( "expandOpen full-opacity" );
}
setTimeout(func_2, 4000);

Etc.
In what way can you make the sequential execution of functions so that everything works the same in any of the browsers?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-06-07
@0example

use events instead of timeouts.
https://developer.mozilla.org/en-US/docs/Web/Event...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question