Explorar el Código

Drag and drop with delay

Nikatlas hace 6 años
padre
commit
a9328ca248
Se han modificado 2 ficheros con 15 adiciones y 13 borrados
  1. 2 1
      src/Game/app.js
  2. 13 12
      src/helpers/dragAndDrop.js

+ 2 - 1
src/Game/app.js

@@ -26,7 +26,8 @@ class App {
 		window.onresize = this.resize;
 		this.app.view.style.display = 'none';
 		document.body.appendChild(this.app.view);
-		this.app.stage = new PIXI.display.Stage();
+
+		//this.app.stage = new PIXI.display.Stage();
 		this.viewStage = new PIXI.Container();
 		// var graphics = new PIXI.Graphics();
 		// graphics.beginFill(0xFFFF00,0.2);

+ 13 - 12
src/helpers/dragAndDrop.js

@@ -48,20 +48,21 @@ function onDragStart(event)
 
 function onDragEnd()
 {
-    this.alpha = 1;
-    this.dragging = false;
-    // set the interaction data to null
-    this.data = null;
-    if(this.placedPosition) {
-        this.moveTo(this.placedPosition);
-        this.scaleTo(this.placedScale.x);
-    } else {
-        this.moveTo(this.draggingInitial);
-    }
-
     EventManager.emit('CardDraggingFinished');
     // Remove Card Placed Callbacks
-    EventManager.off('CardPlaced', this.placeFn);
+    setTimeout(() => {
+        EventManager.off('CardPlaced', this.placeFn)
+        this.dragging = false;
+        this.alpha = 1;
+        // set the interaction data to null
+        this.data = null;
+        if(this.placedPosition) {
+            this.moveTo(this.placedPosition);
+            this.scaleTo(this.placedScale.x);
+        } else {
+            this.moveTo(this.draggingInitial);
+        }
+    }, 10);
 }
 
 function onDragMove()