import gsap from "gsap";
import Swiper from 'swiper';
-import { Navigation, Pagination } from 'swiper/modules';
+import { Navigation, Pagination, Manipulation } from 'swiper/modules';
import 'swiper/css/navigation';
import 'swiper/css/pagination';
function QuizMatch(quiz) {
this.quiz = quiz;
- this.start()
+ this.init()
}
QuizMatch.prototype = {
- start: function() {
+ init: function() {
const $this = this
- this.rules = [{top: "10", opacity: ".48"},{top: "39", opacity: ".24"}]
- this.quiz.screens.currentQuestionAnswers = [];
-
$(document).on("click", ".move-slide", function () {
let move = $(this).attr("aria-keyshortcuts")
$(document).on("click", ".confirmMatch", function() {
$this.confirmTheMatch()
})
+ },
+
+ start: function() {
+ const $this = this
+ this.swiperBottom = false
+ this.rules = [{top: "10", opacity: ".48"},{top: "39", opacity: ".24"}]
+ this.quiz.screens.currentQuestionAnswers = [];
+ this.swiperBottomEl = this.quiz.screens.getActiveScreen().find(".bottom-slider")
+ this.sliderBottomHtml = this.swiperBottomEl.html()
+
+ console.log("screen",)
this.swiperTop = new Swiper('.swiper-container.top-slider', {
modules: [Navigation, Pagination],
},
})
+ this.initSwiperBottom()
+
+ },
+
+ initSwiperBottom: function() {
+ const $this = this
+ if(this.swiperBottom)
+ this.swiperBottom.destroy()
+
this.swiperBottom = new Swiper('.swiper-container.bottom-slider', {
- modules: [Navigation, Pagination],
+ modules: [Navigation, Pagination, Manipulation],
slidesPerView: "auto",
//loop: true,
- watchSlidesProgress: true,
centeredSlides: true,
- freeMode: true,
spaceBetween: 20,
pagination: {
el: '.swiper-pagination-bottom',
}
}
})
-
},
setRotation: function(swiper) {
confirmTheMatch: function() {
let lastIndex = this.swiperTop.slides.length - 1
- let answer = this.swiperBottom.activeIndex
- this.quiz.screens.currentQuestionAnswers.push(answer)
+ let index = this.swiperBottom.activeIndex
+ this.quiz.screens.currentQuestionAnswers.push(index)
+ this.swiperBottom.removeSlide(index)
+ this.swiperBottom.update()
if(this.swiperTop.activeIndex === lastIndex) {
this.switchMatchValidateButton()
text = this.quiz.l10n.__('Validate answer');
btn.removeClass("confirmMatch").addClass("action validate").find('.text').text(text)
+ },
+
+ reset: function () {
+ this.quiz.screens.currentQuestionAnswers = []
+ this.swiperTop.slideTo(0)
+ this.swiperBottomEl.html(this.sliderBottomHtml)
+ this.initSwiperBottom()
+ this.quiz.screens.toggleScreen(1, 'all');
}
}