-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pointer: Replace old primitives with createPointers
#697
base: main
Are you sure you want to change the base?
Conversation
|
@@ -1,4 +1,4 @@ | |||
import { createPointerListeners, pointerHover, createPointerList } from "../src/index.js"; | |||
import { createPointerListeners, pointerHover, createPointerList } from "../src/index-ols.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haven’t touched demo yet
well I did
but by mistake
it’s wip :)
); | ||
if (onGotCapture) addEventListener("gotpointercapture", onGotCapture); | ||
if (onLostCapture) addEventListener("lostpointercapture", onLostCapture); | ||
function upsert_pointer(pointers: PointerEvent[], e: PointerEvent): PointerEvent[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "upsert" mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update/insert
it’s such a cool shortcut I’m upsert I don’t see it more :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just use "set"?
const up_event_touch = new PointerEvent("pointerup", { pointerId: 2, pointerType: "touch" }); | ||
const cancel_event_touch = new PointerEvent("pointercancel", { pointerId: 2, pointerType: "touch" }); | ||
|
||
const ref = document.createElement("div"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the same ref for all tests seem a bit brittle.
It's probably a good time to remove that crap that was the pointer package and replace it with a simple, but actually useful primitive.
The old api was just an experimentation that ended up too complicated and not at at useful. The package is not used much either judging by the downloads.
The new
createPointers
primitive is simple, but it something I would use, it just gives you a list of pointer events of pointers that are currently on the screen. All the other magic like position_to_element, is_inside and is_down can be derived from this list, and I'll be adding examples how to do that to the readme later.