biodiv / contactjs

Pointer gestures for your webapp
MIT License
77 stars 6 forks source link

Plans to add types? #8

Closed orangecoloured closed 2 years ago

orangecoloured commented 2 years ago

Atm a lot of the frontend dev is done using TypeScript. Do you plan to add types to the lib later on?

SubZtep commented 2 years ago

I came across Hammer.js, whose codebase seems notably larger at first sight. I’m not sure about the difference and used none of it. This code seems quite solid – full of event handling and stuff –, isn’t it possible the TypeScript compiler will try to polyfill snippets that affect performance?

Of course native TypeScript would be best for implementation, but I think generating type definitions from JSDoc (or manually) seems a simpler step.

biodiv commented 2 years ago

Adding types in the future does make sense. I currently like the JSDoc idea as a first step, thanks for the input.

Regarding hammer.js: I have been using hammerjs myself for years until I ran into problems in both performance and recognition (going into detail would result in a very long text and be off topic here). Hammerjs is unmaintained, and I did not see the possibility to solve my issues by creating a fork because of the way hammerjs recognizes input. To put it simply, contactjs relies much more on vector calculations than hammerjs does.

SE2Dev commented 2 years ago

@biodiv I've started work on a port of ContactJS that's written in TypeScript, which, of course, includes type information. I've noticed a few potential bugs in the process; perhaps we can merge the projects?

The first pass simply adds types to the existing code and fixes a few internal issues, but the generated types should be compatible with the existing library.

biodiv commented 2 years ago

@SE2Dev that sounds great. I suggest the following:

What do you think?

SE2Dev commented 2 years ago

@SE2Dev that sounds great. I suggest the following:

  • I add you as a collaborator for this repository, which should give you full access
  • the current src folder is preserved for the time being, until the port is complete
  • TypeScript sources go into a ts folder or something

What do you think?

I've already finished the initial version of the conversion, which is available here. There are some additional changes that will probably need to be made in the future, but for an initial conversion it should hopefully be sufficient.