Skip to content

Commit

Permalink
Fix issue where World view minimum size wasn't taking into account na…
Browse files Browse the repository at this point in the history
…vigator sidebar or debugger pane causing unnecessary scroll bars
  • Loading branch information
chrismaltby committed May 22, 2024
1 parent 51fa252 commit e90c946
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix issue where some sidebar inputs would appear above script tabs when scrolled
- Fix rumble support when using MBC5 cartridge [@pau-tomas](https://github.com/pau-tomas)
- Fix issue where empty project message would be positioned incorrectly if World view was scrolled or zoomed
- Fix issue where World view minimum size wasn't taking into account navigator sidebar or debugger pane causing unnecessary scroll bars

## [4.0.0-beta2]

Expand Down
11 changes: 5 additions & 6 deletions src/components/world/WorldView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import styled from "styled-components";
import { useAppDispatch, useAppSelector } from "store/hooks";
import { SceneNormalized } from "shared/lib/entities/entitiesTypes";
import { Selection } from "ui/document/Selection";
import useResizeObserver from "ui/hooks/use-resize-observer";

const Wrapper = styled.div`
position: absolute;
Expand Down Expand Up @@ -88,7 +89,8 @@ const WorldView = () => {
const dispatch = useAppDispatch();
const store = useStore();

const scrollRef = useRef<HTMLDivElement>(null);
const [scrollRef, scrollContainerSize] = useResizeObserver<HTMLDivElement>();

const scrollContentsRef = useRef<HTMLDivElement>(null);
const worldRef = useRef<HTMLDivElement>(null);
const blockWheelZoom = useRef<number>();
Expand Down Expand Up @@ -131,12 +133,9 @@ const WorldView = () => {
(state) => state.editor.clipboardVariables
);
const focusSceneId = useAppSelector((state) => state.editor.focusSceneId);
const sidebarWidth = useAppSelector(
(state) => state.editor.worldSidebarWidth
);

const viewportWidth = window.innerWidth - sidebarWidth - 17;
const viewportHeight = window.innerHeight - 40 - 17;
const viewportWidth = scrollContainerSize?.width ?? 0;
const viewportHeight = scrollContainerSize?.height ?? 0;

const scrollWidth = useAppSelector((state) =>
Math.max(viewportWidth, getMaxSceneRight(state) + 20)
Expand Down

0 comments on commit e90c946

Please sign in to comment.