@@ -455,6 +455,10 @@ export class MatCalendarBody<D = any> implements OnChanges, OnDestroy, AfterView
455
455
}
456
456
} ;
457
457
458
+ /**
459
+ * Triggered on mousedown or touchstart on a date cell.
460
+ * Respsonsible for starting a drag sequence.
461
+ */
458
462
private _mousedownHandler = ( event : Event ) => {
459
463
this . _didDragSinceMouseDown = false ;
460
464
// Begin a drag if a cell within the current range was targeted.
@@ -471,6 +475,7 @@ export class MatCalendarBody<D = any> implements OnChanges, OnDestroy, AfterView
471
475
} ) ;
472
476
} ;
473
477
478
+ /** Triggered on mouseup anywhere. Respsonsible for ending a drag sequence. */
474
479
private _mouseupHandler = ( event : Event ) => {
475
480
const cellElement = getCellElement ( event . target as HTMLElement ) ;
476
481
if ( ! cellElement ) {
@@ -493,6 +498,7 @@ export class MatCalendarBody<D = any> implements OnChanges, OnDestroy, AfterView
493
498
} ) ;
494
499
} ;
495
500
501
+ /** Triggered on touchend anywhere. Respsonsible for ending a drag sequence. */
496
502
private _touchendHandler = ( event : TouchEvent ) => {
497
503
const target = getActualTouchTarget ( event ) ;
498
504
@@ -529,6 +535,10 @@ function isTableCell(node: Node | undefined | null): node is HTMLTableCellElemen
529
535
return node ?. nodeName === 'TD' ;
530
536
}
531
537
538
+ /**
539
+ * Gets the date table cell element that is or contains the specified element.
540
+ * Or returns null if element is not part of a date cell.
541
+ */
532
542
function getCellElement ( element : HTMLElement ) : HTMLElement | null {
533
543
let cell : HTMLElement | undefined ;
534
544
if ( isTableCell ( element ) ) {
@@ -569,6 +579,10 @@ function isInRange(
569
579
) ;
570
580
}
571
581
582
+ /**
583
+ * Extracts the element that actually corresponds to a touch event's location
584
+ * (rather than the element that initiated the sequence of touch events).
585
+ */
572
586
function getActualTouchTarget ( event : TouchEvent ) : Element | null {
573
587
const touchLocation = event . changedTouches [ 0 ] ;
574
588
return document . elementFromPoint ( touchLocation . clientX , touchLocation . clientY ) ;
0 commit comments