Making a Seating Scheme for a Cinema in React: About Canvas, Beautiful Design and Optimization

The rich Tinkoff ecosystem has lifestyle services. You can buy tickets for various events - cinema, theaters, concerts, sports events at https://www.tinkoff.ru/entertainment/ , as well as in the mobile application.





My name is Vadim and I will tell you how we did it in the Entertainment team at Tinkoff Bank.






What do you need to buy a movie ticket?

When you have decided on a movie and a cinema, you need to choose a seat in the cinema - study the beautiful seating scheme and buy the best tickets.





seating scheme design
seating scheme design

We came up with three options for implementing such a scheme.





1. Do everything in good old HTML

HTML diagram.  Found on the Internet
HTML diagram. Found on the Internet

Pros:





  • Convenient to style.





  • It is convenient to work in React.





  • Everything is available (A11Y).





Minuses:





  • The number of DOM nodes and the depth of the DOM tree grows (example - in the image above).





  • Performance issues with user interaction (schema movement).





2. Use SVG

The pros and cons are about the same as with HTML.





I managed to find only the metro map on SVG
SVG

3. Canvas

Stylish.  Bright.  Productive.
. . .

:





  • ( ).





  • .





:





  • Server Side Rendering.





  • A11Y ( ยซ ยป).





canvas, , UX . DOM- . canvas Internet Explorer 11.





, , canvas , SVG- HTML-.





canvas

, canvas. , , โ€” Konva, PixiJS, Fabric.js Phaser.





PixiJS. Pixi: , . .





PixiJS. Pixi.App



(, , , , ). (Stage Pixi), 5 ร— 5 , โ€” Pixi









, . - , .





, 100 , , , .





React

: React?





. , . 





, , โ€” react-pixi-fiber. , JSX, Pixi canvas. 





Pixi. , Pixi.Text



react- <Text />







โ€” CustomPIXIComponent







. Pixi, JSX: Stage, Container, , react-.









. react-, , , . graphics props. , , .









?





. โ€” , : , , .





โ€” , .





. : , โ€” .





: retina- . SVG PixiJS: SVG.





.





PixiJS

:









A โ€” .

B โ€” .

C โ€” .

D โ€” .

E โ€” .

F โ€” .

G โ€” . 



โ€” width / 22. 

โ€” height / 16.

22 16, , โ€” .





: , . , PixiJS CustomPIXIComponent.





โ€” , , , , .



: , !









, ยซยป, , , , โ€” . .





.

sectors , , hallScheme, 236 .









  , SVG base64.









?

SVG - PixiJS.





โ€” HTML, .





, โ€” SVG react-. 





html-react-parser. HTML react-. Node.js, . , .





parseHtmlToReact



, .









JSX , : , .





This is how VTB Arena looks now.
.

, 20%, 80โ€”90%. , .





, , 16 . Ticker_tick







Pixi . , , - , โ€” 16 .





16 ?

ยซ60 ยป - , . , 60 , .





, 60 : 1000 รท 60 = 16,6666 .





Pixi.Ticker



60 canvas, . . , .





Pixi, .





Source code for the Stage component from react-pixi-fiber
Stage react-pixi-fiber

, Pixi Stage react-pixi-library. , react-pixi-library Ticker .









sharedTicker



Pixi. , pixi- Ticker. Ticker .





Ticker . react-, props .





, , . canvas , .





, , Pixi Github wiki, :





  • Gotchas





  • C









, Pixi wiki .





, Pixi.Graphics , , . , , Pixi.Graphics.









  1. โ€” .





  2. canvas .





  3. Pixi , .





  4. . , - .












All Articles