@@ -68,11 +68,14 @@ const appendToParent = (element) => {
68
68
const parentNode = element . parentNode ;
69
69
const siblings = elementChildren ( parentNode ) ;
70
70
const targetIndex = siblings . indexOf ( element ) ;
71
+ const appended = targetIndex + 1 !== siblings . length ;
71
72
72
- if ( targetIndex + 1 !== siblings . length ) {
73
+ if ( appended ) {
73
74
parentNode . removeChild ( element ) ;
74
75
parentNode . appendChild ( element ) ;
75
76
}
77
+
78
+ return appended ;
76
79
} ;
77
80
78
81
/**
@@ -207,6 +210,7 @@ const Card = (stack, targetElement) => {
207
210
let throwDirectionToEventName ;
208
211
let throwOutDistance ;
209
212
let throwWhere ;
213
+ let appendedDuringMouseDown ;
210
214
211
215
const construct = ( ) => {
212
216
card = { } ;
@@ -347,10 +351,16 @@ const Card = (stack, targetElement) => {
347
351
} ) ( ) ;
348
352
} else {
349
353
targetElement . addEventListener ( 'mousedown' , ( ) => {
354
+ appendedDuringMouseDown = appendToParent ( targetElement ) || appendedDuringMouseDown ;
350
355
eventEmitter . trigger ( 'panstart' ) ;
351
356
} , { passive : true } ) ;
352
357
353
358
targetElement . addEventListener ( 'mouseup' , ( ) => {
359
+ if ( appendedDuringMouseDown ) {
360
+ targetElement . click ( ) ;
361
+ appendedDuringMouseDown = false ;
362
+ }
363
+
354
364
if ( isDraging && ! isPanning ) {
355
365
eventEmitter . trigger ( 'dragend' , {
356
366
target : targetElement
@@ -473,13 +483,15 @@ const Card = (stack, targetElement) => {
473
483
lastThrow . direction = direction || computeDirection ( fromX , fromY , config . allowedDirections ) ;
474
484
475
485
if ( where === THROW_IN ) {
486
+ appendToParent ( targetElement ) ;
476
487
springThrowIn . setCurrentValue ( 0 ) . setAtRest ( ) . setEndValue ( 1 ) ;
477
488
478
489
eventEmitter . trigger ( 'throwin' , {
479
490
target : targetElement ,
480
491
throwDirection : lastThrow . direction
481
492
} ) ;
482
493
} else if ( where === THROW_OUT ) {
494
+ appendToParent ( targetElement ) ;
483
495
isDraging = false ;
484
496
springThrowOut . setCurrentValue ( 0 ) . setAtRest ( ) . setVelocity ( 100 ) . setEndValue ( 1 ) ;
485
497
0 commit comments