This commit is contained in:
Lars Westermann 2019-06-14 14:50:27 +02:00
parent 73c4190231
commit 91175653c6
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D
2 changed files with 26 additions and 5 deletions

View file

@ -89,22 +89,26 @@ class Calendar(calendar: HTMLElement) : View(calendar) {
val x = html.offsetTop - htmlBody.scrollTop val x = html.offsetTop - htmlBody.scrollTop
if (x > 0) { if (x > 0) {
val bodyScroll = min(x, verticalScroll) val bodyScroll = min(x, verticalScroll)
verticalScroll -= bodyScroll verticalScroll = 0.0
htmlBody.scrollBy(ScrollToOptions(0.0, bodyScroll, ScrollBehavior.INSTANT)) htmlBody.scrollBy(ScrollToOptions(0.0, bodyScroll, ScrollBehavior.INSTANT))
} else { } else {
if (calendarTable.scrollTop + calendarTable.clientHeight + 5 >= calendarTable.scrollHeight) { if (calendarTable.scrollTop + calendarTable.clientHeight + 5 >= calendarTable.scrollHeight) {
htmlBody.scrollBy(ScrollToOptions(0.0, verticalScroll, ScrollBehavior.INSTANT)) htmlBody.scrollBy(ScrollToOptions(0.0, verticalScroll, ScrollBehavior.INSTANT))
} else if (x < 0) {
htmlBody.scrollBy(ScrollToOptions(0.0, x, ScrollBehavior.INSTANT))
} }
} }
} else if (verticalScroll < 0) { } else if (verticalScroll < 0) {
val x = html.offsetTop - htmlBody.scrollTop val x = html.offsetTop - htmlBody.scrollTop
if (x < 0) { if (x < 0) {
val bodyScroll = max(x, verticalScroll) val bodyScroll = max(x, verticalScroll)
verticalScroll -= bodyScroll verticalScroll = 0.0
htmlBody.scrollBy(ScrollToOptions(0.0, bodyScroll, ScrollBehavior.INSTANT)) htmlBody.scrollBy(ScrollToOptions(0.0, bodyScroll, ScrollBehavior.INSTANT))
} else { } else {
if (calendarTable.scrollTop == 0.0) { if (calendarTable.scrollTop == 0.0) {
htmlBody.scrollBy(ScrollToOptions(0.0, verticalScroll, ScrollBehavior.INSTANT)) htmlBody.scrollBy(ScrollToOptions(0.0, verticalScroll, ScrollBehavior.INSTANT))
} else if (x > 0) {
htmlBody.scrollBy(ScrollToOptions(0.0, x, ScrollBehavior.INSTANT))
} }
} }
} }

View file

@ -369,7 +369,12 @@
.calendar-cell:first-child { .calendar-cell:first-child {
text-align: center; text-align: center;
width: 6rem; width: 4rem;
left: 0;
position: sticky;
z-index: 2;
background-color: var(--background-secondary-color);
border-right: solid 1px var(--table-border-color);
} }
.calendar-cell:not(:first-child) { .calendar-cell:not(:first-child) {
@ -387,6 +392,10 @@
position: absolute; position: absolute;
} }
} }
.calendar-cell:nth-child(1)::before , .calendar-cell:nth-child(2)::before{
border-left: none;
}
} }
.calendar-body { .calendar-body {
@ -421,12 +430,20 @@
} }
.calendar-cell:first-child { .calendar-cell:first-child {
width: 6rem; width: 4rem;
left: 0; left: 0;
text-align: center; text-align: center;
position: sticky;
z-index: 2;
background-color: var(--background-secondary-color);
border-right: solid 1px var(--table-border-color);
&:not(:empty) {
z-index: 3;
}
} }
.calendar-cell:first-child::before { .calendar-cell:nth-child(1)::before , .calendar-cell:nth-child(2)::before{
border-left: none; border-left: none;
} }