簡體   English   中英

Divi Wordpress主題 - 更改幻燈片轉換速度

[英]Divi Wordpress Theme - Change Slide transition speed

我在我正在為客戶建立的網站上使用Divi,在主頁上我有一個預加載器設置,可以在網站顯示之前在后台加載頁面和圖像。 唯一的問題是,Divi全寬滑塊中的第一張幻燈片在頁面加載的同時開始,因此當預加載器完成並淡出屏幕時,第一張幻燈片會更快地更改為第二張幻燈片。

我問過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;

如何調整它以使第一張幻燈片的滑動速度與其他幻燈片不同?

不確定你正在使用哪個版本的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() );
  }
}

希望有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM