Skip to content

Commit

Permalink
fix: disable drag to pan interaction on mobiles
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-giret committed Mar 17, 2024
1 parent a63c5cd commit df9610f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/map.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Text, useMediaQuery } from '@chakra-ui/react';
import { Box, Text } from '@chakra-ui/react';
import { Map as MaplibreMap, NavigationControl } from 'maplibre-gl';
import React, { useEffect, useState } from 'react';

Expand All @@ -8,7 +8,9 @@ const mapId = 'trips-map';

export function TripsMap(): JSX.Element {
const [initialized, setInitialized] = useState(false);
const [isDisplayingInBrowser] = useMediaQuery('(display-mode: browser)');
const isDisplayingInBrowser =
typeof navigator !== 'undefined' &&
/Android|webOS|iPhone|iPad|iPod|Opera Mini/i.test(navigator.userAgent);

useEffect(() => {
setInitialized(true);
Expand Down
6 changes: 4 additions & 2 deletions src/templates/trip/map.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Text, useMediaQuery } from '@chakra-ui/react';
import { Box, Text } from '@chakra-ui/react';
import { Map as MaplibreMap, NavigationControl } from 'maplibre-gl';
import React, { useEffect, useState } from 'react';

Expand All @@ -8,7 +8,9 @@ const mapId = 'trip-map';

function TripMap({ trip: { color, bounds, title, steps } }: { trip: Trip }): JSX.Element {
const [initialized, setInitialized] = useState(false);
const [isDisplayingInBrowser] = useMediaQuery('(display-mode: browser)');
const isDisplayingInBrowser =
typeof navigator !== 'undefined' &&
/Android|webOS|iPhone|iPad|iPod|Opera Mini/i.test(navigator.userAgent);

useEffect(() => {
setInitialized(true);
Expand Down

0 comments on commit df9610f

Please sign in to comment.