Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mounted () {
const self = this
const el = '#' + this.id
const direction = this.direction
// Initialize Swiper
const swiper = new Swiper(el, {
initialSlide: this.direction === 'left' ? 0 : 1,
resistanceRatio: 0,
speed: 150
})
// Event will be fired after transition
swiper.on('transitionEnd', function () {
const activeIndex = this.activeIndex
if ((direction === 'right' && activeIndex === 0) || (direction === 'left' && activeIndex === 1)) {
self.$emit('transitionEnd')
// Destroy slider instance and detach all events listeners
this.destroy()
}
})
}
}
useEffect(() => {
if (containerId) {
swiperRef.current = new OriginalSwiper(`#${containerId}`, swiperOptionsRef.current);
}
}, [containerId, swiperRef, swiperOptionsRef]);