This commit is contained in:
hata6502 2025-04-22 14:09:01 +00:00 committed by GitHub
commit a39641d6c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;