]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wait #6317
authorsoufiane <soufiane@cubedesigners.com>
Tue, 3 Oct 2023 16:17:32 +0000 (18:17 +0200)
committersoufiane <soufiane@cubedesigners.com>
Tue, 3 Oct 2023 16:17:32 +0000 (18:17 +0200)
js/quiz.draganddrop.js
js/quiz.resize.js

index e71c82cccf7558699a748c154c423fd8ac5eff01..2e3a5a4508d65d3e81d8c3f10d30720a620fd2cf 100644 (file)
@@ -36,11 +36,11 @@ QuizDragAndDrop.prototype = {
         this.item = this.activeScreen.find(".list-item")
         this.zone1 = this.activeScreen.find(".zone-1 .zone-content")
         this.zone2 = this.activeScreen.find(".zone-2 .zone-content")
+
         this.htmlZone1 = this.zone1.html()
         this.htmlZone2 = this.zone2.html()
         this.offsetLeftItemDragged = 0
         this.offsetRightItemDragged = 0
-
         this.initQuestion();
     },
 
@@ -71,6 +71,7 @@ QuizDragAndDrop.prototype = {
                 position: 'absolute',
             }
             if (this.quiz.resize.isMobile()) {
+
                 rules = {
                     scale: 0.8, duration: .3, autoAlpha: 0,
                 }
@@ -233,17 +234,25 @@ QuizDragAndDrop.prototype = {
         return zone
     },
 
-    getSlotInformations: function (zone) {
+    measureSizes: function () {
+        this.ww = $(window).width();
+        this.hh = $(window).height();
+        this.ratio = this.ww / this.hh;
 
+        return this.ratio
+    },
+
+    getSlotInformations: function (zone) {
         let a = this.getAreaElement(zone);
         let freeSlot = $(a).find('.slot:not(.active)').eq(0);
         let freeSlotRect = $(freeSlot).get(0).getBoundingClientRect();
         let listRect = this.list.get(0).getBoundingClientRect();
+        let scale = this.quiz.resize.scale
 
-        let x = (freeSlotRect.left - listRect.left), y = (freeSlotRect.top - listRect.top),
+        let x = (freeSlotRect.x - listRect.x), 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}
+        return {"x": Math.round(x / scale), "y": Math.round(y / scale), "w": w / scale, "h": h / scale, "el": el}
     },
 
     getAreaElement: function (area) {
index 1584e88f1b571e822ebcb5a2d08b02027946de42..625d78246869d89d449d5fb213ccb85300ea2bbe 100644 (file)
@@ -4,6 +4,7 @@ function QuizResize(quiz) {
     this.desktopWidth = 1200;
     this.desktopHeight = 680;
     this.mobileWidth = 390;
+    this.scale = 1;
 
     this.measureSizes();
     this.resizePopup();
@@ -96,6 +97,7 @@ QuizResize.prototype = {
                 let sw = this.ww / this.desktopWidth;
                 let sh = this.hh / this.desktopHeight;
                 s = Math.min(sw, sh);
+                this.scale = s
                 qcss.borderRadius = 0;
             } else {
                 qcss.borderRadius = '';