mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Auto Scroll prototyping
This commit is contained in:
parent
fb4bb29aa5
commit
cd2b8e0515
1 changed files with 22 additions and 0 deletions
|
@ -534,6 +534,8 @@ const gesture: Gesture = {
|
||||||
initialScale: null,
|
initialScale: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let velocityX = 0;
|
||||||
|
|
||||||
class App extends React.Component<AppProps, AppState> {
|
class App extends React.Component<AppProps, AppState> {
|
||||||
canvas: AppClassProperties["canvas"];
|
canvas: AppClassProperties["canvas"];
|
||||||
interactiveCanvas: AppClassProperties["interactiveCanvas"] = null;
|
interactiveCanvas: AppClassProperties["interactiveCanvas"] = null;
|
||||||
|
@ -739,6 +741,17 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
this.actionManager.registerAction(
|
this.actionManager.registerAction(
|
||||||
createRedoAction(this.history, this.store),
|
createRedoAction(this.history, this.store),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
if (!this.device.isTouchScreen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.translateCanvas((state) => ({
|
||||||
|
scrollX: state.scrollX - velocityX / state.zoom.value,
|
||||||
|
}));
|
||||||
|
velocityX /= 1 + 1 / 64;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private onWindowMessage(event: MessageEvent) {
|
private onWindowMessage(event: MessageEvent) {
|
||||||
|
@ -7967,6 +7980,15 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
points: [...points, [dx, dy]],
|
points: [...points, [dx, dy]],
|
||||||
pressures,
|
pressures,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (visualViewport) {
|
||||||
|
const feedback =
|
||||||
|
(event.pageX - visualViewport.pageLeft) / visualViewport.width;
|
||||||
|
if (feedback >= 0.625) {
|
||||||
|
const delta = Math.abs(dy) * this.state.zoom.value;
|
||||||
|
velocityX += ((feedback - 0.625) * delta) / 64;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (isLinearElement(newElement)) {
|
} else if (isLinearElement(newElement)) {
|
||||||
pointerDownState.drag.hasOccurred = true;
|
pointerDownState.drag.hasOccurred = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue