Removed double click map reset due to conflicts with other interactions
This commit is contained in:
parent
4b4c88f85c
commit
43b0ff3e2e
@ -1,10 +1,4 @@
|
|||||||
import React, {
|
import React, { useRef, useEffect, useState, useContext } from "react";
|
||||||
useRef,
|
|
||||||
useEffect,
|
|
||||||
useState,
|
|
||||||
useContext,
|
|
||||||
useCallback,
|
|
||||||
} from "react";
|
|
||||||
import { Box } from "theme-ui";
|
import { Box } from "theme-ui";
|
||||||
import { useGesture } from "react-use-gesture";
|
import { useGesture } from "react-use-gesture";
|
||||||
import ReactResizeDetector from "react-resize-detector";
|
import ReactResizeDetector from "react-resize-detector";
|
||||||
@ -42,7 +36,8 @@ function MapInteraction({ map, children, controls, selectedToolId }) {
|
|||||||
const stageTranslateRef = useRef({ x: 0, y: 0 });
|
const stageTranslateRef = useRef({ x: 0, y: 0 });
|
||||||
const mapDragPositionRef = useRef({ x: 0, y: 0 });
|
const mapDragPositionRef = useRef({ x: 0, y: 0 });
|
||||||
|
|
||||||
const resetMapTransform = useCallback(() => {
|
// Reset transform when map changes
|
||||||
|
useEffect(() => {
|
||||||
const layer = mapLayerRef.current;
|
const layer = mapLayerRef.current;
|
||||||
if (map && layer) {
|
if (map && layer) {
|
||||||
const mapHeight = stageWidthRef.current * (map.height / map.width);
|
const mapHeight = stageWidthRef.current * (map.height / map.width);
|
||||||
@ -59,11 +54,6 @@ function MapInteraction({ map, children, controls, selectedToolId }) {
|
|||||||
}
|
}
|
||||||
}, [map]);
|
}, [map]);
|
||||||
|
|
||||||
// Reset transform when map changes
|
|
||||||
useEffect(() => {
|
|
||||||
resetMapTransform();
|
|
||||||
}, [map, resetMapTransform]);
|
|
||||||
|
|
||||||
// Convert a client space XY to be normalized to the map image
|
// Convert a client space XY to be normalized to the map image
|
||||||
function getMapDragPosition(xy) {
|
function getMapDragPosition(xy) {
|
||||||
const [x, y] = xy;
|
const [x, y] = xy;
|
||||||
@ -210,7 +200,6 @@ function MapInteraction({ map, children, controls, selectedToolId }) {
|
|||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
{...bind()}
|
{...bind()}
|
||||||
className="map"
|
className="map"
|
||||||
onDoubleClick={resetMapTransform}
|
|
||||||
>
|
>
|
||||||
<ReactResizeDetector handleWidth handleHeight onResize={handleResize}>
|
<ReactResizeDetector handleWidth handleHeight onResize={handleResize}>
|
||||||
<Stage
|
<Stage
|
||||||
|
Loading…
Reference in New Issue
Block a user