Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Make events work like the normal DOM #9

Closed
2 tasks done
Olical opened this issue Oct 3, 2015 · 6 comments
Closed
2 tasks done

Make events work like the normal DOM #9

Olical opened this issue Oct 3, 2015 · 6 comments
Assignees

Comments

@Olical
Copy link
Owner

Olical commented Oct 3, 2015

This involves the following changes which should help with things like #4.

  • Calling addEventListener multiple times should allow you to add multiple listeners.
  • Events such as mouse events should pass the native event through, not the synthetic React event.

On listeners...

Right now I have a dumb approach which removes the previous listener and replaces it because I'm just setting props.onClick, for example. This needs to basically delegate to some event system that allows you to add or remove multiple listeners. An abstraction on top of Reacts event system to make it behave like the DOM.

On event objects...

This should allow things like d3.mouse to work, right now it completely fails, you have to hit d3.event and work it out yourself.

@martpie
Copy link

martpie commented Oct 11, 2015

Give that man à cookie...

Thanks a lot !

@Olical
Copy link
Owner Author

Olical commented Oct 11, 2015

No problem :D I needed something to do on this five hour long train ride!
On 11 Oct 2015 9:17 pm, "Pierre de la Martinière" notifications@github.com
wrote:

Give that man à cookie...

Thanks a lot !


Reply to this email directly or view it on GitHub
#9 (comment)
.

@tristanguigue
Copy link

I can't seem to get d3.mouse to work still. It throws a TypeError: container.getBoundingClientRect is not a function

Using this (simplified) example:

let container = d3.select(ReactFauxDOM.createElement('svg'));
container.selectAll('g')
    .data(data)
  .enter().append('g')
    .append('path')
    .attr('d', function(d) {return line(d.values);})
    .on('mouseover', function() {
        let pos = d3.mouse(this) // throws an error
    });

Any reason why this is?

@alexyuly
Copy link
Contributor

@tristanguigue +1. I'm getting the same error (container.getBoundingClientRect is not a function) calling a D3 zoom behavior on an SVG element appended to a <div> created with react-faux-dom, like so (simplified for clarity):

d3.select(createElement('div'))
  .append('svg')
    .call(d3.behavior.zoom().on('zoom', () => { ... })
    .append('g');

Perhaps I am missing something.

@Olical
Copy link
Owner Author

Olical commented Jun 18, 2016

Interesting, would you like to open another issue with some steps to reproduce? Once we have tests for it, it'll be a lot easier.

@sungwoncho
Copy link

@Olical I think I found a related issue. Please see #66.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants