+import gsap from "gsap";
import Swiper from 'swiper';
- import { Navigation, Pagination, Manipulation } from 'swiper/modules';
+ import {Navigation, Pagination, Manipulation} from 'swiper/modules';
import 'swiper/css/navigation';
import 'swiper/css/pagination';
})
this.initSwiperBottom()
+
},
- initSwiperBottom: function() {
+ initSwiperBottom: function () {
const $this = this
- if(this.swiperBottom)
- this.swiperBottom.destroy()
+ if (this.swiperBottom) this.swiperBottom.destroy()
- this.swiperBottom = new Swiper('.swiper-container.bottom-slider', {
+ this.swiperBottom = new Swiper(this.swiperBottomEl.get(0), {
modules: [Navigation, Pagination, Manipulation],
slidesPerView: "auto",
+ //loop: true,
centeredSlides: true,
spaceBetween: 20,
+ initialSlide: Math.floor(this.swiperBottomEl.find('.swiper-slide').length / 2),
pagination: {
- el: '.swiper-pagination-bottom',
- type: 'bullets',
+ el: '.swiper-pagination-bottom', type: 'bullets',
},
on: {
- slideChange: function(swiper) {
- $this.setRotation(swiper)
- },
- progress: function(swiper) {
- console.log(swiper)
- $this.setRotation(swiper)
+ slideChange: function (swiper) {
+ $this.setRotation(swiper);
+ }, progress: function (swiper) {
+ $this.setRotation(swiper);
+ }, update: function (swiper) {
+ $this.setRotation(swiper);
},
- update(swiper) {
- console.log(swiper)
- }
}
})
- .to(".active-screen .bottom-slider", {
- opacity: 1
- })
- .to(".active-screen .bottom-slider .swiper-slide", {
- opacity: function(index) {
- let opacity = 1
- if(index === 1) {
- opacity = 0.48
- }else if(index === 2) {
- opacity = 0.24
- }else if(index === 3) {
- opacity = 0
++
+ this.animateContent()
+ },
+
+ animateContent: function() {
+ gsap.timeline({delay: .5}).to(".active-screen .top-slider-container", {
+ opacity: 1
+ })
- return opacity
- },
- ease: "power1.inOut",
- stagger: .15,
- onComplete: function() {
- $(this.target).removeClass("not-visible")
++ .to(".active-screen .bottom-slider", {
++ opacity: 1
++ })
++ .to(".active-screen .bottom-slider .swiper-slide", {
++ opacity: function(index) {
++ let opacity = 1
++ if(index === 1) {
++ opacity = 0.48
++ }else if(index === 2) {
++ opacity = 0.24
++ }else if(index === 3) {
++ opacity = 0
++ }
++ return opacity
++ },
++ ease: "power1.inOut",
++ stagger: .15,
++ onComplete: function() {
++ $(this.target).removeClass("not-visible")
+ }
++ })
+ },
+
+ setRotation: function (swiper) {
+ let activeIndex = Math.max(0, Math.min(Math.round(swiper.progress * swiper.slides.length), swiper.slides.length - 1));
+ for (let i = 0; i < swiper.slides.length; i++) {
+ let position = i - (swiper.progress * (swiper.slides.length - 1));
+ if (Math.round(position) === position) {
+ $(swiper.slides[i]).addClass('move-transitions');
+ } else {
+ $(swiper.slides[i]).removeClass('move-transitions');
}
- })
+ this.slideSetPosition(swiper.slides[i], position);
+ }
},
- setRotation: function(swiper) {
- let activeIndex = swiper.activeIndex
- let nextAllArray = swiper.slides.slice(activeIndex+1)
- let prevAllArray = swiper.slides.slice(0,activeIndex).reverse()
+ slideSetPosition: function (slide, position) {
+ let tops = [0, 12, 41, 88, 120, 160, 200];
+ let abspos = Math.abs(position);
- this.setStyleCard(prevAllArray,"prev")
- this.setStyleCard(nextAllArray,"next")
- },
+ let angle = (position * 4);
+ let opacity = 1 - (abspos * 0.2);
+ let floorpos = Math.floor(abspos)
+ let ceilpos = Math.ceil(abspos);
+ let top = tops[floorpos];
+ top += (abspos - floorpos) * (tops[ceilpos] - tops[floorpos]);
- 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.rules[index] ? $this.rules[index].top+'px' : 0,
- })
- if(!$(el).hasClass("not-visible")) {
- $(el).css({
- 'opacity': $this.rules[index] ? $this.rules[index].opacity : 0
- })
- }
- if(direction === "next") {
- angle += 4
- } else {
- angle -= 4
- }
- })
- }
+ $(slide).css({transform: 'rotate(' + angle + 'deg) translateY(' + top + 'px)', opacity: opacity});
},
- confirmTheMatch: function() {
+ confirmTheMatch: function () {
let lastIndex = this.swiperTop.slides.length - 1
let index = this.swiperBottom.activeIndex
this.quiz.screens.currentQuestionAnswers.push(index)
<div class="score-text">
<h1>{{$__('Congratulation!')}}</h1>
<div class="subtitle">
-- <p class="word">{!! $__('You have completed the quiz with :score correct answers out of :total',['score'=>'<span id="score-text"></span>','total'=>'<span id="maxScore-text"></span>']) !!}</p>
++ <p class="word">{!! $__('You have completed the quiz with :score correct answers out of :total',['score'=>"<span id='score-text'></span>",'total'=>'<span id="maxScore-text"></span>']) !!}</p>
</div>
@if($data->restart_button)
<div class="restart-sentence-mobile">{{$__('Want to improve your score?')}}</div>
@if($data->restart_button)
<div class="restart-sentence">{{$__('Want to improve your score?')}}</div>
@endif
-- <div class="controls">
++ <div class="score-controls">
@if($data->restart_button)
<a class="btn secondary restart" aria-keyshortcuts="r">
{{$__('Restart')}}
@endif
<a class="btn secondary toggle-answers-review">
<span data-icon=""></span>
-- {{$__('Review answers')}}
++ <span>{{$__('Review answers')}}</span>
</a>
<a class="btn primary action">
-- {{$__('Leave')}}
++ <span>{{$__('Leave')}}</span>
<span class="access space">{{$__('space')}}</span>
</a>
</div>
</div>
<div class="score-answers-review_container">
<div class="score-answers-review">
-- <h2>{{$__('Answers review')}}<span class="toggle-answers-review" id="close-answers"
-- data-icon="wrong"></span></h2>
++ <h2>{{$__('Answers review')}}
++ <span class="toggle-answers-review" id="close-answers" data-icon="wrong"></span>
++ </h2>
<p class="subtitle">{{$__('Review your answers before you go')}}</p>
<ul id="answers-list">
@verbatim