Skip to content
This repository has been archived by the owner on Sep 13, 2021. It is now read-only.

- styling no longer applies if before or after min and max #150

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions saturn-datepicker/src/datepicker/calendar-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
SimpleChanges,
} from '@angular/core';
import {take} from 'rxjs/operators';

/**
* Extra CSS classes that can be associated with a calendar cell.
*/
Expand Down Expand Up @@ -179,7 +178,7 @@ export class SatCalendarBody implements OnChanges {
/** Do not mark start and end of interval. */
if (date === this.begin || date === this.end) {
return false;
}
}
if (this.begin && !this.end) {
return date > this.begin;
}
Expand All @@ -197,6 +196,12 @@ export class SatCalendarBody implements OnChanges {
if (this.isBeforeSelected && !this.begin) {
return date > this._cellOver;
}
if(this._cellOver > this.end){
return false
}
if(this._cellOver < this.begin){
return false
}
if (this._cellOver > this.begin) {
return date > this.begin && date < this._cellOver;
}
Expand All @@ -222,7 +227,7 @@ export class SatCalendarBody implements OnChanges {
/** Whenever to mark cell as end of the range. */
_isEnd(date: number): boolean {
if (this.rangeMode && this.beginSelected && this._cellOver) {
if (this.isBeforeSelected && !this.begin) {
if (this.isBeforeSelected && !this.begin || date > this.end) {
return false;
} else {
return (this.end === date && !(this._cellOver > this.begin)) ||
Expand All @@ -248,6 +253,12 @@ export class SatCalendarBody implements OnChanges {

/** Whenever to highlight the target cell when selecting the second date in range mode */
_previewCellOver(date: number): boolean {
if(this._cellOver > this.end){
return false
}
if(this._cellOver < this.begin){
return false
}
return this._cellOver === date && this.rangeMode && this.beginSelected;
}
}
Loading