From 2ab1ef607e47075d5b49ecd7fc092ccdd44582a6 Mon Sep 17 00:00:00 2001 From: soufiane Date: Tue, 3 Oct 2023 18:17:32 +0200 Subject: [PATCH] wait #6317 --- js/quiz.draganddrop.js | 17 +++++++++++++---- js/quiz.resize.js | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/js/quiz.draganddrop.js b/js/quiz.draganddrop.js index e71c82c..2e3a5a4 100644 --- a/js/quiz.draganddrop.js +++ b/js/quiz.draganddrop.js @@ -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) { diff --git a/js/quiz.resize.js b/js/quiz.resize.js index 1584e88..625d782 100644 --- a/js/quiz.resize.js +++ b/js/quiz.resize.js @@ -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 = ''; -- 2.39.5