resize: function () {
this.measureSizes();
+ this.updateBackgrounds();
this.updateViewport();
if (this.isMobile()) {
}
},
+ updateBackgrounds: function () {
+ let $this = this;
+ $('[data-bg]').each(function () {
+ var v = $this.isMobile() ? $(this).attr('data-bg-m') : $(this).attr('data-bg-d');
+
+ if ($(this).attr('data-bg') === v) {
+ return;
+ }
+ $this.updateBackground($(this), v);
+ });
+ },
+
+ updateBackground: function (b, v) {
+ let c = '';
+
+ if (v.toLowerCase().indexOf('.json') >= 0) {
+ $(b).html('');
+ this.quiz.animations.load(v, b, undefined, true);
+ } else {
+ $(b).html('<img src="' + v + '" />');
+ }
+ $(b).attr('data-bg', v);
+ },
+
isMobile: function () {
return this.ww <= 600 && this.ratio < 0.7;
},
}
QuizUtils.prototype = {
+
isVisible(e) {
if ($(e).length === 0) {
return false;
return elt.offsetWidth || elt.offsetHeight || elt.getClientRects().length;
},
+
isEnabled: function (e) {
if (!this.isVisible(e)) {
return false;
transition: opacity 200ms
opacity: 1
- background-color: $background-color
-
- @if ($background-custom)
- background-image: url($background-desktop-image)
- background-repeat: $background-desktop-repeat
- background-size: $background-desktop-size
- background-position-x: $background-desktop-position-x
- background-position-y: $background-desktop-position-y
-
- .m &
- background-image: url($background-mobile-image)
- background-repeat: $background-mobile-repeat
- background-size: $background-mobile-size
- background-position-x: $background-mobile-position-x
- background-position-y: $background-mobile-position-y
+ .bg
+ background-color: $background-color
+
+ @if ($background-custom)
+ object-fit: $background-desktop-size
+ object-position: $background-desktop-position-x $background-desktop-position-y
+
+ .m &
+ object-fit: $background-mobile-size
+ object-position: $background-mobile-position-x $background-mobile-position-y
min-width: 1200px
max-width: 1200px
top: 0
left: 0
width: 100%
+
+[data-bg]
+ position: absolute
+ display: block
+ top: 0
+ left: 0
+ width: 100%
+ height: 100%
+ pointer-events: none
--- /dev/null
+@php
+ $d=$data[$name];
+ if(isset($data[$name.'Mobile']) && $data[$name.'Mobile'] && $d!==$data[$name.'Mobile']){
+ $m=$data[$name.'Mobile'];
+ }else{
+ $m=false;
+ }
+@endphp
+<div data-bg="" data-bg-d="{{$d}}" @if($m)data-bg-m="{{$m}}"@endif></div>
@endphp
<div class="container">
<div id="quiz">
+ @include('components.background',['data'=>$data,'name'=>'mainBackground'])
@include('screens.intro', ['data'=> $data])
@foreach($data->questions as $key => $question)
@include('screens.question_'.$question['type'], ['theme' => $data->theme,'data'=> $data, 'question' => $question, 'max' => $totalQuestion, 'position' => $key, 'alphabet' => $alphabet])