Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there performance difference between -transform translate ans scroll

I am building a maps website like google maps. There will be tiles of images connected to each other. The map will be explored by dragging with mouse where after each drag, new images will be loaded. In order to have explore-by-dragging functionality, I have found two ways:

  1. calling scrolling functions to scroll to the right place in the map
  2. applying css-transform translate on the map so that right portion of the map comes into the displayed area.

The question is, is there a performance difference between the methods? (mainly in terms of rendering speed and dragging smoothness) Also, are there any other criteria to prefer one of the methods?

like image 994
ali gurbuz Avatar asked Nov 14 '22 10:11

ali gurbuz


1 Answers

Scrolling is better because CSS transforms can cause document re-flows, which are quite expensive.

See: http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/

like image 89
Diodeus - James MacFarlane Avatar answered Dec 18 '22 19:12

Diodeus - James MacFarlane