]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wait #6812
authorsoufiane <soufiane@cubedesigners.com>
Tue, 14 May 2024 16:33:39 +0000 (18:33 +0200)
committersoufiane <soufiane@cubedesigners.com>
Tue, 14 May 2024 16:33:39 +0000 (18:33 +0200)
js/quiz.draganddrop.js

index 511fb0bfef90301f625599b03da31c3155307c50..5f9b80c3c740cf03548c823b80299f1fc147f3d5 100644 (file)
@@ -118,81 +118,84 @@ QuizDragAndDrop.prototype = {
     },
 
     createDraggable: function ($this) {
-        Draggable.create($this.item, {
-            type: $this.quiz.resize.isMobile() ? "y" : "x,y",
-            edgeResistance: 0.2,
-            inertia: false,
-            bounds: "#quiz",
-            onDragParams: [{}],
-            onDrag: function () {
-                $(".zone-1,.zone-2").removeClass("notDrag")
-                $(this.target).addClass("isDragging").removeClass("isNext")
-
-                $this.offsetLeftItemDragged = $(this.target).offset().left
-                $this.offsetRightItemDragged = $(this.target).offset().left + $(this.target).outerWidth()
-                let direction = this.getDirection()
-
-                //let zone = $this.getZoneOverlap($this.offsetLeftItemDragged,$this.offsetRightItemDragged)
-                let zone = $this.getZoneOverlap(this.target)
-
-                // fix bug scale !important from css
-                gsap.to(this.target, {
-                    scale: 1, duration: 0, immediateRender: true
-                })
+        setTimeout(function() {
+            Draggable.create($this.item, {
+                type: $this.quiz.resize.isMobile() ? "y" : "x,y",
+                edgeResistance: 0.2,
+                inertia: false,
+                bounds: "#quiz",
+                onDragParams: [{}],
+                onDrag: function () {
+                    $(".zone-1,.zone-2").removeClass("notDrag")
+                    $(this.target).addClass("isDragging").removeClass("isNext")
+
+                    $this.offsetLeftItemDragged = $(this.target).offset().left
+                    $this.offsetRightItemDragged = $(this.target).offset().left + $(this.target).outerWidth()
+                    let direction = this.getDirection()
+
+                    //let zone = $this.getZoneOverlap($this.offsetLeftItemDragged,$this.offsetRightItemDragged)
+                    let zone = $this.getZoneOverlap(this.target)
+
+                    // fix bug scale !important from css
+                    gsap.to(this.target, {
+                        scale: 1, duration: 0, immediateRender: true
+                    })
 
-                //
-                //$this.setOpacityZone(this.target,direction)
+                    //
+                    //$this.setOpacityZone(this.target,direction)
 
-                //set rotation on desktop
-                if (!$this.quiz.resize.isMobile()) {
-                    $this.rotateItem(this, direction)
-                }
+                    //set rotation on desktop
+                    if (!$this.quiz.resize.isMobile()) {
+                        $this.rotateItem(this, direction)
+                    }
 
-                // actions when enter in zone
-                $this.enterZone(zone)
+                    // actions when enter in zone
+                    $this.enterZone(zone)
 
-                // actions when leave zone
-                if (!zone) {
-                    $this.leaveZone()
-                }
-            },
-            onDragEnd: function () {
-                //
-                let zone = $this.getZoneOverlap(this.target)
-                if (zone) {
-                    $this.sendCurrentAnswerToArea(zone, $(this.target).data("id"));
-                }
+                    // actions when leave zone
+                    if (!zone) {
+                        $this.leaveZone()
+                    }
+                },
+                onDragEnd: function () {
+                    //
+                    let zone = $this.getZoneOverlap(this.target)
+                    if (zone) {
+                        $this.sendCurrentAnswerToArea(zone, $(this.target).data("id"));
+                    }
+
+                    //
+                    $(".zone-content").removeClass("active")
+                },
+                onRelease: function () {
+                    //
+                    $(".zone-1,.zone-2").addClass("notDrag")
 
-                //
-                $(".zone-content").removeClass("active")
-            },
-            onRelease: function () {
-                //
-                $(".zone-1,.zone-2").addClass("notDrag")
 
+                    //
+                    document.documentElement.style.setProperty('--opacity-zone-1', '0');
+                    document.documentElement.style.setProperty('--opacity-zone-2', '0');
 
-                //
-                document.documentElement.style.setProperty('--opacity-zone-1', '0');
-                document.documentElement.style.setProperty('--opacity-zone-2', '0');
+                    //
+                    $this.leaveZone()
+
+                    //
+                    if (!$this.getZoneOverlap(this.target)) {
+                        gsap.to(this.target, {
+                            x: 0, y: 0,
+                        })
+                    }
 
-                //
-                $this.leaveZone()
+                    $(this.target).removeClass("isDragging")
 
-                //
-                if (!$this.getZoneOverlap(this.target)) {
+                    // reset list rotation
                     gsap.to(this.target, {
-                        x: 0, y: 0,
+                        rotation: 0
                     })
                 }
+            });
+        }, 1000)
 
-                $(this.target).removeClass("isDragging")
-
-                // reset list rotation
-                gsap.to(this.target, {
-                    rotation: 0
-                })
-            }
-        });
     },
 
     rotateItem: function ($this, direction) {