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

Make it possible to pass DOM-object to CanvasSpace instead of id #23

Closed
jonathanazulay opened this issue Sep 13, 2016 · 4 comments
Closed

Comments

@jonathanazulay
Copy link

In some cases, giving elements an id is undesirable. It would be better to just be able to pass in an object. For example with React, using IDs break the idea of writing reusable components.

Bad

var space = new CanvasSpace('canvas').setup( {bgcolor: '#f1f5f7'} )

render () {
  return (
    <canvas id="canvas" />
  )
}

Good

var space = new CanvasSpace(this.refs.canvas).setup( {bgcolor: '#f1f5f7'} )

render () {
  return (
    <canvas ref="canvas" />
  )
}
@williamngan
Copy link
Owner

That's a good point. Will fix this to support React and DOM element as parameter.

It uses "id" because it's much easier for beginners to set an "id" in a div then querying the DOM. But definitely should support more advanced uses too.

Thanks @jonathanazulay !

@williamngan
Copy link
Owner

Fixed :) You should be able to pass a DOM element or an id to initiate a CanvasSpace. Please see if it works.

1a98873

@williamngan
Copy link
Owner

I've tested it with something like new CanvasSpace(this.refs.canvas).setup( ... ) in React's componentDidMount. It works.

@jonathanazulay
Copy link
Author

Sorry for the late feedback! Works great, thanks 💯 👍

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

No branches or pull requests

2 participants