21
More native look and feel with HTML5 canvas Cases, advantages, issues and solutions

More native look and feel of mobile JS applications with HTML5 canvas

Embed Size (px)

DESCRIPTION

Why canvas beats DOM sometimes? How to use canvas in more efficient way? What are bottlenecks?

Citation preview

Page 1: More native look and feel of mobile JS applications with HTML5 canvas

More native look and feel with HTML5 canvas

Cases, advantages, issues and solutions

Page 2: More native look and feel of mobile JS applications with HTML5 canvas

How to compare DOM and CANVAS?

We will use FlashJS engine.

It have CANVAS and DOM renderers, so we can launch same code in both ways.

flashjs.com

Page 3: More native look and feel of mobile JS applications with HTML5 canvas

Why?

Page 4: More native look and feel of mobile JS applications with HTML5 canvas

Why not HTML?

HTML Node - is heavy to render object.

● Designed for advanced layouts, sometimes it is useless and harmful

● CSS● Legacy properties, logic

Page 5: More native look and feel of mobile JS applications with HTML5 canvas

Why canvas?

One DOM interface - unlimited number of objects, so much more easier to render.

Page 6: More native look and feel of mobile JS applications with HTML5 canvas

Why canvas?

Using canvas for UI components rendering is very close to event delegation - you delegate not only events but rendering as well.

Page 7: More native look and feel of mobile JS applications with HTML5 canvas

Cases

Page 10: More native look and feel of mobile JS applications with HTML5 canvas

Typical cases

For example - you`ll need to draw timelines like this with DOM. How many DIVs will you need?

Page 11: More native look and feel of mobile JS applications with HTML5 canvas

Your case?

Page 12: More native look and feel of mobile JS applications with HTML5 canvas

Anti-cases

Page 13: More native look and feel of mobile JS applications with HTML5 canvas

AnticasesSmall amount of objects without transforms or transitions / animations are enought.

Page 14: More native look and feel of mobile JS applications with HTML5 canvas

Anticases

Your objects have to include content with advanced layout.

Page 15: More native look and feel of mobile JS applications with HTML5 canvas

And much more...

CANVAS is not a silver bullet for HTML perfomance...

Page 16: More native look and feel of mobile JS applications with HTML5 canvas

Big canvas - bad canvas?

Page 17: More native look and feel of mobile JS applications with HTML5 canvas

Frameworks

Probably you`ll need easy to use interfaces for sprites, animations, scales, nested objects and much more, but HTML5 canvas API is too low level thing - you`d better to use frameworks.

Page 18: More native look and feel of mobile JS applications with HTML5 canvas

Canvas UI development issues

Because of previous issue - you`ll need batch assets resizing for different screen sizes.

Page 19: More native look and feel of mobile JS applications with HTML5 canvas

Canvas UI development issuesUsing large universal engines seems to be wrong way sometimes.

There is space for your own wheel.

Page 20: More native look and feel of mobile JS applications with HTML5 canvas

Questions?

Page 21: More native look and feel of mobile JS applications with HTML5 canvas

Thanks =)

Denis RadinPixelsCommander.com

Special thanks to FlashJS engine - www.flashjs.com