No description
Find a file
Lu Wilson 3ce18c0c31
Fix new wobble (#1431)
This PR stops collaborator cursors wobbling while viewport-following. 
It's a **new wobble** that we haven't seen before! (It crept in at some
point)

It happens when these three things happen at the same time:
* You're following someone
* They're panning
* They're not moving their pointer

eg: This happens when they're trackpad-panning.

So this is *not* the **old wobble** that we fixed before! That one is
still fixed.

---

The **new wobble** looks like this:

![2023-05-22 at 12 08 51 - Magenta
Urial](https://github.com/tldraw/tldraw/assets/15892272/4b738766-cde3-4a9c-9169-76d622bec3bf)

It's sometimes hard-to-spot because of the _smoothing_ that we do.
When we drastically increase the strength of smoothing... the **new
wobble** is less noticeable:
![2023-05-22 at 12 12 40 - Rose
Goat](https://github.com/tldraw/tldraw/assets/15892272/4ece229a-60e8-4923-89f8-4a0f9b702491)

But we can do better!
So for demonstration purposes... let's turn off _smoothing_ to let us
see the **new wobble** more clearly.
![2023-05-22 at 12 16 02 - Gold
Macaw](https://github.com/tldraw/tldraw/assets/15892272/9030cf2a-bdf3-47f0-87f0-a1195ab2fcbf)

Now we can clearly see what's going on...

The cursor is updating every animation **frame**.
The camera is updating every **tick**.

Depending on your screen's refresh rate, these _might be different_!

Let's test that theory by throttling the **tick** further.
As expected, it increases the **new wobble**:
![2023-05-22 at 14 16 21 - Blush
Caterpillar](https://github.com/tldraw/tldraw/assets/15892272/c70ee08c-8fd3-40ae-a4b3-95637c08acc7)

Let's test the theory again by trying on a screen where the _tick_ and
_frame_ are in sync.
As expected, the **new wobble** doesn't happen _most of the time_.

However, _frame_ and _tick_ can still get out of sync! Which causes the
occasional wobble:

![2023-05-22 at 14 38 21 - Lime
Eagle](https://github.com/tldraw/tldraw/assets/15892272/2a9d8c98-194f-4b73-a7ea-ee85ac1fa28f)

So let's fix both cases...
Instead of making the following-camera update every _tick_...
Let's make it update every _frame_!

![2023-05-22 at 15 28 47 - Salmon
Smelt](https://github.com/tldraw/tldraw/assets/15892272/e9f5c10c-d421-4611-b049-7a961218c087)

The perceptive among you might notice a slight wobble that's still
there...
This is an entirely **different wobble** caused by different things.
We can get to it in the future! But we're back at our original
wobble-quota for now.

![2023-05-22 at 14 32 18 - Brown
Tern](https://github.com/tldraw/tldraw/assets/15892272/e1250715-0bf2-4b87-b6e7-a357bccf4106)

When we turn smoothing back on, things look better than before 👍 

![2023-05-22 at 14 42 48 - Cyan
Roundworm](https://github.com/tldraw/tldraw/assets/15892272/f3616c6f-7969-4a8d-80b1-26ee44e6f451)

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Open a single shared project in two different browser sessions.
2. Make one session's user follow the other.
3. Trackpad-pan the leader's camera around.
4. Check that the wobble has reduced.
2023-05-23 08:04:07 +00:00
.github [chore] remove yarnrc-private.yml (#1427) 2023-05-22 08:56:05 +00:00
.husky [chore] remove yarnrc-private.yml (#1427) 2023-05-22 08:56:05 +00:00
.yarn transfer-out: transfer out 2023-04-25 12:01:25 +01:00
apps Update docs links + guides + build (#1422) 2023-05-22 08:21:54 +00:00
assets [feature] add laser pointer (#1412) 2023-05-19 11:09:13 +00:00
config readmes 2023-05-04 13:47:56 +01:00
e2e Measure individual words instead of just line breaks for text exports (#1397) 2023-05-22 15:10:03 +00:00
packages Fix new wobble (#1431) 2023-05-23 08:04:07 +00:00
scripts main: notify huppy after release 2023-05-15 14:17:19 +01:00
.eslintignore enable eslint for test files (#1363) 2023-05-12 13:19:39 +00:00
.eslintplugin.js transfer-out: transfer out 2023-04-25 12:01:25 +01:00
.eslintrc.js enable eslint for test files (#1363) 2023-05-12 13:19:39 +00:00
.gitignore Added initial webdriver tests (#1337) 2023-05-09 20:21:45 +00:00
.ignore [feature] ui events (#1326) 2023-05-11 22:14:58 +00:00
.prettierignore [refactor] record migrations (#1430) 2023-05-22 21:46:24 +00:00
.prettierrc [fix] pick a better default language (#1201) 2023-04-29 23:06:02 +00:00
.yarnrc.yml lite: tweak lockfile name 2023-04-25 12:01:38 +01:00
CODE_OF_CONDUCT.md transfer-out: transfer out 2023-04-25 12:01:25 +01:00
CONTRIBUTING.md [improvement] readme / contributing (#1199) 2023-05-03 08:32:52 +00:00
lazy.config.ts [fix] Don't synchronize isReadOnly (#1396) 2023-05-17 10:45:43 +00:00
lerna.json transfer-out: transfer out 2023-04-25 12:01:25 +01:00
LICENSE transfer-out: transfer out 2023-04-25 12:01:25 +01:00
package.json Update docs links + guides + build (#1422) 2023-05-22 08:21:54 +00:00
public-yarn.lock Create @tldraw/indices package (#1426) 2023-05-22 08:18:01 +00:00
README.md Update docs links + guides + build (#1422) 2023-05-22 08:21:54 +00:00

tldraw

tldraw

Welcome to the public monorepo for tldraw.

What is tldraw?

tldraw is a collaborative digital whiteboard available at tldraw.com. Its editor, user interface, and other underlying libraries are open source and available in this repository. They are also distributed on npm. You can use tldraw to create a drop-in whiteboard for your product or as the foundation on which to build your own inifinite canvas applications.

Learn more at tldraw.dev.

Note

This repo contains source code for the current version of tldraw. You can find the source for the original version here.

Installation & Usage

To learn more about using tldraw in your React application, follow our guide here or see this StackBlitz.

import { Tldraw } from '@tldraw/tldraw'
import '@tldraw/tldraw/editor.css'
import '@tldraw/tldraw/ui.css'

function TldrawExample() {
	return <Tldraw />
}

Local development

To run the local development server, first clone this repo.

Install dependencies:

yarn

Start the local development server:

yarn dev

Open the example project at localhost:5420.

Examples

Our development server contains several examples that demonstrates different ways that you can customize tldraw or use its APIs. Each example is found in the apps/examples/src folder.

  • eg: localhost:5420 for the basic example.
  • eg: localhost:5420/api for the API example.

To learn more about using tldraw, visit our docs.

About this repository

Top-level layout

This repository's contents is divided across four primary sections:

  • /apps contains the source for our applications
  • /packages contains the source for our public packages
  • /scripts contains scripts used for building and publishing
  • /assets contains icons and translations relied on by the app

Applications

Packages

  • editor: the tldraw editor
  • ui: the editor's user interface
  • tldraw: the main tldraw package containing both the editor and the UI
  • primitives: low-level primitives for working with vectors and geometry
  • tlschema: shape definitions and migrations
  • tlsync-client: a library for (locally) syncronizing editor instances
  • tlstore: an in-memory reactive database
  • tlvalidate: a validation library used for run-time validation
  • tlassets: a library for working with tldraw's fonts and translations
  • file-format: a library for working with tldraw's .tldr file format
  • utils: low-level data utilities shared by other libraries

Community

Have questions, comments or feedback? Join our discord or start a discussion.

Distributions

You can find tldraw on npm here.

License

The source code for various apps and packages in this repository (as well as our 2.0+ distributions and releases) are currently licensed under Apache-2.0. These licenses are subject to change in our upcoming 2.0 release. If you are planning to use tldraw in a commercial product, please reach out at hello@tldraw.com.

Contribution

Please see our contributing guide. Found a bug? Please submit an issue.

Note: we are currently unable to accept contributions on the @tldraw/tldraw or @tldraw/editor packages while we work out our final licensing.

Contact

Find us on Twitter at @tldraw or email hello@tldraw.com. You can also join our discord for quick help and support.