QuizMatch.prototype = {
start: function() {
const $this = this
- let posInit = 0
- this.positionsX = [{top: "10", opacity: ".48"},{top: "39", opacity: ".24"}]
- this.counter = 0
+ this.rules = [{top: "10", opacity: ".48"},{top: "39", opacity: ".24"}]
this.quiz.screens.currentQuestionAnswers = [];
$(document).on("click", ".move-slide", function () {
slideChange: function(swiper) {
$this.setRotation(swiper)
},
- progress: function(swiper, progress) {
+ progress: function(swiper) {
$this.setRotation(swiper)
}
}
},
setRotation: function(swiper) {
- const $this = this
- const slides = swiper.slides
let activeIndex = swiper.activeIndex
let nextAllArray = swiper.slides.slice(activeIndex+1)
- let prevAllArray = swiper.slides.slice(0,activeIndex)
-
-
- console.log(nextAllArray)
- //console.log(prevAllArray)
- let angle = 4
-
- if(swiper.swipeDirection === "next") {
- angle -= 4
- }
+ let prevAllArray = swiper.slides.slice(0,activeIndex).reverse()
- if(prevAllArray.length > 0) {
- let angle = -4
- prevAllArray.reverse().forEach(function(el,index) {
-
- $(el).css({
- 'transform':'rotate('+(angle)+'deg)',
- 'top': $this.positionsX[index] ? $this.positionsX[index].top+'px' : 0,
- 'opacity': $this.positionsX[index] ? $this.positionsX[index].opacity : 0
- })
- angle -= 4
-
- })
- }
-
- if(nextAllArray.length > 0) {
- let angle = 4
- nextAllArray.forEach(function(el,index) {
+ this.setStyleCard(prevAllArray,"prev")
+ this.setStyleCard(nextAllArray,"next")
+ },
+ setStyleCard: function(array,direction) {
+ const $this = this
+ let angle = direction === "next" ? 4 : -4
+ if(array.length > 0) {
+ array.forEach(function(el,index) {
$(el).css({
'transform':'rotate('+(angle)+'deg)',
- 'top': $this.positionsX[index] ? $this.positionsX[index].top+'px' : 0,
- 'opacity': $this.positionsX[index] ? $this.positionsX[index].opacity : 0
+ 'top': $this.rules[index] ? $this.rules[index].top+'px' : 0,
+ 'opacity': $this.rules[index] ? $this.rules[index].opacity : 0
})
- angle += 4
-
+ if(direction === "next") {
+ angle += 4
+ } else {
+ angle -= 4
+ }
})
}
},