Comments (4)
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.
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.
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.
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)
- Add a basic example on usage HOT 5
- allow global panic handler HOT 2
- removeChild crashes if parent node is nil HOT 1
- [feature request] static HTML/CSS components HOT 6
- Examples go.mod file conflict HOT 1
- Add snake videogame example. HOT 4
- question: What is this prop vs. state idea HOT 3
- Instrumenting panic messages HOT 8
- question: initializing rendered HTML nodes via javascript HOT 4
- Porting gopherjs js calls to use with vecty HOT 2
- Document the availability of vecty project template generator HOT 1
- Return type of If function
- prop.Value("") does not produce the correct html on first render
- Vecty needs an official website HOT 10
- The slack invite link in readme is broken
- vecty docs HOT 1
- How to update a rendered element? HOT 10
- Failed Running The Example HOT 8
- Todo MVC example has misleading usage of p.Items HOT 2
- Rerendering List Replaces First ListItem HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vecty.