Skip to content

Commit cb4365b

Browse files
committed
fix fullscreen, key issue
1 parent 40e0db6 commit cb4365b

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"material-survey": "^1.0.34",
1515
"mmgc1-cpp": "^1.0.50",
1616
"moment": "^2.23.0",
17-
"react-full-screen": "^0.2.4",
17+
"react-full-screen": "^0.3.1",
1818
"react-hotkeys": "^2.0.0",
1919
"react-json-view": "^1.19.1",
2020
"react-markdown": "^4.0.6",

src/ImageCanvas/index.story.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ const events = {
9696

9797
onChangeRegion: action("onChangeRegion"),
9898
onBeginRegionEdit: action("onBeginRegionEdit"),
99-
onChangeRegion: action("onChangeRegion"),
10099
onCloseRegionEdit: action("onCloseRegionEdit"),
101100

102101
onSelectRegion: action("onSelectRegion"),

src/MainLayout/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import useKey from "use-key-hook"
1010
import classnames from "classnames"
1111
import { useSettings } from "../SettingsProvider"
1212
import SettingsDialog from "../SettingsDialog"
13-
import Fullscreen from "../Fullscreen"
13+
// import Fullscreen from "../Fullscreen"
14+
import { FullScreen, useFullScreenHandle } from "react-full-screen"
1415
import getActiveImage from "../Annotator/reducers/get-active-image"
1516
import useImpliedVideoRegions from "./use-implied-video-regions"
1617
import { useDispatchHotkeyHandlers } from "../ShortcutsManager"
@@ -55,6 +56,7 @@ export const MainLayout = ({
5556
}: Props) => {
5657
const classes = useStyles()
5758
const settings = useSettings()
59+
const fullScreenHandle = useFullScreenHandle()
5860

5961
const memoizedActionFns = useRef({})
6062
const action = (type: string, ...params: Array<string>) => {
@@ -165,6 +167,11 @@ export const MainLayout = ({
165167
})
166168

167169
const onClickHeaderItem = useEventCallback((item) => {
170+
if (item.name === "Fullscreen") {
171+
fullScreenHandle.enter()
172+
} else if (item.name === "Window") {
173+
fullScreenHandle.exit()
174+
}
168175
dispatch({ type: "HEADER_BUTTON_CLICKED", buttonName: item.name })
169176
})
170177

@@ -173,11 +180,12 @@ export const MainLayout = ({
173180
!nextImage || (nextImage.regions && nextImage.regions.length > 0)
174181

175182
return (
176-
<Fullscreen
177-
enabled={state.fullScreen}
183+
<FullScreen
184+
handle={fullScreenHandle}
178185
onChange={(open) => {
179186
if (!open) {
180-
action("HEADER_BUTTON_CLICKED", "buttonName")("Exit Fullscreen")
187+
fullScreenHandle.exit()
188+
action("HEADER_BUTTON_CLICKED", "buttonName")("Window")
181189
}
182190
}}
183191
>
@@ -323,7 +331,7 @@ export const MainLayout = ({
323331
}
324332
/>
325333
</HotkeyDiv>
326-
</Fullscreen>
334+
</FullScreen>
327335
)
328336
}
329337

src/RegionShapes/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ const RegionComponents = {
2424
strokeWidth={2}
2525
x={0}
2626
y={0}
27-
width={region.w * iw}
28-
height={region.h * ih}
27+
width={Math.max(region.w * iw, 0)}
28+
height={Math.max(region.h * ih, 0)}
2929
stroke={colorAlpha(region.color, 0.75)}
3030
fill={colorAlpha(region.color, 0.25)}
3131
/>
@@ -80,6 +80,7 @@ const RegionComponents = {
8080
/>
8181
{points.map(({ x, y, angle }, i) => (
8282
<g
83+
key={i}
8384
transform={`translate(${x * iw} ${y * ih}) rotate(${
8485
(-(angle || 0) * 180) / Math.PI
8586
})`}

yarn.lock

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8419,7 +8419,7 @@ fs.realpath@^1.0.0:
84198419
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
84208420
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
84218421

8422-
fscreen@^1.0.1:
8422+
fscreen@^1.0.2:
84238423
version "1.0.2"
84248424
resolved "https://registry.yarnpkg.com/fscreen/-/fscreen-1.0.2.tgz#c4c51d96d819d75a19d728e0df445f9be9bb984f"
84258425
integrity sha1-xMUdltgZ11oZ1yjg30Rfm+m7mE8=
@@ -14459,13 +14459,12 @@ react-focus-lock@^2.1.0:
1445914459
use-callback-ref "^1.2.1"
1446014460
use-sidecar "^1.0.1"
1446114461

14462-
react-full-screen@^0.2.4:
14463-
version "0.2.4"
14464-
resolved "https://registry.yarnpkg.com/react-full-screen/-/react-full-screen-0.2.4.tgz#e5bda9535abb6523b65e0e46526c8f21be65ef7e"
14465-
integrity sha512-K6V87g/uopQnnebg6/jM7VL3FcurgCIQU4nTkzknbjGOT9XOOxr3XVwRweI8QPn1TFRZH7j5OpHanUdk5uYlBQ==
14462+
react-full-screen@^0.3.1:
14463+
version "0.3.1"
14464+
resolved "https://registry.yarnpkg.com/react-full-screen/-/react-full-screen-0.3.1.tgz#60bf7b1ab140348bcfee4f5c98e927b6a0766809"
14465+
integrity sha512-lguQkP+vqwyZGHsLXvM90d8Aktp4gTlPUzszYKuQ9YvxNXIXtu+BILdwr/T+j6P2jREvEppgV20UEauv/0WLDg==
1446614466
dependencies:
14467-
"@types/react" "*"
14468-
fscreen "^1.0.1"
14467+
fscreen "^1.0.2"
1446914468

1447014469
react-github-btn@^1.1.1:
1447114470
version "1.1.1"

0 commit comments

Comments
 (0)