I have the following situation... I have to draw a bunch of rectangles within a region of the viewport. The sizes of those rectangles (divs really) are based on some data.
The controller reaches out to the server, grabs the data, and sizes the divs based on the available space allocated to it in the viewport.
Roughly:
<div ng-init="main.init();">
<div ng-repeat="icon in main.icons"
style="top: {{icon.top}}px;
left: {{icon.left}}px;
width: {{icon.width}}px;
height: {{icon.height}}px;"></div>
</div>
The main.init() function reaches into the DOM using angular.element()
calls, gets the width and height of the available space and calls a service that does some complicated calculation (basically a packing algorithm to position & size) the rectangles in the best way possible given the area given.
My only problem is on screen resize. If the user resizes the screen, my available space (which is defined in %) also changes and I need to redraw those rectangles.
I am currently resorting to reloading the whole page on re-size of the window, but that's obviously not what I want.
One more thing... There are A LOT of those data points that translate into the rectangles: 10K-20K.
How do I do this properly in Angular so my window size causes them to be calculated and redrawn. Simply updating the main.icons
in the controller doesn't seem to trigger ng-repeat to redraw everything. Not sure why.
Any help would be appreciated.