fix ink demo
This commit is contained in:
parent
4e2ece8f01
commit
1f1cfcb597
|
|
@ -14,12 +14,14 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin: 0.5rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav>
|
<button on:click="DRAW">Draw</button>
|
||||||
<button on:click="DRAW">Draw</button>
|
|
||||||
</nav>
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import '../src/standalone/folk-shape.ts';
|
import '../src/standalone/folk-shape.ts';
|
||||||
import '../src/standalone/folk-ink.ts';
|
import '../src/standalone/folk-ink.ts';
|
||||||
|
|
|
||||||
|
|
@ -146,11 +146,11 @@ export class FolkInk extends HTMLElement {
|
||||||
|
|
||||||
handleEvent(event: PointerEvent) {
|
handleEvent(event: PointerEvent) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
|
// for some reason adding a point on pointer down causes a bug
|
||||||
case 'pointerdown': {
|
case 'pointerdown': {
|
||||||
if (event.button !== 0 || event.ctrlKey) return;
|
if (event.button !== 0 || event.ctrlKey) return;
|
||||||
|
|
||||||
this.points = [];
|
this.points = [];
|
||||||
this.addPoint([event.offsetX, event.offsetY, event.pressure]);
|
|
||||||
this.addEventListener('lostpointercapture', this);
|
this.addEventListener('lostpointercapture', this);
|
||||||
this.addEventListener('pointermove', this);
|
this.addEventListener('pointermove', this);
|
||||||
this.setPointerCapture(event.pointerId);
|
this.setPointerCapture(event.pointerId);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue