1

I wrote this animate out script and it works fine on chrome, but does not work on Firefox and I cant figure out why?

Any ideas?

Basically, it checks if a particular link is clicked, if it is it animates certain elements

<script>
jQuery(document).ready(function($) {
    console.log('here i am on ff');
// ---------------------
  var triggers = '.menu-item a, .isotope-item a';
// ---------------------

  $(triggers).on('click', function() { //up & out
    event.preventDefault();


    var href = $(this).attr('href');
    // ------------------ add here
    changePage('.rt-tpg-isotope', '.isotope-item', 'upAndOut', 100, 0);
    changePage('.menu', '.menu-item', 'rightAndOut', 70, 0);
    changePage('.vc_single_image-wrapper', 'img', 'leftAndOut', 100, 500);
    // ---------------------
    setTimeout(function() {window.location = href}, 1000);
  });


function changePage(parentDiv,childDiv,divClass, timingV, delayV){
var time = delayV;
    $(parentDiv).children(childDiv).each(function(index, value) {
      setTimeout(function() {
        $(parentDiv).children().eq(index).addClass(divClass);
      }, time)
      time += timingV;
      /*var $this = $(this);
      var $yourset = $(parentDiv).children(childDiv);
      if ($this[0] === $yourset.last()[0]) {
        console.log('is last');
                changePage();  
      } else {
        console.log('is not last');
      }*/
    });
}

});
</script>
Sony ThePony
  • 315
  • 1
  • 2
  • 13

1 Answers1

1

You should put an event as a parameter of function like this:

$(triggers).on('click', function (event, e) { //up & out
  e.preventDefault();
}
Mario Petrovic
  • 7,500
  • 14
  • 42
  • 62
ThucVu
  • 95
  • 7
  • That worked, missing a comma but : $(triggers).on('click', function(event, e) {event.preventDefault(); (worked) ... do you know why this worked on all browsers except firefox? Also thank you very much – Sony ThePony Jun 25 '17 at 11:48
  • I think that because they are different web browse engine. And each engine has it own way to render the webpage. – ThucVu Jun 25 '17 at 13:50