Merge pull request #74 from timothyarmes/scroll

Make scrolling easier on mobile (#67)
This commit is contained in:
Owen Rees
2023-07-06 09:51:47 +02:00
committed by GitHub
2 changed files with 16 additions and 0 deletions
+15
View File
@@ -8,6 +8,7 @@ import {
LayerGroup,
useMapEvent,
} from "react-leaflet";
import { FaChevronDown } from "react-icons/fa";
import { useAtomValue, useSetAtom } from "jotai";
import "leaflet/dist/leaflet.css";
@@ -37,6 +38,11 @@ export default function TournamentMap() {
const setMapBounds = useSetAtom(mapBoundsAtom);
const center: LatLngLiteral = { lat: 47.0844, lng: 2.3964 };
const onScrollToTable = () => {
const tournamentTable = document.getElementById("tournament-table");
tournamentTable?.scrollIntoView({ behavior: "smooth" });
};
const createLayerGroups = (
timeControl: TimeControl,
colour: string,
@@ -110,6 +116,15 @@ export default function TournamentMap() {
{blitzMarkers}
{otherMarkers}
</MapContainer>
<div className="flex items-center justify-center lg:hidden">
<button
className="p-3 text-teal-900 dark:text-white"
onClick={onScrollToTable}
>
<FaChevronDown />
</button>
</div>
</section>
);
}
+1
View File
@@ -38,6 +38,7 @@ export default function TournamentTable() {
const tournamentRow = document.getElementById(
debouncedHoveredMapTournamentId
);
tournamentRow?.scrollIntoView({ behavior: "smooth" });
}, [debouncedHoveredMapTournamentId]);