Fix resize detector sizes
This commit is contained in:
parent
029a992381
commit
8e8e800760
@ -192,7 +192,12 @@ function DiceInteraction({
|
|||||||
}}
|
}}
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
>
|
>
|
||||||
<ReactResizeDetector handleWidth handleHeight onResize={handleResize}>
|
<ReactResizeDetector
|
||||||
|
handleWidth
|
||||||
|
handleHeight
|
||||||
|
onResize={handleResize}
|
||||||
|
targetRef={containerRef}
|
||||||
|
>
|
||||||
<canvas
|
<canvas
|
||||||
onPointerDown={handlePointerDown}
|
onPointerDown={handlePointerDown}
|
||||||
onPointerUp={handlePointerUp}
|
onPointerUp={handlePointerUp}
|
||||||
|
@ -136,7 +136,12 @@ function MapEditor({ map, onSettingsChange }: MapEditorProps) {
|
|||||||
bg="muted"
|
bg="muted"
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
>
|
>
|
||||||
<ReactResizeDetector handleWidth handleHeight onResize={handleResize}>
|
<ReactResizeDetector
|
||||||
|
handleWidth
|
||||||
|
handleHeight
|
||||||
|
onResize={handleResize}
|
||||||
|
targetRef={containerRef}
|
||||||
|
>
|
||||||
<KonvaBridge
|
<KonvaBridge
|
||||||
stageRender={(children: React.ReactNode) => (
|
stageRender={(children: React.ReactNode) => (
|
||||||
<Stage
|
<Stage
|
||||||
|
@ -210,7 +210,12 @@ function MapInteraction({
|
|||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
className="map"
|
className="map"
|
||||||
>
|
>
|
||||||
<ReactResizeDetector handleWidth handleHeight onResize={handleResize}>
|
<ReactResizeDetector
|
||||||
|
handleWidth
|
||||||
|
handleHeight
|
||||||
|
onResize={handleResize}
|
||||||
|
targetRef={containerRef}
|
||||||
|
>
|
||||||
<KonvaBridge
|
<KonvaBridge
|
||||||
stageRender={(children) => (
|
stageRender={(children) => (
|
||||||
<Stage
|
<Stage
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState, useRef } from "react";
|
||||||
import { Box, Close, Grid, useThemeUI, IconButton, Text, Flex } from "theme-ui";
|
import { Box, Close, Grid, useThemeUI, IconButton, Text, Flex } from "theme-ui";
|
||||||
import { useSpring, animated, config } from "react-spring";
|
import { useSpring, animated, config } from "react-spring";
|
||||||
import ReactResizeDetector from "react-resize-detector";
|
import ReactResizeDetector from "react-resize-detector";
|
||||||
@ -42,6 +42,7 @@ function TilesOverlay({ modalSize, children }: TilesOverlayProps) {
|
|||||||
config: config.gentle,
|
config: config.gentle,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const [containerSize, setContinerSize] = useState({ width: 0, height: 0 });
|
const [containerSize, setContinerSize] = useState({ width: 0, height: 0 });
|
||||||
function handleContainerResize(width?: number, height?: number) {
|
function handleContainerResize(width?: number, height?: number) {
|
||||||
if (width && height) {
|
if (width && height) {
|
||||||
@ -76,11 +77,13 @@ function TilesOverlay({ modalSize, children }: TilesOverlayProps) {
|
|||||||
top: 0,
|
top: 0,
|
||||||
}}
|
}}
|
||||||
bg="overlay"
|
bg="overlay"
|
||||||
|
ref={containerRef}
|
||||||
/>
|
/>
|
||||||
<ReactResizeDetector
|
<ReactResizeDetector
|
||||||
handleWidth
|
handleWidth
|
||||||
handleHeight
|
handleHeight
|
||||||
onResize={handleContainerResize}
|
onResize={handleContainerResize}
|
||||||
|
targetRef={containerRef}
|
||||||
>
|
>
|
||||||
<animated.div
|
<animated.div
|
||||||
style={{
|
style={{
|
||||||
|
@ -93,7 +93,12 @@ function TokenPreview({ token }: TokenPreviewProps) {
|
|||||||
bg="muted"
|
bg="muted"
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
>
|
>
|
||||||
<ReactResizeDetector handleWidth handleHeight onResize={handleResize}>
|
<ReactResizeDetector
|
||||||
|
handleWidth
|
||||||
|
handleHeight
|
||||||
|
onResize={handleResize}
|
||||||
|
targetRef={containerRef}
|
||||||
|
>
|
||||||
<Stage
|
<Stage
|
||||||
width={stageWidth}
|
width={stageWidth}
|
||||||
height={stageHeight}
|
height={stageHeight}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user