]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6107 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Sep 2023 18:20:41 +0000 (20:20 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 20 Sep 2023 18:20:41 +0000 (20:20 +0200)
js/quiz.draganddrop.js
js/quiz.js
js/quiz.progressbar.js
js/quiz.resize.js
style/001-global-variables.sass
style/003-reset.sass
style/004-mixins.sass
style/100-global.sass
style/103-question-multiple.sass
style/106-question-draganddrop.sass

index 2e5a2bf2b8e231a2220c891b1814ba865c95a3a7..e71c82cccf7558699a748c154c423fd8ac5eff01 100644 (file)
@@ -38,7 +38,6 @@ QuizDragAndDrop.prototype = {
         this.zone2 = this.activeScreen.find(".zone-2 .zone-content")
         this.htmlZone1 = this.zone1.html()
         this.htmlZone2 = this.zone2.html()
-        this.quiz.screens.currentQuestionAnswers = [];
         this.offsetLeftItemDragged = 0
         this.offsetRightItemDragged = 0
 
@@ -228,11 +227,9 @@ QuizDragAndDrop.prototype = {
                 div.classList.remove("active")
             }
         });
-
         if ($(".zone-content.active").length > 0) {
             zone = $(".zone-content.active").parent().data("zone")
         }
-
         return zone
     },
 
@@ -240,10 +237,11 @@ QuizDragAndDrop.prototype = {
 
         let a = this.getAreaElement(zone);
         let freeSlot = $(a).find('.slot:not(.active)').eq(0);
-        let freeSlotOffset = $(freeSlot).offset();
+        let freeSlotRect = $(freeSlot).get(0).getBoundingClientRect();
+        let listRect = this.list.get(0).getBoundingClientRect();
 
-        let x = (freeSlotOffset.left - this.list.offset().left), y = (freeSlotOffset.top - this.list.offset().top),
-            w = $(a).find(".slot").innerWidth(), h = $(a).find(".slot").innerHeight(), el = $(a).find(".slot")
+        let x = (freeSlotRect.left - listRect.left), y = (freeSlotRect.top - listRect.top),
+            w = freeSlotRect.width, h = freeSlotRect.height, el = $(a).find(".slot")
 
         return {"x": x, "y": y, "w": w, "h": h, "el": el}
     },
@@ -253,6 +251,7 @@ QuizDragAndDrop.prototype = {
     },
 
     initQuestion: function () {
+        this.quiz.screens.currentQuestionAnswers = [];
         //
         const htmlList = this.quiz.draganddrop.listHtml
         const htmlZone1 = this.quiz.draganddrop.htmlZone1
index d36ae0d5c2a1709782401849adc54de679411b8b..00ffaf9dfed9b5fd7c1080c23e9cd9db075be267 100644 (file)
@@ -48,18 +48,12 @@ Quiz.prototype = {
         this.draganddrop = new QuizDraganddrop(this);
         this.match = new QuizMatch(this);
 
-        console.log(this.data);
-        // ICI tout commence vraiment
-        console.log(this.data.theme)
-
-        //
-        $("#quiz").css("background-image", "url(" + this.data.theme.backgroundImage + ")")
-
         // La fonction resize est appelée à chaque fois qu'un resize de la fenêtre survient (et à l'init de l'app)
         $(window).on('resize', function () {
             $this.quizResize();
         });
         this.quizResize();
+        $('#quiz').addClass('ready');
 
         // Afficher l'écran d'introduction et lancer l'animation
         this.screens.intro.show();
index cf19511ecf16a8d340dc929c9318f1f8233eabd2..b61df881853627dd88bc28edc4083241723e6130 100644 (file)
@@ -5,8 +5,7 @@ function QuizProgressbar(quiz) {
 QuizProgressbar.prototype = {
     update: function () {
         let $this = this;
-        const questionStatus = this.quiz.score.questionStatus
-        console.log(questionStatus);
+        const questionStatus = this.quiz.score.questionStatus;
         $('.progress-container').each(function () {
             let $cont = this;
             $.each(questionStatus, function (questionIndex, status) {
index c83ce650b6bb22de5b14528d22e97740f794fca4..89f9d0120032e8b6b90119d2dea15493fc85abe0 100644 (file)
@@ -8,6 +8,10 @@ QuizResize.prototype = {
         this.hh = $(window).height();
         this.ratio = this.ww / this.hh;
 
+        this.desktopWidth = 1200;
+        this.desktopHeight = 680;
+        this.mobileWidth = 390;
+
         this.updateViewport();
 
         if (this.isMobile()) {
@@ -62,8 +66,25 @@ QuizResize.prototype = {
     updateViewport: function () {
         if (!this.isMobile()) {
             $('meta[name="viewport"]').attr('content', 'width=device-width, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, test=yes');
+            let s = 1;
+            let qcss = {};
+            if (this.ww < this.desktopWidth || this.hh < this.desktopHeight) {
+                let sw = this.ww / this.desktopWidth;
+                let sh = this.hh / this.desktopHeight;
+                s = Math.min(sw, sh);
+                qcss.borderRadius = 0;
+            } else {
+                qcss.borderRadius = '';
+            }
+            qcss.transform = 'scale(' + s + ')';
+            qcss.transformOrigin = '0 0 0';
+            qcss.left = (this.ww - (this.desktopWidth * s)) / 2;
+            qcss.top = (this.hh - (this.desktopHeight * s)) / 2;
+            qcss.margin = '';
+            $("#quiz").css(qcss);
         } else {
-            $('meta[name="viewport"]').attr('content', 'width=390, user-scalable=no, initial-scale=1.0, shrink-to-fit=no, test=yes');
+            $('meta[name="viewport"]').attr('content', 'width=' + this.mobileWidth + ', user-scalable=no, initial-scale=1.0, shrink-to-fit=no, test=yes');
+            $("#quiz").css({transform: '', transformOrigin: '', top: '', left: '', margin: '0 auto'});
         }
     },
 
index 65d5730c7df453ddcb4339762ce3ecf7aa5a9538..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-$screenSizeMobile: 391px
index 45897f9ce5102a45570a91fb8e0568c68438a912..7786d0c016931489f02065aa039b03c3808f0915 100644 (file)
@@ -30,6 +30,10 @@ footer, header, hgroup, menu, nav, section, main
     display: block
 
 
+html, body
+    min-height: 100%
+    height: 100%
+
 body
     line-height: 1
 
index bd8e37f9c4a17c68f93696a25683f1aa595152bf..1cb10b761de6482262b184e07d805a52d9b36017 100644 (file)
@@ -8,13 +8,6 @@
         @content
 
 
-@mixin breakpoint($breakpoint, $direction: min)
-    $breakpoint-values: map-get($breakpoints, $breakpoint)
-    $breakpoint: map-get($breakpoint-values, $direction)
-    @media (#{$direction}-width: $breakpoint)
-        @content
-
-
 @mixin opacity($opacity, $rule: background-color, $color: $texts-color)
     #{$rule}: rgba($color,$opacity)
 
@@ -41,9 +34,7 @@
 
 
 @mixin padding-container()
-    padding: 16px
-    +breakpoint(md)
-        padding: 24px
+    padding: 24px
 
 @mixin radius($size)
     border-radius: $size
index 55f213e5508dc88a865b69d49d1b6f7832228dbe..34b362f4a7924aeb7a6278be283feadce1a3c454 100644 (file)
@@ -8,11 +8,29 @@ body
 [data-icon] svg
     height: 20px
 
-.container
-    +flex-config(center, false, false, center)
-    min-height: 100vh
-
 #quiz
+    opacity: 0
+    transition: opacity 200ms
+
+    &.ready
+        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
 
     min-width: 1200px
     max-width: 1200px
@@ -20,7 +38,6 @@ body
     min-height: 680px
     max-height: 680px
 
-    margin: 0 auto
     +padding-container()
     position: relative
     overflow: hidden
index e42c80f271917258cd9479a42f0f6bd2e042511d..273e409e99b080719785e78a3afb4a70efd73f9b 100644 (file)
@@ -5,8 +5,8 @@
     .list
         display: grid
         grid-gap: 16px
-        +breakpoint(md)
-            grid-template-columns: repeat(2, 1fr)
+        grid-template-columns: repeat(2, 1fr)
+
         &-item
             opacity: 0
             label
index 5dff60982976f03239a012db9333a581548012f7..bdeeca6947cc316ffdb6ee1470905276d936e9eb 100644 (file)
             .zone-content
                 right: 24px
 
-        &.zone-1,
-        &.zone-2
-            &.active
-                .card-holder
-                    +opacity(.2, background-color, $texts-color)
 
         .zone-content
             position: absolute
             height: 50%
             padding: 0 8px
 
-            transition: background-color .2s ease
+            &.active
+                .card-holder
+                    +opacity(.2, background-color, $texts-color)
+
 
             .card-holder
+                transition: background-color .2s ease
                 +opacity(.08, background-color, $texts-color)
                 +radius(16px)
                 min-height: 196px