swiper: Uncaught TypeError: Controller.LinearSpline is not a constructor
This is a (multiple allowed):
-
bug
-
enhancement
-
feature-discussion (RFC)
-
Swiper Version: 4.0.0
-
Platform/Target and Browser Versions: Any
What you did
A simple thumbs-gallery
this.image = new Swiper(this.el.querySelector('.js-carousel-image'), {
effect: 'slide',
speed: 300,
loop: false,
});
this.type = new Swiper(this.el.querySelector('.js-carousel-type'), {
effect: 'slide',
speed: 300,
loop: false,
navigation: {
nextEl: this.controls.next,
prevEl: this.controls.prev,
},
});
this.image.controller.control = this.type;
this.type.controller.control = this.image;
Expected Behavior
Both swipers to be able to control the sliding of each other
Actual Behavior
Error thrown on Google Chrome Debugger
Uncaught TypeError: Controller.LinearSpline is not a constructor
at Swiper$1.getInterpolateFunction (webpack-internal:///23:5029:9)
at setControlledTranslate (webpack-internal:///23:5044:27)
at Swiper$1.setTranslate (webpack-internal:///23:5071:7)
at Swiper$1.setTranslate (webpack-internal:///23:5150:25)
at self.eventsListeners.(anonymous function).forEach (webpack-internal:///23:300:24)
at Array.forEach (<anonymous>)
at eventsArray.forEach (webpack-internal:///23:299:37)
at Array.forEach (<anonymous>)
at Swiper$1.emit (webpack-internal:///23:297:17)
at Swiper$1.setTranslate (webpack-internal:///23:940:10)
Not sure if this is a webpack issue or there needs to be some configuration with alias
.
Any suggestions welcomed!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 17 (5 by maintainers)
Commits related to this issue
- Fixes "Controller.LinearSpline is not a constructor" error Fixes #2239 — committed to nolimits4web/swiper by nolimits4web 7 years ago
- Fixes "Controller.LinearSpline is not a constructor" error Fixes #2239 — committed to moyus/swiper-lite by nolimits4web 7 years ago
As a workaround you can use UMD build (works with webpack)
import Swiper from 'swiper/dist/js/swiper.js
@Uriziel01 thanks, i’ve fixed it, fix will arrive in next release. But anyway, it is still recommended to run Babel/Buble over swiper
esm
packages. In this case you won’t have this errorimport Swiper from 'swiper/dist/js/swiper.js
it works,thank you @nolimits4web