Called when the user has activated a new cell and the preview needs to be updated.
({event, value: cell}: MatCalendarUserEvent<MatCalendarCell<D> | null>)
| 437 | |
| 438 | /** Called when the user has activated a new cell and the preview needs to be updated. */ |
| 439 | _previewChanged({event, value: cell}: MatCalendarUserEvent<MatCalendarCell<D> | null>) { |
| 440 | if (this._rangeStrategy) { |
| 441 | // We can assume that this will be a range, because preview |
| 442 | // events aren't fired for single date selections. |
| 443 | const value = cell ? cell.rawValue! : null; |
| 444 | const previewRange = this._rangeStrategy.createPreview( |
| 445 | value, |
| 446 | this.selected as DateRange<D>, |
| 447 | event, |
| 448 | ); |
| 449 | this._previewStart.set(this._getCellCompareValue(previewRange.start)); |
| 450 | this._previewEnd.set(this._getCellCompareValue(previewRange.end)); |
| 451 | |
| 452 | if (this.activeDrag && value) { |
| 453 | const dragRange = this._rangeStrategy.createDrag?.( |
| 454 | this.activeDrag.value, |
| 455 | this.selected as DateRange<D>, |
| 456 | value, |
| 457 | event, |
| 458 | ); |
| 459 | |
| 460 | if (dragRange) { |
| 461 | this._previewStart.set(this._getCellCompareValue(dragRange.start)); |
| 462 | this._previewEnd.set(this._getCellCompareValue(dragRange.end)); |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | /** |
| 469 | * Called when the user has ended a drag. If the drag/drop was successful, |
nothing calls this directly
no test coverage detected