Skip to content
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

Expose the event types so it could be used with svelte typescript #1

Closed
joseDaKing opened this issue Jun 3, 2021 · 2 comments
Closed

Comments

@joseDaKing
Copy link

No description provided.

@qurafi
Copy link
Owner

qurafi commented Jun 3, 2021

Thank you for your suggestion. I will work on that on the next release.

@qurafi
Copy link
Owner

qurafi commented Jun 4, 2021

Event types now are shipped in the latest 1.1.4 version.

First make sure you reference types in your tsconfig file:

"include": [
    "node_modules/ezgesture/types/*"
],

Then you can use you the types globally in svelte without importing them:

<button on:ezgdragstart="{onDragStart}"></button>

Here in markup It will automatically check function type. but you have to do it manually in the function definition:

function onDragStart(event: EZGDragEvent) {
  console.log(event.detail.startX);
}

For DOM Events. it will automatically do types for you:

document.body.addEventListener("ezgdragstart", ev => {
   console.log(ev.detail.startX)
})

List of available interfaces(Available globally):

EZGDragEvent // for all drag events

EZGPinchStartEvent
EZGPinchMoveEvent
EZGPinchEndEvent 

EZGLongPressEvent

* Replace Event with Detail to get access to parameter types

@qurafi qurafi closed this as completed Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants