2016-06-21 85 views
0

我試圖將我用jquery獲得的DOM元素傳入setClassToggle(element, class),但我不斷收到此錯誤。我在這裏錯過了什麼?在DOM元素中傳遞給setClassToggle

(ScrollMagic.Scene) - >錯誤調用方法'setClassToggle()': 提供了無效的元素。

jsfiddle

 <div class="grid-item" data-parallax="bouble"> 
     <div class="container quote start" id="first"> 
      <h2>"</h2> 
      <p>Vestibulum vitae congue nibh. Aliquam erat volutpat. Proin pretium mauris a quam molestie porttitor. Nulla vel molestie enim. Aenean suscipit cursus volutpat.</p> 
     </div> 
     </div> 



    var parallaxClass = $(this).data('parallax'); 
    var element = $(this).find('.container'); 

    if (parallaxClass === 'bouble') { 
    new ScrollMagic.Scene({ 
     triggerElement: this, 
     triggerHook: 0.7 
     }) 
     .addIndicators() 
     .setClassToggle(element, parallaxClass) 
     .addTo(controller); 
    } 

回答

1

the ScrollMagic docssetClassToggle接收的element屬性應該是選擇器,而不是實際的元素本身。

element:一個選擇器定位一個或多個元件或一個應該被modified.`

// add multiple classes to multiple elements defined by the selector 
'.classChange' scene.setClassToggle(".classChange", "class1 class2 class3"); 
DOM對象