1

当 Enquire.js 不匹配时,销毁场景的正确代码是什么?我一直在浏览 ScrollMagic.js 文档,但运气不佳: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);
            }
    });

在控制台中,在 Unmatch 我得到:

Uncaught TypeError: a.destroy is not a function

4

0 回答 0