Calender Side Bar Autoscroll behaviour
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import {useEffect} from "react";
|
import {useEffect, useRef} from "react";
|
||||||
|
|
||||||
let startParts = []
|
let startParts = []
|
||||||
let endParts = []
|
let endParts = []
|
||||||
@@ -8,14 +8,22 @@ let result = []
|
|||||||
let startDate
|
let startDate
|
||||||
let calculatedDay = []
|
let calculatedDay = []
|
||||||
const weekdays = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"]
|
const weekdays = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"]
|
||||||
|
let lastMonth = 0
|
||||||
|
|
||||||
export default function BasicDateCalendar(p) {
|
export default function BasicDateCalendar(p) {
|
||||||
|
|
||||||
|
const ref = useRef(null)
|
||||||
|
|
||||||
function getBackMonthColor(monthIndex)
|
function getBackMonthColor(monthIndex)
|
||||||
{
|
{
|
||||||
let date = new Date(parseInt(startParts[2]), parseInt(startParts[1]) + monthIndex - 1, 1)
|
let date = new Date(parseInt(startParts[2]), parseInt(startParts[1]) + monthIndex - 1, 1)
|
||||||
if (date.getFullYear() === p.highlightYear && date.getMonth() === p.highlightMonth)
|
if (date.getFullYear() === p.highlightYear && date.getMonth() === p.highlightMonth)
|
||||||
{
|
{
|
||||||
|
if(lastMonth !== p.highlightMonth)
|
||||||
|
{
|
||||||
|
ref.current.scrollTo({top: 290 * monthIndex - 270, behavior: "smooth"})
|
||||||
|
}
|
||||||
|
lastMonth = p.highlightMonth
|
||||||
return true
|
return true
|
||||||
}else
|
}else
|
||||||
return false
|
return false
|
||||||
@@ -35,7 +43,7 @@ export default function BasicDateCalendar(p) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"Allround"}>
|
<div className={"Allround"} ref={ref}>
|
||||||
<div className={"Down"}>
|
<div className={"Down"}>
|
||||||
{result.map((monthResult, index) => (
|
{result.map((monthResult, index) => (
|
||||||
<div className={"A box-shadow"} onClick={() => p.onMonthClick(
|
<div className={"A box-shadow"} onClick={() => p.onMonthClick(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
margin: 10px;
|
margin: 10px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
height: 270px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.A P
|
.A P
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user