2

Running into a problem with the scrollmagic 'section wipes (natural)' activation. What I have in my wordpress theme:

functions.php

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

the scene controller is sceneControls.js and includes

sceneControls.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);
    }
});

I am receiving console errors however, I may be including sceneControls.js in a bad manner.

Console Readout

Uncaught TypeError: $ is not a function

Any thoughts, have tried several variations:

 wp_enqueue_script( 'sceneControls' );

Help is greatly appreciated! Thank you in advance!

This was revised. Rnevius after changing the function to a noConflict. The console no longer shows an error but the behaviour is not there.

sandovalg
  • 109
  • 13
  • 1
    Is `$` for jQuery? If so, make sure that you load the script after jQuery. Check the generated HTML source for script tag orders. – FelisCatus Sep 10 '15 at 04:22
  • 1
    possible duplicate of [TypeError: 'undefined' is not a function (evaluating '$(document)')](http://stackoverflow.com/questions/7975093/typeerror-undefined-is-not-a-function-evaluating-document) – rnevius Sep 10 '15 at 04:43
  • This last link solved it rnevius adding in `var $ =jQuery.noConflict();` just before calling `$(document).ready(function () {` – sandovalg Sep 11 '15 at 05:50

1 Answers1

0

Per last comment

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

$(document).ready(function () {

sandovalg
  • 109
  • 13