foundation / foundation-sites

The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.
https://get.foundation
MIT License
29.66k stars 5.48k forks source link

Foundation 6.4: Drop-in compiled JS files in dist/js -> Uncaught TypeError: Cannot read property 'scrollToLoc' of undefined #10502

Closed pablopaul closed 7 years ago

pablopaul commented 7 years ago

I am using the "drop-in compiled js files" (dist/js) and get the following error when trying to use Magellan:

Uncaught TypeError: Cannot read property 'scrollToLoc' of undefined
    at Magellan.scrollToLoc (foundation.magellan.js:286)
    at HTMLAnchorElement.<anonymous> (foundation.magellan.js:255)
    at HTMLUListElement.dispatch (jquery.js?ver=1.12.4:3)
    at HTMLUListElement.r.handle (jquery.js?ver=1.12.4:3)

foundation.magellan.js:286 and following are:

      __WEBPACK_IMPORTED_MODULE_3__foundation_smoothScroll__["SmoothScroll"].scrollToLoc(loc, options, function () {
        _this._inTransition = false;
        _this._updateActive();
      });

So basically __WEBPACK_IMPORTED_MODULE_3__foundation_smoothScroll__["SmoothScroll"] is undefined.

My config.yml looks like this:

  javascript:
    # Libraries requried by Foundation
    # - "bower_components/jquery/dist/jquery.js"
    - "bower_components/what-input/dist/what-input.js"
    # Core Foundation files
    - "bower_components/foundation-sites/dist/js/plugins/foundation.core.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.util.*.js"
    # Individual Foundation components
    # If you aren't using a component, just remove it from the list
    - "bower_components/foundation-sites/dist/js/plugins/foundation.abide.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.accordion.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.accordionMenu.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.drilldown.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.dropdown.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.dropdownMenu.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.equalizer.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.interchange.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.magellan.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.offcanvas.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.orbit.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.responsiveAccordionTabs.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.responsiveMenu.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.responsiveToggle.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.reveal.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.slider.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.smoothScroll.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.sticky.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.tabs.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.toggler.js"
    - "bower_components/foundation-sites/dist/js/plugins/foundation.tooltip.js"

When I change the config to import the whole foundation.js bundle like this

  javascript:
    # Libraries requried by Foundation
    # - "bower_components/jquery/dist/jquery.js"
    - "bower_components/what-input/dist/what-input.js"
    # Core Foundation files
    - "bower_components/foundation-sites/dist/js/foundation.js"

Magellan is working as expected, what do I miss here?

kball commented 7 years ago

Hmm... @pablopaul can you try moving the line

- "bower_components/foundation-sites/dist/js/plugins/foundation.smoothScroll.js"

Above the magellan line and see if that resolves the issue? If so I think we simply have a documentation issue to address, otherwise I'll keep digging

jurecuhalev commented 7 years ago

I just had this error. foundation.smoothScroll.js has to be included before foundation.magellan.js (but in your listing, it's after)

pablopaul commented 7 years ago

@kball Thanks for hinting us in the right direction, I was able to resolve the issue.

Seems that it was helpful that I raised the issue since @gandalfar directly found this and was able to fix also his case. If you are interested how the "issue" came up, read the issue in the origin repo here.