Giter Site home page Giter Site logo

EventListener is limiting about vecty HOT 4 CLOSED

hexops avatar hexops commented on May 17, 2024 1
EventListener is limiting

from vecty.

Comments (4)

dave avatar dave commented on May 17, 2024

Seconded... Exposing the raw event object would make things more flexible... Exposing these as methods on the handler is neat, but it always struck me as a bit weird. In fact, the first time I needed to use preventDefault, I spent quite a while scratching my head and referring to examples before I worked it out. It's a lot more familiar to call it within the event handler, and not being able to call it conditionally is an important omission.

p.s. We recently fixed this to expose stopPropagation in the same way as preventDefault.

from vecty.

neelance avatar neelance commented on May 17, 2024

The initial idea for that preventDefault implementation was to be able to automatically call the event listener in a new goroutine to allow blocking code by adding a go statement here: https://github.com/gopherjs/vecty/blob/master/dom.go#L97. This may not be the best solution.

Keep in mind that React still sees a reason for adding an abstraction on the native event: https://facebook.github.io/react/docs/events.html This might be especially necessary when we add event pooling for performance.

from vecty.

slimsag avatar slimsag commented on May 17, 2024

From @davelondon

In order to do a drag+drop file upload, you need access to dataTransfer from the js event. The js native event object isn't currently presented to the vecty event handler. I've added this in my fork as an anonymous struct member, and it seems to feel good in use:

https://github.com/davelondon/uploader/blob/master/editor.go#L133

I seem to remember this was discussed before?

From @shurcooL

need access to dataTransfer from the js event. The js native event object isn't currently presented to the vecty event handler.

Just asking, but have you considered simply filling that gap and exposing dataTransfer natively?

From @slimsag

I think this is a duplicate or related to #55

I agree it is limiting, and the best choice for now is probably to expose the native event object. Although in #55 neelance does make some good points about event pooling in the future.. I'm not sure yet.

@shurcooL there are so many DOM event properties I think it would be a bit crazy to add them all :P

from vecty.

slimsag avatar slimsag commented on May 17, 2024

From React's event documentation it seems like the main reason they use synthetic events is to standardize how events act across browsers. That actually feels a bit strange to do IMO, but I do not know all the details I suppose.

They too, also expose the native event:

If you find that you need the underlying browser event for some reason, simply use the nativeEvent attribute to get it.

And event pooling appears to just be for purposes of not creating the same JS object over and over again (something that could be achieved by simply using the event object the browser gives us).

I think they might do more behind the scenes to improve event performance, but I think for now it is OK for us to expose native event objects.

from vecty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.