flekschas/piling.js

In pan&zoom mode, on resizing the window, the pile position doesn't update

flekschas opened this issue · 3 comments

I noticed that when we have the pan&zoom mode activated and resize the browser, the grid itself updates but not the pile position.

Note that in scroll mode, the position updates correctly.

Apr-29-2020 13-49-20

I'm wondering how to calculate the new position in pan&zoom mode? In scroll mode, I calculated the new position based on the grid. But in pan&zoom mode, does it requires the camera scaling or other camera properties?

Mhhh good point. Yes, it requires the camera scaling and translation. Can you remind me of the steps that we take right now? I think all we need to get things working is a method that unprojects the item position.

  1. Use the old layout and old pile position to calculate the old ij position (xy pos to ij pos)
  2. Use the old layout to calculate the grid cell index (ij pos to index pos)
  3. Use the new layout to calculate the new xy pos (index pos to xy pos)

You can look at https://github.com/flekschas/piling.js/blob/master/src/library.js#L909-L969