fix ink demo

This commit is contained in:
“chrisshank” 2024-12-03 20:30:14 -08:00
parent 4e2ece8f01
commit 1f1cfcb597
2 changed files with 6 additions and 4 deletions

View File

@ -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';

View File

@ -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);