2015-10-20 107 views
0

在WordPress內部使用scrollReveal.js,通過CDN排隊。保留零控制檯錯誤,但data-sr值不會爲前端設置動畫。在Chrome的檢查控制檯中鍵入scrollReveal表示正在初始化,但不會分析動畫效果。ScrollReveal.js v2.3.2加載,沒有控制檯錯誤,但沒有動畫

app.js:

$ = jQuery.noConflict(true); 

(function($) { 
    // init scroll-reveal 
    var config = { 
     easing: 'hustle', 
     reset: true, 
     delay: 'onload', 
     vFactor: 0.90 
    } 
    window.sr = new scrollReveal(config); 
})(jQuery); 

Chrome的控制檯:

scrollReveal輸入:

function e(e){this.docElem=t.document.documentElement,this.options=this.extend(this.defaults,e),this.styleBank=[],1==this.options.init&&this.init()} 

大,它的初始化,但是當我追加必要的data-sr,或者它的鍵值,到前端HTML它報告沒有錯誤,但沒有動畫。

排隊:

wp_enqueue_script('foundation', 'https://cdn.jsdelivr.net/g/[email protected](js/foundation.min.js+js/vendor/jquery.js+js/vendor/modernizr.js),[email protected]', array(), '', true); 

初始化:

add_action('init', 'source_enqueue' , 999); 

HTML:

<div role="front" data-sr> 
    <main> 
     <article> 
      <?php 
       if (have_posts()) : 
        while (have_posts()) : the_post(); 
         the_content(); 
        endwhile; 
        else: 
       endif; 
      ?> 
     </article> 
    </main> 
</div> 

難道是因爲我使用init?錯誤的jQuery?我已經得到零控制檯錯誤,並且確實輸了。我究竟做錯了什麼?

+0

您是否嘗試過加入'jquery'在'wp_enqueue_script()'的依賴? – rnevius

+0

Nope,nadda。它使用特定版本的jquery嗎?我無法找到相關文件。 –

回答

0

原來,jsdelivr CDN軟件包已過時,不僅在該CDN上,而且在所有CDN網站上。 CDN隊列 0.1.2,而包裹使用 2.1,所以請使用 bower並通過這些媒介排隊。

CDN已更新!以下wp_enqueue_script正常工作,以及noConflict() JS文件和init。感謝scrollReveal.js的主人幫助解決CDN錯誤!

排隊

wp_enqueue_script('scroll-reveal', 'https://cdn.jsdelivr.net/scrollreveal.js/2.3.2/scrollReveal.min.js', array(), '', true); 

App.js

$ = jQuery.noConflict(true); 

(function($) { 

    // init scroll-reveal 
    window.sr = new scrollReveal(); 

})(jQuery); 
+0

我更新了jsDelivr上的scrollreveal並啓用了自動更新功能。http://www.jsdelivr.com/projects/scrollreveal.js – Jim

+1

哦,我的天啊!謝謝!我可以看到版本不同。你昨天什麼時候照顧這件事的?讓我做一些測試! –

+1

@jim工作得很好! –

相關問題