Skip to content

Commit 314b3eb

Browse files
Arti Martismarti
Arti M
authored andcommitted
chore: Update docs
1 parent 2a7d80a commit 314b3eb

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,4 @@ The above listener will receive a `CursorUpdate` event:
209209
"position": { "x": 864, "y": 32 },
210210
"data": { "color": "red" }
211211
}
212-
```
212+
```

docs/class-definitions.md

+19
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,25 @@ Set your current location. [Location](#location-1) can be any JSON-serializable
279279
```ts
280280
type set = (update: Location) => void;
281281
```
282+
### getSelf
283+
Get location for self
284+
```ts
285+
space.locations.getSelf()
286+
```
287+
### getAll
288+
Get location for all members
289+
290+
```ts
291+
space.locations.getAll()
292+
```
293+
### getOthers
294+
Get location for other members
295+
296+
```ts
297+
space.locations.getOthers()
298+
```
299+
300+
282301

283302
### on
284303

docs/usage.md

+1-21
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,13 @@ The listener will be called with a `CursorUpdate`:
268268

269269
To set the position of a cursor and emit a `CursorUpdate`, first enter the space:
270270

271-
To retrieve the initial position and data of all cursors within a space, you can use the `cursors.getAll()` method. This returns an object keyed by `connectionId` and cursor name. The value is the last `cursorUpdate` set by the given `connectionId`.
272271
```ts
273272
space.enter();
274273
```
275274

276-
Example of calling `getAll` to return all cursor positions:
277275
Then call `.set`:
278276

279277
```ts
280-
const lastPositions = await space.cursors.getAll();
281278
window.addEventListener('mousemove', ({ clientX, clientY }) => {
282279
space.cursors.set({ position: { x: clientX, y: clientY } });
283280
});
@@ -286,28 +283,11 @@ window.addEventListener('mousemove', ({ clientX, clientY }) => {
286283
A `CursorUpdate` is an object with 2 properties. `position` is an object with 2 required properties, `x` and `y`. These represent the position of the cursor on a 2D plane. A second optional property, `data` can also be passed. This is an object of any shape and is meant for data associated with the cursor movement (like drag or hover calculation results):
287284

288285
```ts
289-
{
290-
"hd9743gjDc": {
291-
"slidedeck-cursors": {
292-
"name": "slidedeck-cursors",
293-
"connectionId": "hd9743gjDc",
294-
"clientId": "clemons#142",
295-
"position": {
296-
"x": 864,
297-
"y": 32
298-
},
299-
"data": {
300-
"color": "red"
301-
}
302-
}
303-
}
304-
}
305286
window.addEventListener('mousemove', ({ clientX, clientY }) => {
306287
space.cursors.set({ position: { x: clientX, y: clientY }, data: { color: 'red' } });
307288
});
308289
```
309290

310-
Example of calling `getAll` to get the last positions for the named cursor `slidedeck-cursors`:
311291
### Initial cursor position and data
312292

313293
To retrieve the initial position and data of all cursors within a space, you can use the `space.cursors.getAll()` method. This returns an object keyed by `connectionId`. The value is the last `cursorUpdate` set by the given `connectionId`.
@@ -382,4 +362,4 @@ space.off(`membersUpdate`, listener);
382362
space.off([`membersUpdate`], listener);
383363
```
384364

385-
As with the native DOM API, this only works if the listener is the same reference as the one passed to `on`.
365+
As with the native DOM API, this only works if the listener is the same reference as the one passed to `on`.

0 commit comments

Comments
 (0)