@@ -329,7 +329,23 @@ export default class Draggable {
329
329
* @return {String|null }
330
330
*/
331
331
getClassNameFor ( name ) {
332
- return this . options . classes [ name ] ;
332
+ return this . getClassNamesFor ( name ) [ 0 ] ;
333
+ }
334
+
335
+ /**
336
+ * Returns class names for class identifier
337
+ * @return {String[] }
338
+ */
339
+ getClassNamesFor ( name ) {
340
+ const classNames = this . options . classes [ name ] ;
341
+
342
+ if ( classNames instanceof Array ) {
343
+ return classNames ;
344
+ } else if ( typeof classNames === 'string' || classNames instanceof String ) {
345
+ return [ classNames ] ;
346
+ } else {
347
+ return [ ] ;
348
+ }
333
349
}
334
350
335
351
/**
@@ -393,8 +409,8 @@ export default class Draggable {
393
409
394
410
if ( this . lastPlacedSource && this . lastPlacedContainer ) {
395
411
clearTimeout ( this . placedTimeoutID ) ;
396
- this . lastPlacedSource . classList . remove ( this . getClassNameFor ( 'source:placed' ) ) ;
397
- this . lastPlacedContainer . classList . remove ( this . getClassNameFor ( 'container:placed' ) ) ;
412
+ this . lastPlacedSource . classList . remove ( ... this . getClassNamesFor ( 'source:placed' ) ) ;
413
+ this . lastPlacedContainer . classList . remove ( ... this . getClassNamesFor ( 'container:placed' ) ) ;
398
414
}
399
415
400
416
this . source = this . originalSource . cloneNode ( true ) ;
@@ -418,10 +434,10 @@ export default class Draggable {
418
434
return ;
419
435
}
420
436
421
- this . originalSource . classList . add ( this . getClassNameFor ( 'source:original' ) ) ;
422
- this . source . classList . add ( this . getClassNameFor ( 'source:dragging' ) ) ;
423
- this . sourceContainer . classList . add ( this . getClassNameFor ( 'container:dragging' ) ) ;
424
- document . body . classList . add ( this . getClassNameFor ( 'body:dragging' ) ) ;
437
+ this . originalSource . classList . add ( ... this . getClassNamesFor ( 'source:original' ) ) ;
438
+ this . source . classList . add ( ... this . getClassNamesFor ( 'source:dragging' ) ) ;
439
+ this . sourceContainer . classList . add ( ... this . getClassNamesFor ( 'container:dragging' ) ) ;
440
+ document . body . classList . add ( ... this . getClassNamesFor ( 'body:dragging' ) ) ;
425
441
applyUserSelect ( document . body , 'none' ) ;
426
442
427
443
requestAnimationFrame ( ( ) => {
@@ -479,7 +495,7 @@ export default class Draggable {
479
495
over : this . currentOver ,
480
496
} ) ;
481
497
482
- this . currentOver . classList . remove ( this . getClassNameFor ( 'draggable:over' ) ) ;
498
+ this . currentOver . classList . remove ( ... this . getClassNamesFor ( 'draggable:over' ) ) ;
483
499
this . currentOver = null ;
484
500
485
501
this . trigger ( dragOutEvent ) ;
@@ -494,14 +510,14 @@ export default class Draggable {
494
510
overContainer : this . currentOverContainer ,
495
511
} ) ;
496
512
497
- this . currentOverContainer . classList . remove ( this . getClassNameFor ( 'container:over' ) ) ;
513
+ this . currentOverContainer . classList . remove ( ... this . getClassNamesFor ( 'container:over' ) ) ;
498
514
this . currentOverContainer = null ;
499
515
500
516
this . trigger ( dragOutContainerEvent ) ;
501
517
}
502
518
503
519
if ( isOverContainer ) {
504
- overContainer . classList . add ( this . getClassNameFor ( 'container:over' ) ) ;
520
+ overContainer . classList . add ( ... this . getClassNamesFor ( 'container:over' ) ) ;
505
521
506
522
const dragOverContainerEvent = new DragOverContainerEvent ( {
507
523
source : this . source ,
@@ -517,7 +533,7 @@ export default class Draggable {
517
533
}
518
534
519
535
if ( isOverDraggable ) {
520
- target . classList . add ( this . getClassNameFor ( 'draggable:over' ) ) ;
536
+ target . classList . add ( ... this . getClassNamesFor ( 'draggable:over' ) ) ;
521
537
522
538
const dragOverEvent = new DragOverEvent ( {
523
539
source : this . source ,
@@ -559,32 +575,32 @@ export default class Draggable {
559
575
this . source . parentNode . removeChild ( this . source ) ;
560
576
this . originalSource . style . display = '' ;
561
577
562
- this . source . classList . remove ( this . getClassNameFor ( 'source:dragging' ) ) ;
563
- this . originalSource . classList . remove ( this . getClassNameFor ( 'source:original' ) ) ;
564
- this . originalSource . classList . add ( this . getClassNameFor ( 'source:placed' ) ) ;
565
- this . sourceContainer . classList . add ( this . getClassNameFor ( 'container:placed' ) ) ;
566
- this . sourceContainer . classList . remove ( this . getClassNameFor ( 'container:dragging' ) ) ;
567
- document . body . classList . remove ( this . getClassNameFor ( 'body:dragging' ) ) ;
578
+ this . source . classList . remove ( ... this . getClassNamesFor ( 'source:dragging' ) ) ;
579
+ this . originalSource . classList . remove ( ... this . getClassNamesFor ( 'source:original' ) ) ;
580
+ this . originalSource . classList . add ( ... this . getClassNamesFor ( 'source:placed' ) ) ;
581
+ this . sourceContainer . classList . add ( ... this . getClassNamesFor ( 'container:placed' ) ) ;
582
+ this . sourceContainer . classList . remove ( ... this . getClassNamesFor ( 'container:dragging' ) ) ;
583
+ document . body . classList . remove ( ... this . getClassNamesFor ( 'body:dragging' ) ) ;
568
584
applyUserSelect ( document . body , '' ) ;
569
585
570
586
if ( this . currentOver ) {
571
- this . currentOver . classList . remove ( this . getClassNameFor ( 'draggable:over' ) ) ;
587
+ this . currentOver . classList . remove ( ... this . getClassNamesFor ( 'draggable:over' ) ) ;
572
588
}
573
589
574
590
if ( this . currentOverContainer ) {
575
- this . currentOverContainer . classList . remove ( this . getClassNameFor ( 'container:over' ) ) ;
591
+ this . currentOverContainer . classList . remove ( ... this . getClassNamesFor ( 'container:over' ) ) ;
576
592
}
577
593
578
594
this . lastPlacedSource = this . originalSource ;
579
595
this . lastPlacedContainer = this . sourceContainer ;
580
596
581
597
this . placedTimeoutID = setTimeout ( ( ) => {
582
598
if ( this . lastPlacedSource ) {
583
- this . lastPlacedSource . classList . remove ( this . getClassNameFor ( 'source:placed' ) ) ;
599
+ this . lastPlacedSource . classList . remove ( ... this . getClassNamesFor ( 'source:placed' ) ) ;
584
600
}
585
601
586
602
if ( this . lastPlacedContainer ) {
587
- this . lastPlacedContainer . classList . remove ( this . getClassNameFor ( 'container:placed' ) ) ;
603
+ this . lastPlacedContainer . classList . remove ( ... this . getClassNamesFor ( 'container:placed' ) ) ;
588
604
}
589
605
590
606
this . lastPlacedSource = null ;
0 commit comments