Destroy a Scene in ScrollMagic when Enquire.js Unmatches

330 views Asked by At

What would be the proper code to destroy a Scene when Enquire.js unmatches? I've been going through ScrollMagic.js documentation without much luck:http://scrollmagic.io/examples/expert/removing_and_destroying.html

   var $headerMobile = new ScrollMagic.Scene({
                  triggerElement: "#main-header-mobile", // point of execution
                  duration: 0,
                  triggerHook: 0, // don't trigger until #pinned-trigger1 hits the top of the viewport
                  reverse: true // allows the effect to trigger when scrolled in the reverse direction
                })

    enquire.register("screen and (max-width: 479px)", {
            match : function() {
                $headerMobile.setPin("#main-header-mobile") // the element we want to pin
                .addIndicators()
                .loglevel(3)
                .addTo(controller);
            },
            unmatch : function() {
                $headerMobile.destroy(true);
            }
    });

In console, on Unmatch I get:

Uncaught TypeError: a.destroy is not a function

0

There are 0 answers