Merge branch 'main' into stickies-rc

pull/3249/head
Steve Ruiz 2024-04-14 14:30:47 +01:00 zatwierdzone przez GitHub
commit 5711530f1b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 20 dodań i 14 usunięć

Wyświetl plik

@ -8175,11 +8175,16 @@ export class Editor extends EventEmitter<TLEventMap> {
private _updateInputsFromEvent(
info: TLPointerEventInfo | TLPinchEventInfo | TLWheelEventInfo
): void {
const { previousScreenPoint, previousPagePoint, currentScreenPoint, currentPagePoint } =
this.inputs
const {
pointerVelocity,
previousScreenPoint,
previousPagePoint,
currentScreenPoint,
currentPagePoint,
} = this.inputs
const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID)!
const { x: cx, y: cy, z: cz } = this.getCamera()
const { x: cx, y: cy, z: cz } = this.store.unsafeGetWithoutCapture(this.getCameraId())!
const sx = info.point.x - screenBounds.x
const sy = info.point.y - screenBounds.y
@ -8197,9 +8202,9 @@ export class Editor extends EventEmitter<TLEventMap> {
this.inputs.isPen = info.type === 'pointer' && info.isPen
// Reset velocity on pointer down
if (info.name === 'pointer_down') {
this.inputs.pointerVelocity.set(0, 0)
// Reset velocity on pointer down, or when a pinch starts or ends
if (info.name === 'pointer_down' || this.inputs.isPinching) {
pointerVelocity.set(0, 0)
}
// todo: We only have to do this if there are multiple users in the document
@ -8207,14 +8212,15 @@ export class Editor extends EventEmitter<TLEventMap> {
{
id: TLPOINTER_ID,
typeName: 'pointer',
x: currentPagePoint.x,
y: currentPagePoint.y,
x: sx,
y: sy,
lastActivityTimestamp:
// If our pointer moved only because we're following some other user, then don't
// update our last activity timestamp; otherwise, update it to the current timestamp.
info.type === 'pointer' && info.pointerId === INTERNAL_POINTER_IDS.CAMERA_MOVE
? this.store.get(TLPOINTER_ID)?.lastActivityTimestamp ?? Date.now()
: Date.now(),
? this.store.unsafeGetWithoutCapture(TLPOINTER_ID)?.lastActivityTimestamp ??
this._tickManager.now
: this._tickManager.now,
meta: {},
},
])

Wyświetl plik

@ -20,13 +20,13 @@ export class TickManager {
cancelRaf?: null | (() => void)
isPaused = true
last = 0
now = 0
start = () => {
this.isPaused = false
this.cancelRaf?.()
this.cancelRaf = throttleToNextFrame(this.tick)
this.last = Date.now()
this.now = Date.now()
}
tick = () => {
@ -35,8 +35,8 @@ export class TickManager {
}
const now = Date.now()
const elapsed = now - this.last
this.last = now
const elapsed = now - this.now
this.now = now
this.updatePointerVelocity(elapsed)
this.editor.emit('frame', elapsed)