mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Merge cd2b8e0515
into debf2ad608
This commit is contained in:
commit
a39641d6c1
1 changed files with 22 additions and 0 deletions
|
@ -621,6 +621,8 @@ const gesture: Gesture = {
|
|||
initialScale: null,
|
||||
};
|
||||
|
||||
let velocityX = 0;
|
||||
|
||||
class App extends React.Component<AppProps, AppState> {
|
||||
canvas: AppClassProperties["canvas"];
|
||||
interactiveCanvas: AppClassProperties["interactiveCanvas"] = null;
|
||||
|
@ -811,6 +813,17 @@ class App extends React.Component<AppProps, AppState> {
|
|||
this.actionManager.registerAction(
|
||||
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) {
|
||||
|
@ -8618,6 +8631,15 @@ class App extends React.Component<AppProps, AppState> {
|
|||
this.setState({
|
||||
newElement,
|
||||
});
|
||||
|
||||
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)) {
|
||||
pointerDownState.drag.hasOccurred = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue