2

遇到滚动魔术“部分擦除(自然)”激活的问题。我在我的 wordpress 主题中有什么:

函数.php

wp_enqueue_script( 'tweenmax' );
wp_enqueue_script( 'scrollMagic' );
wp_enqueue_script( 'scrollMagicPlugin' );
wp_enqueue_script( 'scrollMagicDebug' );
wp_enqueue_script( 'sceneControls' );

场景控制器是 sceneControls.js 并且包括

场景控件.js

$(function () { // wait for document ready
    // init
    var controller = new ScrollMagic.Controller({
        globalSceneOptions: {
            triggerHook: 'onLeave'
        }
    });

    // get all slides
    var slides = document.querySelectorAll(".section");

    // create scene for every slide
    for (var i=0; i<slides.length; i++) {
        new ScrollMagic.Scene({
                triggerElement: slides[i]
            })
            .setPin(slides[i])
            .addIndicators() // add indicators (requires plugin)
            .addTo(controller);
    }
});

但是,我收到控制台错误,我可能以错误的方式包含了sceneControls.js

控制台读数

Uncaught TypeError: $ is not a function

任何想法,都尝试了几种变化:

 wp_enqueue_script( 'sceneControls' );

非常感谢您的帮助!先感谢您!

对此进行了修订。将函数更改为 noConflict 后的 Rnevius。控制台不再显示错误,但行为不存在。

4

1 回答 1

0

Per last comment

var $ =jQuery.noConflict(); just before calling

$(document).ready(function () {

于 2015-09-11T05:51:40.777 回答