Преглед на файлове

Drag and drop with delay

Nikatlas преди 6 години
родител
ревизия
a9328ca248
променени са 2 файла, в които са добавени 15 реда и са изтрити 13 реда
  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()