import gsap from "gsap";
+
const lottie = require("lottie-web");
function QuizAnimations(quiz) {
},
// Load the animation "name" in container
- load: function (name, container, replace, loop = false) {
+ load: function (name, container, replace, loop = false, fit = 'default') {
let json = this.quiz.data.animations[name];
+ let renderSettings = {};
+ if (fit === 'cover') {
+ renderSettings.preserveAspectRatio = 'xMidYMid slice';
+ } else if (fit === 'fill') {
+ renderSettings.preserveAspectRatio = 'none';
+ }
if (json) {
for (const k in replace) {
json = json.replace(new RegExp(k, 'g'), replace[k]);
renderer: 'svg',
loop: loop,
autoplay: true,
+ rendererSettings: renderSettings,
animationData: JSON.parse(json),
});
}
})
},
- setAnimItemMultiple: function(tl) {
+ setAnimItemMultiple: function (tl) {
tl.to(".active-screen .list-item", {
- opacity: 1,
- ease: "power1.inOut",
- stagger: .15
+ opacity: 1, ease: "power1.inOut", stagger: .15
}, .7)
- .to(".active-screen .list-item .content", {
- autoAlpha: 1,
- stagger: .1
- }, "<+=.3")
+ .to(".active-screen .list-item .content", {
+ autoAlpha: 1, stagger: .1
+ }, "<+=.3")
},
- animateDragAndDropCarrousel: function(tl) {
+ animateDragAndDropCarrousel: function (tl) {
$(".active-screen .list-item").removeClass("complete");
tl.to(".active-screen .list-item", {
- opacity: function(index) {
+ opacity: function (index) {
let opacity = 1
- if(index === 1) {
+ if (index === 1) {
opacity = 0.64
- }else if(index === 2) {
+ } else if (index === 2) {
opacity = 0.4
- }else if(index === 3) {
+ } else if (index === 3) {
opacity = 0.16
}
return opacity
- },
- ease: "power1.inOut",
- stagger: .15,
- onComplete: function() {
+ }, ease: "power1.inOut", stagger: .15, onComplete: function () {
$(".active-screen .list-item").addClass("complete")
}
}, .7)
let $this = this;
$('[data-bg]').each(function () {
var v = $this.isMobile() ? $(this).attr('data-bg-m') : $(this).attr('data-bg-d');
+ if (v === undefined || v === null) {
+ v = $(this).attr('data-bg-d');
+ }
if ($(this).attr('data-bg') === v) {
return;
updateBackground: function (b, v) {
let c = '';
+ if (v === undefined) {
+ return;
+ }
if (v.toLowerCase().indexOf('.json') >= 0) {
$(b).html('');
- this.quiz.animations.load(v, b, undefined, true);
+ this.quiz.animations.load(v, b, undefined, true, $(b).attr('data-bg-fit'));
} else {
$(b).html('<img src="' + v + '" />');
}
@endphp
<div class="container">
<div id="quiz">
- @include('components.background',['data'=>$data,'name'=>'mainBackground'])
+ @include('components.background',['data'=>$data,'name'=>'mainBackground','fit'=>'cover'])
@include('screens.intro', ['data'=> $data])
@foreach($data->questions as $key => $question)
@php($coundown_enabled = $question["countdown_enable"])