osrec / SuperSlide.js

A flexible, smooth, GPU accelerated sliding menu for your next PWA
https://osrec.co.uk/products/superslidejs
GNU General Public License v3.0
490 stars 21 forks source link

TypeError: superslide_js__WEBPACK_IMPORTED_MODULE_0___default.a.superslide is not a constructor #1

Closed JacobDB closed 6 years ago

JacobDB commented 6 years ago

This looks awesome, and I'm trying to add it to my personal framework, but I'm running in to an odd issue that I can't seem to track down. I keep getting the error in the title, not sure what I'm doing wrong. I'm using webpack, initializing the script with:

import OSREC from "superslide.js";

const MOBILE_MENU = new OSREC.superslide({
    animation: "slideLeft",
    content:   document.getElementById("page-container"),
    slider:    document.getElementById("mobile-menu"),
});

#page-container and #mobile-menu both exist, and console.log(OSREC) outputs function superslide(), so I don't see what could be the problem. The only difference I'm seeing between my code and your example code is that I'm importing OSREC rather than including the script on the page.

Any help figuring out why this won't work would be appreciated.

JacobDB commented 6 years ago

Figured it out, I'm just new to this whole import thing. I just needed to change import OSREC from "superslide.js"; to import SuperSlide from "superslide.js";, and OSREC.superslide to SuperSlide. Works great now!