piling.js icon indicating copy to clipboard operation
piling.js copied to clipboard

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

Open flekschas opened this issue 5 years ago • 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

flekschas avatar Apr 29 '20 17:04 flekschas

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?

eeeeenchanted avatar May 01 '20 08:05 eeeeenchanted

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.

flekschas avatar May 01 '20 14:05 flekschas

  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

eeeeenchanted avatar May 02 '20 02:05 eeeeenchanted