]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6295 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Sep 2023 11:37:40 +0000 (13:37 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Sep 2023 11:37:40 +0000 (13:37 +0200)
js/quiz.resize.js
js/quiz.screen.intro.js
js/quiz.screens.js
style/100-global.sass
style/102-intro.sass
style/106-question-draganddrop.sass
views/header_question.blade.php
views/screens/intro.blade.php
views/screens/question_draganddrop.blade.php

index 04b1fdbfb87310f9580c96c44e98a453b858063d..c83ce650b6bb22de5b14528d22e97740f794fca4 100644 (file)
@@ -6,6 +6,9 @@ QuizResize.prototype = {
     resize: function () {
         this.ww = $(window).width();
         this.hh = $(window).height();
+        this.ratio = this.ww / this.hh;
+
+        this.updateViewport();
 
         if (this.isMobile()) {
             $('html').addClass('m');
@@ -21,24 +24,51 @@ QuizResize.prototype = {
         this.quiz.screens.intro.resize(this.ww, this.hh);
         //
         if (this.isMobile()) {
-            $(".btn.reset .text").html(iconReset)
+            $(".btn.reset .text").html(iconReset);
+            this.centerItems();
         } else {
-            $(".btn.reset .text").html(textReset)
+            $(".btn.reset .text").html(textReset);
+            this.resetCenterItems();
         }
+    },
+
+    centerItems: function () {
+        const $this = this;
+        $('.vertical-center-screen').each(function () {
+            if (!$this.quiz.utils.isVisible(this)) {
+                return;
+            }
+            let h = $(this).outerHeight();
+            $(this).css('top', ($this.hh - h) / 2);
+        });
+
+        $('.vertical-center-screen-relative').each(function () {
+            if (!$this.quiz.utils.isVisible(this)) {
+                return;
+            }
 
+            $(this).css('top', '');
+            let rect = $(this).get(0).getBoundingClientRect();
 
+            let h = $(this).outerHeight();
+            $(this).css('top', (($this.hh - h) / 2) - rect.y);
+        });
+    },
+
+    resetCenterItems: function () {
+        $('.vertical-center-screen,.vertical-center-screen-relative').css('top', '');
     },
 
     updateViewport: function () {
-        if (this.isMobile()) {
-            $('meta[name="viewport"]').attr('content', 'width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no');
+        if (!this.isMobile()) {
+            $('meta[name="viewport"]').attr('content', 'width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, test=yes');
         } else {
-            $('meta[name="viewport"]').attr('content', 'width=390, user-scalable=no, initial-scale=1.0, shrink-to-fit=no');
+            $('meta[name="viewport"]').attr('content', 'width=390, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, test=yes');
         }
     },
 
     isMobile: function () {
-        return this.ww <= 390;
+        return this.ww <= 600 && this.ratio < 0.7;
     },
 
 }
index b38c03e219717759abcc35c3c15a715f610e1e6b..92961bfa69b7b83c34887315a39c4f9ada137715 100644 (file)
@@ -23,27 +23,27 @@ QuizScreenIntro.prototype = {
         let title = new SplitType("#welcome h2", {types: 'words, chars'})
         let text = new SplitType("#welcome p", {types: 'words, chars'})
         gsap.timeline({delay: .4})
-        .to(".active-screen .title-header", {
-            y: 0
-        })
-        .to("#start", {
-            y: 0,
+            .to(".active-screen .title-header", {
+                y: 0
+            })
+            .to("#start", {
+                y: 0,
 
-        },.2)
-        .from(title.words, {
-            opacity: 0, y: 20, duration: .2, stagger: 0.05
-        },.5)
-        .to(text.words, {
-            opacity: 1, y: 0, duration: .8, ease: "power4.easeInOut", stagger: {
-                amount: 0.2
-            }
-        },.7)
+            }, .2)
+            .from(title.words, {
+                opacity: 0, y: 20, duration: .2, stagger: 0.05
+            }, .5)
+            .to(text.words, {
+                opacity: 1, y: 0, duration: .8, ease: "power4.easeInOut", stagger: {
+                    amount: 0.2
+                }
+            }, .7)
     },
 
     resize: function (ww, hh) {
-        let intro_text_mobile = this.quiz.data.intro_text_mobile
-        let intro_text = this.quiz.data.intro_text
-        if (ww <= 390) {
+        let intro_text_mobile = this.quiz.data.intro_text_mobile || this.quiz.data.intro_text;
+        let intro_text = this.quiz.data.intro_text;
+        if (this.quiz.resize.isMobile()) {
             $("#welcome p").html(this.quiz.utils.nl2br(intro_text_mobile))
         } else {
             $("#welcome p").html(this.quiz.utils.nl2br(intro_text))
index d5372a1f83ec83fb4de2e41dc739ee6520aea094..513e927c7d38feaa69a5930538e6913f47035de3 100644 (file)
@@ -57,7 +57,9 @@ QuizScreens.prototype = {
                 $this.nextQuestion();
             }
         });
-    }, instantReview: function (review) {
+    },
+
+    instantReview: function (review) {
         this.quiz.progressbar.update();
         this.quiz.animations.instantReviewAnimation(review.ok === 'ok' ? 'OK' : 'NOK');
 
@@ -122,7 +124,9 @@ QuizScreens.prototype = {
         const $this = this;
         let screenToShow = $('[data-screen="' + screen + '"]');
         this.hideCurrentScreen(function () {
-            $this.resetCountdownBackground()
+
+
+            $this.resetCountdownBackground();
             screenToShow.removeClass("none").addClass("next active-screen");
             if (callback !== undefined) {
                 callback();
@@ -137,7 +141,6 @@ QuizScreens.prototype = {
             $this.animateContent(screenToShow);
 
 
-
             // Reset form to prevent browser letting a option selected after a refresh
             $this.resetForm();
             $this.currentQuestionAnswers = [];
@@ -147,7 +150,7 @@ QuizScreens.prototype = {
             if (screen === 'outro') {
                 $this.outro.show();
             }
-
+            $this.quiz.resize.resize();
         });
     },
 
index e51fc234a1cd3d079ac43cc0b9e620be3590dc91..55f213e5508dc88a865b69d49d1b6f7832228dbe 100644 (file)
@@ -13,9 +13,13 @@ body
     min-height: 100vh
 
 #quiz
-    width: 100%
+
+    min-width: 1200px
     max-width: 1200px
+
     min-height: 680px
+    max-height: 680px
+
     margin: 0 auto
     +padding-container()
     position: relative
@@ -25,7 +29,13 @@ body
 
     .m &
         border-radius: 0
-        box-shadow: 0
+        box-shadow: 0 0 0
+        height: 100vh
+        max-height: 100vh
+        min-height: 100vh
+        width: 390px
+        min-width: 390px
+        max-width: 390px
 
 
 .btn
@@ -212,3 +222,6 @@ body
 
     .only-mobile
         display: inherit
+
+    .vertical-center-screen-relative
+        position: relative
index cac7809b854a81d1da84e9912a7e255c1dbf9dff..7719dfb3ae6f2bd07f4094541af0ad13a6f816ee 100644 (file)
@@ -6,6 +6,7 @@
     max-width: 590px
     margin: 0 auto
     top: 160px
+
     h2
         margin: 0 0 12px
         +font-size(20)
         +font-size(16)
         clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%)
         white-space: pre-wrap
+
         .word
             opacity: 0
             transform: translateY(100px)
 
 .m
     #welcome
-        top: 138px
+        position: absolute
+
     #start
         left: 50%
index 0dcdb15d021edb478fc0539e61d6dedd540add32..793390c8e499ee99810fc2dbd6bb32aee048cca6 100644 (file)
@@ -18,6 +18,9 @@
                 position: absolute
                 right: 0
 
+                .m &
+                    height: 252px
+
             .zone-content
                 right: 24px
 
@@ -43,6 +46,9 @@
                 min-height: 196px
                 padding: 8px
 
+                .m &
+                    display: none
+
             .text
                 margin-bottom: 21px
 
                 height: auto
 
                 .zone-content
-                    top: 29px
+                    top: 0
 
             &.zone-2
-                height: auto
+                height: 210px
                 top: initial
                 bottom: -3px
                 left: 0
index a9f2cb9a86286b3cacda7eba8e9bbf5cbb4316e1..9303f0b6ace858abfec78bfd158f026450460304 100644 (file)
@@ -12,8 +12,7 @@
             <span class="only-desktop">{{$__('Drag and drop each card in the right container')}}</span>
             <span class="only-mobile">{{$__('Swipe up or down each card in the right container')}}</span>
         </h1>
-        <h2 class="subtitle"
-            class="only-desktop">{{$__('Use arrow keys to move the cards to the corresponding zone')}}</h2>
+        <h2 class="subtitle only-desktop">{{$__('Use arrow keys to move the cards to the corresponding zone')}}</h2>
     @elseif($question['type']==='match')
         <h1 id="titleQuestion">
             {{$__('Answer the question by swiping left or right to select the most appropriate answer')}}
index 383037aa00dca80f0cb0a662746c0820bbd9fb7b..543416baf2b86d668535466369dd5d20178564e6 100644 (file)
@@ -3,7 +3,7 @@
 @endphp
 <div class="container-screen none" data-type="intro" data-screen="welcome">
     @include('header_title', ['data', $data])
-    <div class="screen" id="welcome">
+    <div class="screen vertical-center-screen" id="welcome">
         <h2>{{$data->intro_title?:$__('Welcome')}}</h2>
         <p>{{$data->intro_text}}</p>
     </div>
index 2dfa6218a9633a0db1dd6f314c781c4fc120c3f4..3f2db1d931186870e2819997aea98d56cb6fdb5d 100644 (file)
@@ -1,18 +1,20 @@
 <div class="container-screen none question-draganddrop" data-type="draganddrop" data-screen="q-{{$position}}">
     @include('screens.question_draganddrop_area',['area'=>1,'question'=>$question,'theme'=>$theme])
     @include('header_question', ['question' => $question, 'data' => $data, 'max' => $max, 'position' => $position])
-    <div class="screen question-draganddrop">
-        @include('screens.arrow',['side'=>'left'])
-        <ul class="list">
-            @foreach($question['answers'] as $key => $answer)
-                <li class="list-item {{ $key === 0 ? 'current' : '' }}" data-id="{{$key}}">
-                    <h4>{{$answer['answer']}}</h4>
-                    <p>{{$answer['answer_text']}}</p>
-                </li>
-            @endforeach
-            <li class="overlay"></li>
-        </ul>
-        @include('screens.arrow',['side'=>'right'])
+    <div class="vertical-center-screen-relative">
+        <div class="screen question-draganddrop">
+            @include('screens.arrow',['side'=>'left'])
+            <ul class="list">
+                @foreach($question['answers'] as $key => $answer)
+                    <li class="list-item {{ $key === 0 ? 'current' : '' }}" data-id="{{$key}}">
+                        <h4>{{$answer['answer']}}</h4>
+                        <p>{{$answer['answer_text']}}</p>
+                    </li>
+                @endforeach
+                <li class="overlay"></li>
+            </ul>
+            @include('screens.arrow',['side'=>'right'])
+        </div>
     </div>
     @include('screens.question_draganddrop_area',['area'=>2,'question'=>$question,'theme'=>$theme])
     @include('footer', ['question' => $question,'data' => $data, 'reset' => true, 'text' => $__('Validate answer'), 'info' => true])