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

DOM inside canvas #49

Closed
natew opened this issue Feb 19, 2015 · 3 comments
Closed

DOM inside canvas #49

natew opened this issue Feb 19, 2015 · 3 comments

Comments

@natew
Copy link

natew commented Feb 19, 2015

I've searched around a bit and it seems like it's at least possible, I tried out putting an SVG inside a Surface but got an error. Have you guys tried this, or have any thoughts on implementing?

https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas
http://www.paciellogroup.com/blog/2015/02/html5-canvas-sub-dom/

@mjohnston
Copy link

You'll get mixed results with DOM inside canvas. Usually this is used to provide fallback content for user agents that don't support , or for screen readers. Screen readers on mobile do not support this use case very well though. See issue #5.

Surface does not currently support React.DOM.* children.

@natew
Copy link
Author

natew commented Feb 19, 2015

Interesting. My use case would be to enhance performance of some pieces but not all of them. Minor pieces of the UI like icons, buttons, titlebars, etc don't need to be copy/pasteable, but would benefit greatly from canvas, while other areas that are text heavy would be great to still use DOM.

Will probably take me a while but in the future I'd like to look into this more. Let me know if you have any other readings or tips!

@mjohnston
Copy link

Certainly - you don't have to use React Canvas for the entire UI. flipboard.com, for instance, uses standard DOM rendering for articles where text selection is more essential.

You can use a <Surface> alongside regular components. A typical use case might be to render a loading spinner on top of the canvas while fetching data:

render: function() {
  <div>
    <Surface />
    <div className='loading' />
  </div>
}

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

No branches or pull requests

2 participants