How to remove alert from "Uncaught RangeError: Maximum call stack size exceeded"

3

I have a .js file on my site where I put some effects and everything. The problem is that you are acknowledging an Uncaught RangeError: Maximum call stack size exceeded alert and I do not know what it is.

Is it a code error? Because all commands and effects are executed normally.

My jQuery is this:

jQuery(document).ready(function(){

    //======================================================
    // Ajuste automático da altura do background do header
    var header = jQuery('#header'),
        bg = jQuery('#bg'),
        altura_janela = jQuery(window).height(),
        altura_final = altura_janela - 125;

        bg.css({ 'height': altura_final+'px' });


    //======================================================
    // Menu fixo
    var headerBottom = 200;
    jQuery(window).scroll(function() {
            var scrollTop = jQuery(window).scrollTop(), menufixo = jQuery("#menu-fixo");
            if (scrollTop > headerBottom) {
                if (menufixo.is(":visible") == false) {
                    menufixo.fadeIn(300);
                }
            } else {
                if (menufixo.is(":visible")) {
                    menufixo.fadeOut(300);
                }
            }
    });


    //======================================================
    // Botão voltar ao topo
    jQuery(window).scroll(function(){
        var scrollTop2 = jQuery(window).scrollTop(), backtop = jQuery("#back-top");
        if (scrollTop2 > 500) {
             if (backtop.is(":visible") == false) {
                  backtop.fadeIn(200);
             }
        } else {
             if (backtop.is(":visible")) {
                  backtop.fadeOut(100);
             }
        }
    });


    //======================================================
    // Efeito âncoras
    jQuery('a[href^="#"]').on('click',function(e){
        e.preventDefault();

    var target = this.hash;

    if (target == '') { e.preventDefault(); }
    else if (target == '#topo') { 
        jQuery('html, body').stop().animate({ 'scrollTop': 0 }, 900, 'swing');
    }
    else if (target == "#maisconteudo") {
        jQuery('html, body').stop().animate({ 'scrollTop': 700 }, 900, 'swing');
    }
    else {
        var Starget = jQuery(target),
            alturadolink = Starget.offset().top,
            alturaefeito = (alturadolink - 70);

        jQuery('html, body').stop().animate({ 'scrollTop': alturaefeito }, 900, 'swing');
    }

    });


    //======================================================
    // Efeito seta que mexe
    var imgSETABAIXO = jQuery('#seta');
    jQuery(function() {
       function setaShake() {
          if (imgSETABAIXO.css('display') != 'none') {
              imgSETABAIXO.animate({"padding":"30px 0"},600).animate({"padding":"24px 0"},400);
              setTimeout(setaShake(),1500);
          }
       }
       setaShake();
    });


    //======================================================
    // Carousel de notícias
    var carousel = jQuery('#carousel');
    carousel.cycle({
        fx: 'carousel',
        carouselVisible: '3',
        next: '.carousel-next',
        prev: '.carousel-prev',
        slides: '> .carousel-post',
        timeout: '20000',
        pager: '.carousel-pager',
        pagerTemplate: '<a href="#">A</a>'
    });

});

I believe the problem is in this effect: ( see online )

//======================================================
// Efeito seta que mexe
var imgSETABAIXO = jQuery('#seta');
jQuery(function() {
   function setaShake() {
      if (imgSETABAIXO.css('display') != 'none') {
          imgSETABAIXO.animate({"padding":"30px 0"},600).animate({"padding":"24px 0"},400);
          setTimeout(setaShake(),1500);
      }
   }
   setaShake();
});

It is an effect that causes an arrow to move up and down, infinitely.

What can it be? Thank you.

    
asked by anonymous 09.04.2015 / 15:56

1 answer

2

I removed the% w / o that was causing the problem and added setInterval for the movement to keep repeating itself and looked like this:

//======================================================
// Efeito seta que mexe
var imgSETABAIXO = $('#seta');
$(function() {

   function setaShake() {
      if (imgSETABAIXO.css('display') != 'none') {
          imgSETABAIXO.animate({"padding":"30px 0"},600).animate({"padding":"24px 0"},400);         
      }  
   }
   setaShake();
   setInterval(setaShake,1100);     
});

jQuery considers setTimeout as a face that will only do a certain process once, because it was exceeding the expected limit and when you tried to reference the method again you called it, parenteses that would work also, would look like this:

//======================================================

    // Efeito seta que mexe
    var imgSETABAIXO = $('#seta');
    $(function() {
       function setaShake() {
          if (imgSETABAIXO.css('display') != 'none') {
              imgSETABAIXO.animate({"padding":"30px 0"},600).animate({"padding":"24px 0"},400);
              setTimeout(setaShake,1500);
          }
       }
       setaShake();
    });

Source: link

    
09.04.2015 / 16:43