/**
 *
 */
import { Swiper, Navigation, Pagination, Scrollbar } from "swiper/dist/js/swiper.esm.js";

/**
 *
 */
Swiper.use([Navigation, Pagination, Scrollbar]);

/**
 *
 */
export default class msMiniGallery {
	constructor(selector, options) {
		this.carousel = null;

		const widthChange = e => {
			if (e.matches) {
				/* < 640 */
				if (!this.carousel) {
					this.carousel = new Swiper(selector, options);
				}
			} else {
				/* > 640 */
				if (this.carousel) {
					this.carousel.destroy();
				}
			}
		};

		const mq = window.matchMedia("(max-width: 640px)");
		mq.addListener(widthChange);
		widthChange(mq);
	}
}
