Auto Scroll CalenderView to Middle

This commit is contained in:
brausjonas
2023-05-26 15:43:41 +02:00
parent aada7872da
commit d5443c87d0
4 changed files with 24665 additions and 5 deletions
+5 -2
View File
@@ -1,4 +1,4 @@
import {useEffect, useState} from "react"; import {useEffect, useRef, useState} from "react";
import Button from "@/components/Button"; import Button from "@/components/Button";
import {list} from "postcss"; import {list} from "postcss";
import Background from "@/components/Background"; import Background from "@/components/Background";
@@ -18,6 +18,7 @@ export default function CalenderView(p) {
const [entries, setEntries] = useState([[], [], [], [], [], []]) const [entries, setEntries] = useState([[], [], [], [], [], []])
const [update, setUpdate] = useState(false) const [update, setUpdate] = useState(false)
const scrollRef = useRef(null);
function readEntries() { function readEntries() {
let url = "http://localhost:8080/entries?semesterid=" + localStorage.getItem("currentsid") + let url = "http://localhost:8080/entries?semesterid=" + localStorage.getItem("currentsid") +
@@ -189,6 +190,7 @@ export default function CalenderView(p) {
semesterStart = s.startday; semesterStart = s.startday;
}).then(readEntries) }).then(readEntries)
scrollRef.current.scrollTop = 600;
window.addEventListener("contextmenu", (e) => (e.preventDefault())) window.addEventListener("contextmenu", (e) => (e.preventDefault()))
setInterval(function(){ setInterval(function(){
@@ -232,6 +234,7 @@ export default function CalenderView(p) {
flexDirection: "row", flexDirection: "row",
justifyContent: "center", justifyContent: "center",
alignItems: "center", alignItems: "center",
backgroundColor: "white",
gap: 5 gap: 5
}}> }}>
@@ -246,7 +249,7 @@ export default function CalenderView(p) {
<div className={"wochen-tag font-big"}>Samstag {new Date(currentYear, 0, currentWeekStartDay + 5).getDate()}.</div> <div className={"wochen-tag font-big"}>Samstag {new Date(currentYear, 0, currentWeekStartDay + 5).getDate()}.</div>
</div> </div>
</div> </div>
<div className={"calender-container"}> <div className={"calender-container"} ref={scrollRef}>
<div className={"calender-view content"} style={{height: cellHeight * 96 + 10}}> <div className={"calender-view content"} style={{height: cellHeight * 96 + 10}}>
+4 -3
View File
@@ -165,8 +165,8 @@ weekSelector
.dateElement { .dateElement {
display: flex; display: flex;
max-width: 250px; max-width: 900px;
width: 250px; width: 900px;
margin-left: 20px; margin-left: 20px;
margin-right: 20px; margin-right: 20px;
padding: 0px 20px; padding: 0px 20px;
@@ -299,10 +299,11 @@ Calender View
.calender-view .spalte { .calender-view .spalte {
border-radius: 10px; border-radius: 10px;
width: 400px; width: 400px;
background-color: #ffffff; /*background-color: #ffffff;*/
display: grid; display: grid;
padding: 0 3px; padding: 0 3px;
grid-template-columns: 100%; grid-template-columns: 100%;
background-color: white;
} }
.wochen-tag-container .wochen-tag { .wochen-tag-container .wochen-tag {
Binary file not shown.
File diff suppressed because it is too large Load Diff