0

I am using Isotope to layout a grid of blocks using the 'masonryHorizontal' layout mode. On click the selected box expands and re-adjusts the layout. What I want is to scroll the window so the expanded box is centered in the window horizontally. I have this working so that it scrolls to the expanded box, but it's not centered horizontally.

In my click function, I have the following:

setTimeout(function() {
var itemPosition = $this.parent().data('isotope-item-position');
    $('#page').scrollTo({ top:itemPosition.y, left:itemPosition.x}, 500);
}, 800);

I know I have to adjust the itemPosition.x, but can't seem to calculate the correct center. Any help is appreciated.

Edit: Here is a screenshot to reference

Need to center the expanded block

downtomike
  • 94
  • 1
  • 11

0 Answers0