当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