Apply mouseup handler faster in hopes of reducing drag glitches

This commit is contained in:
Max Goodhart
2020-08-10 23:51:29 -07:00
parent 2c0f586eb5
commit df3972dfe8

View File

@@ -5,7 +5,13 @@ import ReconnectingWebSocket from 'reconnecting-websocket'
import * as Y from 'yjs' import * as Y from 'yjs'
import { patch as patchJSON } from 'jsondiffpatch' import { patch as patchJSON } from 'jsondiffpatch'
import { h, Fragment, render } from 'preact' import { h, Fragment, render } from 'preact'
import { useEffect, useState, useCallback, useRef } from 'preact/hooks' import {
useEffect,
useLayoutEffect,
useState,
useCallback,
useRef,
} from 'preact/hooks'
import { State } from 'xstate' import { State } from 'xstate'
import styled, { createGlobalStyle } from 'styled-components' import styled, { createGlobalStyle } from 'styled-components'
import { useHotkeys } from 'react-hotkeys-hook' import { useHotkeys } from 'react-hotkeys-hook'
@@ -214,7 +220,7 @@ function App({ wsEndpoint }) {
ev.preventDefault() ev.preventDefault()
}, []) }, [])
const [dragEnd, setDragEnd] = useState() const [dragEnd, setDragEnd] = useState()
useEffect(() => { useLayoutEffect(() => {
function endDrag() { function endDrag() {
if (dragStart !== undefined) { if (dragStart !== undefined) {
stateDoc.transact(() => { stateDoc.transact(() => {