]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6182 @1:30 question drag and drop
authorsoufiane <soufiane@cubedesigners.com>
Thu, 14 Sep 2023 12:11:49 +0000 (14:11 +0200)
committersoufiane <soufiane@cubedesigners.com>
Thu, 14 Sep 2023 12:11:49 +0000 (14:11 +0200)
js/quiz.animations.js
js/quiz.draganddrop.js
js/quiz.screens.js

index 22bfb527b30d54413ad4df116f69566c5fd83152..c581f1639cf8be45726c6b35ad427ddd3eca3285 100644 (file)
@@ -20,7 +20,6 @@ QuizAnimations.prototype = {
         });
     },
 
-
     // Load the animation "name" in container
     load: function (name, container, replace, loop = false) {
         let json = this.quiz.data.animations[name];
@@ -122,7 +121,7 @@ QuizAnimations.prototype = {
             },
             ease: "power1.inOut",
             stagger: .15,
-            onComplete: function(index, target) {
+            onComplete: function() {
                 $(".active-screen .list-item").addClass("complete")
             }
         }, .7)
index 1235a68ec25ea91ca1acc9dc2ee79f7107da32f1..22c49d283585a4c5a8f5455bd6560ff2044a151f 100644 (file)
@@ -22,8 +22,6 @@ QuizDragAndDrop.prototype = {
     },
 
     start: function() {
-        const $this = this;
-
         this.activeScreen = this.quiz.screens.getActiveScreen()
         this.list = this.activeScreen.find(".list")
         this.listHtml = this.list.html()
@@ -98,10 +96,10 @@ QuizDragAndDrop.prototype = {
                             target.addClass("isValidated")
                         },
                         onComplete: function () {
-                            let html = target.html(),
+                            let text = target.text(),
                                 id = "answer-"+target.data("id")
 
-                            $(zone).find(".slot:not(.active)").eq(0).addClass("active").html(html).attr('data-order',target.data("id"))
+                            $(zone).find(".slot:not(.active)").eq(0).addClass("active").append("<span>"+text+"</span>").attr('data-order',target.data("id"))
                             $this.saveAnswer(zone,id)
                             target.remove()
                         }
@@ -119,7 +117,6 @@ QuizDragAndDrop.prototype = {
                         duration: 0
                     }, "+=0.3")
                 }
-
             },
             onRelease: function() {
                 //
@@ -133,6 +130,11 @@ QuizDragAndDrop.prototype = {
                     })
                 }
 
+                //
+                if($this.activeScreen.find(".list-item:not(.isDragging)").length === 0) {
+                    $this.toggleScreen(0,"none")
+                }
+
                 $(this.target).removeClass("isDragging")
 
                 // reset list rotation
@@ -168,6 +170,13 @@ QuizDragAndDrop.prototype = {
         $(".zone-1,.zone-2").removeClass("active")
     },
 
+    toggleScreen: function(opacity,pointer) {
+        gsap.to(".active-screen .screen", {
+            opacity: opacity,
+            pointerEvents: pointer
+        })
+    },
+
     getZoneOverlap: function(offsetLeft, offsetRight) {
         let zone = false,
             zone1 = ".zone-1",
@@ -211,8 +220,7 @@ QuizDragAndDrop.prototype = {
 
     saveAnswer: function(zone,id) {
         $(zone).find("input[id="+id+"]").prop("checked", true)
-
-        console.log($("input:checked"))
+        this.quiz.screens.updateUserAnswers();
     }
 }
 
index 6fb9bee67583b1d5dd8adf6ecd80ddda4b768c24..7765e980d6109f66ab681ab29640c6c26590d359 100644 (file)
@@ -199,6 +199,7 @@ QuizScreens.prototype = {
         this.getCurrentForm().find("input").prop("checked", false)
         if(!only) {
             if(this.quiz.question.isDragAndDrop()) {
+                this.quiz.draganddrop.toggleScreen(1,"initial")
                 this.quiz.draganddrop.retreiveAnswer()
             }
         }