Skip to content

Commit f250011

Browse files
committed
[pr] scroll locking
1 parent 0770400 commit f250011

File tree

14 files changed

+1346
-69
lines changed

14 files changed

+1346
-69
lines changed

excalidraw-app/App.tsx

Lines changed: 337 additions & 13 deletions
Large diffs are not rendered by default.

packages/excalidraw/actions/actionCanvas.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
ZoomResetIcon,
4141
} from "../components/icons";
4242
import { setCursor } from "../cursor";
43+
import { constrainScrollState } from "../scene/scrollConstraints";
4344

4445
import { t } from "../i18n";
4546
import { getNormalizedZoom } from "../scene";
@@ -141,7 +142,7 @@ export const actionZoomIn = register({
141142
trackEvent: { category: "canvas" },
142143
perform: (_elements, appState, _, app) => {
143144
return {
144-
appState: {
145+
appState: constrainScrollState({
145146
...appState,
146147
...getStateForZoom(
147148
{
@@ -152,7 +153,7 @@ export const actionZoomIn = register({
152153
appState,
153154
),
154155
userToFollow: null,
155-
},
156+
}),
156157
captureUpdate: CaptureUpdateAction.EVENTUALLY,
157158
};
158159
},
@@ -182,7 +183,7 @@ export const actionZoomOut = register({
182183
trackEvent: { category: "canvas" },
183184
perform: (_elements, appState, _, app) => {
184185
return {
185-
appState: {
186+
appState: constrainScrollState({
186187
...appState,
187188
...getStateForZoom(
188189
{
@@ -193,7 +194,7 @@ export const actionZoomOut = register({
193194
appState,
194195
),
195196
userToFollow: null,
196-
},
197+
}),
197198
captureUpdate: CaptureUpdateAction.EVENTUALLY,
198199
};
199200
},

packages/excalidraw/appState.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const defaultExportScale = EXPORT_SCALES.includes(devicePixelRatio)
2323

2424
export const getDefaultAppState = (): Omit<
2525
AppState,
26-
"offsetTop" | "offsetLeft" | "width" | "height"
26+
"offsetTop" | "offsetLeft" | "width" | "height" | "scrollConstraints"
2727
> => {
2828
return {
2929
showWelcomeScreen: false,
@@ -250,6 +250,7 @@ const APP_STATE_STORAGE_CONF = (<
250250
objectsSnapModeEnabled: { browser: true, export: false, server: false },
251251
userToFollow: { browser: false, export: false, server: false },
252252
followedBy: { browser: false, export: false, server: false },
253+
scrollConstraints: { browser: false, export: false, server: false },
253254
isCropping: { browser: false, export: false, server: false },
254255
croppingElementId: { browser: false, export: false, server: false },
255256
searchMatches: { browser: false, export: false, server: false },

0 commit comments

Comments
 (0)