Skip to content

Commit 7eca955

Browse files
committed
fix: glass pen filter, element targeting in skill, rename to board
1 parent a36bcaf commit 7eca955

3 files changed

Lines changed: 30 additions & 5 deletions

File tree

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ event stream and dispatches it to the passed `element`:
111111
> "swipe across an element using 1 finger, and draw a square":
112112
113113
```js
114-
await new DragMotion(document.querySelector('#whiteboard'), [
114+
await new DragMotion(document.querySelector('#board'), [
115115
[30, 50, 0],
116116
[60, 80, 16],
117117
[120, 140, 32],
@@ -122,24 +122,26 @@ await new DragMotion(document.querySelector('#whiteboard'), [
122122
> then lift up":
123123
124124
```js
125-
await new TwistMotion(document.querySelector('#whiteboard'), 45, {
125+
await new TwistMotion(document.querySelector('#board'), 45, {
126126
x: 100, y: 100
127127
}).perform()
128128
```
129129

130130
### Element targeting
131131

132132
The passed element should be the **container** of the
133-
actual element you're targeting:
133+
actual element you're targeting.
134+
135+
For example:
134136

135137
```html
136-
<div id="whiteboard">
138+
<div id="board">
137139
<canvas></canvas>
138140
</div>
139141
```
140142

141143
```js
142-
await new DragMotion(document.querySelector('#whiteboard'), [
144+
await new DragMotion(document.querySelector('#board'), [
143145
[30, 50, 0],
144146
[60, 80, 16],
145147
]).perform()

bin/skill.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,26 @@ await new DragMotion(el, [
5151
- `ms` is relative to motion start and must be non-decreasing.
5252
- Use `getBoundingClientRect()` to keep points inside the element.
5353

54+
## Element targeting
55+
56+
The passed element should be the **container** of the
57+
actual element you're targeting:
58+
59+
For example:
60+
61+
```html
62+
<div id="board">
63+
<canvas></canvas>
64+
</div>
65+
```
66+
67+
```js
68+
await new DragMotion(document.querySelector('#board'), [
69+
[30, 50, 0],
70+
[60, 80, 16],
71+
]).perform()
72+
```
73+
5474
## Glass
5575

5676
Glass is an overlay that visualizes dispatched events

src/glass/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ const js = `;(() => {
128128
const f = lookup.get(e.type)
129129
if (!f) return
130130
131+
if (f.name === 'pointer' && e.pointerType !== 'pen')
132+
return
133+
131134
const x = e.changedTouches?.[0]?.clientX ?? e.clientX
132135
const y = e.changedTouches?.[0]?.clientY ?? e.clientY
133136

0 commit comments

Comments
 (0)