Divi Wordpress主题 - 更改幻灯片转换速度

时间:2017-01-19 19:51:40

标签: javascript jquery html css wordpress

我在我正在为客户构建的网站上使用Divi,在主页上我有一个预加载器设置,可以在网站显示之前在后台加载页面和图像。唯一的问题是,Divi全宽滑块中的第一张幻灯片在页面加载的同时开始,因此当预加载器完成并淡出屏幕时,第一张幻灯片会更快地更改为第二张幻灯片。 / p>

我问过ElegantThemes,他们说我的请求超出了支持范围。我甚至不知道从哪里开始调整任何东西,只有FIRST幻灯片的时间比其他幻灯片长。

所以,我想我的问题是,如何更改Divi全宽滑块上第一张幻灯片的转换时间?

这是链接:: http://mfinangaphoto.wpengine.com

我想我已找到确定幻灯片自动动画速度的代码,在/wp-content/themes/Divi/includes/builder/main-modules.php下:

$fullwidth = 'et_pb_fullwidth_slider' === $function_name ? 'on' : 'off';

    $class  = '';
    $class .= 'off' === $fullwidth ? ' et_pb_slider_fullwidth_off' : '';
    $class .= 'off' === $show_arrows ? ' et_pb_slider_no_arrows' : '';
    $class .= 'off' === $show_pagination ? ' et_pb_slider_no_pagination' : '';
    $class .= 'on' === $parallax ? ' et_pb_slider_parallax' : '';
    $class .= 'on' === $auto ? ' et_slider_auto et_slider_speed_' . esc_attr( $auto_speed ) : '';
    $class .= 'on' === $auto_ignore_hover ? ' et_slider_auto_ignore_hover' : '';
    $class .= 'on' === $remove_inner_shadow ? ' et_pb_slider_no_shadow' : '';
    $class .= 'on' === $show_image_video_mobile ? ' et_pb_slider_show_image' : '';

    $output = sprintf(
        '<div%4$s class="et_pb_module et_pb_slider%1$s%3$s%5$s">
            <div class="et_pb_slides">
                %2$s
            </div> <!-- .et_pb_slides -->
        </div> <!-- .et_pb_slider -->
        ',
        $class,
        $content,
        ( $et_pb_slider_has_video ? ' et_pb_preload' : '' ),
        ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
        ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
    );

return $output;

如何调整此选项以使第一张幻灯片的幻灯片速度与其他幻灯片不同?

1 个答案:

答案 0 :(得分:7)

不确定您使用的Divi版本,但在我的版本(Divi 1.9.1)中,有一个名为js/custom.js的文件负责运行幻灯片。

在119 - 125行附近,你会发现这个功能:

function et_slider_auto_rotate(){
    if ( settings.slideshow && et_slides_number > 1 && ! $et_slider.hasClass( 'et_slider_hovered' ) ) {
        et_slider_timer = setTimeout( function() {
            $et_slider.et_slider_move_to( 'next' );
        }, settings.slideshow_speed );
    }
}

settings.slideshow_speed变量控制每张幻灯片显示的时间。您可以调整此文件,如下所示。请注意,以下是即时伪代码,未经过测试。它被评论,所以你可以跟随。我的例子只会处理你旋转木马的第一张幻灯片。因此,当第一张幻灯片重复播放时,除非你做更多的黑客攻击,否则你将被卡在与其他幻灯片相同的时间控件上。

// somewhere inside the same function block closure in js/custom.js

// first, create some arbitrary variable to manage whether or not we've started
var hasCarouselStarted

// create our own custom function to get the interval between slides
function getMyInterval () {
  // our carousel has already started, so, return the default interval
  if (hasCarouselStarted) {
    return settings.slideshow_speed
  }
  // we got here, so this is the first time the carousel is start, 
  // mark the flag as true so we won't get here anymore
  hasCarouselStarted = true
  // return time in milliseconds for the first slide. 
  return 1 * 60 * 1000    // 1 min * 60 seconds & 1000 milliseconds
}

function et_slider_auto_rotate(){
  if ( settings.slideshow && et_slides_number > 1 && ! $et_slider.hasClass( 'et_slider_hovered' ) ) {
    et_slider_timer = setTimeout( function() {
      $et_slider.et_slider_move_to( 'next' );
    // use our function to determine slide speed instead of the original settings.slideshow_speed
    }, getMyInterval() );
  }
}

希望有所帮助。

相关问题