gpt4 book ai didi

javascript - Slideshow_animate 未定义

转载 作者:行者123 更新时间:2023-11-28 08:56:58 24 4
gpt4 key购买 nike

我正在工作的 js 中遇到以下问题:

Uncaught ReferenceError: slideshow_animate is not defined (anonymous function)

引用它的函数是:

    function slideshow_animate() {
if(!animation.auto_animate) return;

var next_slide = $('.item-slide.active').next();
if(!next_slide.length) {
next_slide = $('#item-slide-1');
}

next_slide.click();
}

我有另一个网站,如果我正在工作,但似乎在这个应用程序中我遇到了 Slideshowa_animate 的问题,附上完整的代码以供引用:

(function ($, Drupal) {

Drupal.behaviors.lek7_zen_theme = {
attach: function(context, settings) {

$(document).ready(function(){


var i = 1;
$('.item-slide').each(function(key, value) {
$(value).attr('id', 'item-slide-'+i);
i++;
});

$('.slide_caption').hide();
$('#item-slide-1 > .slide_caption').show();
$('#item-slide-1').addClass('active');
$('.item-slide').not('.active').children('.slide_image_slice').show();

});


var animation = {
'auto_animate': true,
'auto_animate_delay': 8000,
'auto_animate_id': '',
'caption_speed': 'fast',
//'panel_speed': 'slow',
'panel_speed': 1000,
'panel_easing': 'easeInOutCubic'
}

$('.item-slide')
.bind('open', function(){
if(! $(this).hasClass('open')){
$(this).next().trigger('open');
$(this).addClass('open');
$(this).animate({right: "-=769px"}, animation.panel_speed, animation.panel_easing, function(){display_slices();});
}
else{
$(this).prev().trigger('close');
}
$(this).siblings().removeClass('active');
$(this).addClass('active');
setTimeout(function(){hide_slices()},1);


display_caption();
})
.bind('close', function(){
if($(this).hasClass('open')){
$(this).removeClass('open');
$(this).animate({right: "+=769px"}, animation.panel_speed, animation.panel_easing, function(){display_slices();});
$(this).prev().trigger('close');
}
});

$('.item-slide')
.hoverIntent(
function() {
animation.auto_animate = false;
trigger_accordion($(this));
},
function() {
animation.auto_animate = true;
clearInterval(animation.auto_animate_id);
animation.auto_animate_id = setInterval('slideshow_animate()', animation.auto_animate_delay);
}
)
.click(function() {
trigger_accordion($(this));
});

animation.auto_animate_id = setInterval('slideshow_animate()', animation.auto_animate_delay);


function trigger_accordion(itemSlide) {
if(!(itemSlide.is(':animated'))) {
itemSlide.trigger('open');
}
}

function display_caption() {
$('.slide_caption').each(function() {
if(!($(this).parent().hasClass('active'))) {
$(this).fadeOut('fast', function() {
$('.item-slide.active > .slide_caption').fadeIn(animation.caption_speed);
});
}
});
}

function hide_slices() {
$('.slide_image_slice').each(function() {
if($(this).parent().hasClass('active')) {
$(this).fadeOut('fast');
}
});
}

function display_slices() {
$('.slide_image_slice').each(function() {
if(!$(this).parent().hasClass('active') && !$(this).is(":visible")) {
$(this).fadeIn('fast');
}
});
}

function slideshow_animate() {
if(!animation.auto_animate) return;

var next_slide = $('.item-slide.active').next();
if(!next_slide.length) {
next_slide = $('#item-slide-1');
}

next_slide.click();

}
}
};

})(jQuery, Drupal);

最佳答案

当您使用 animation.auto_animate_id = setInterval('slideshow_animate()',animation.auto_animate_delay); 时,该函数将在函数 slideshow_animate 执行的全局范围内进行计算不存在,因为它在闭包范围内

尝试

animation.auto_animate_id = setInterval(slideshow_animate, animation.auto_animate_delay);

关于javascript - Slideshow_animate 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18348319/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com