Permalink
Browse files

Merge pull request #6 from ajaswa/master

Reduced DOM manipulation by moving them outside loops.
  • Loading branch information...
2 parents c8e2e6c + 7a1e5b9 commit 9cad415411b377a9be0eebc730a0cb10dc90865b @dotjay committed May 15, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 hashgrid.js
View
10 hashgrid.js
@@ -110,10 +110,12 @@ var hashgrid = function(set) {
if (lineHeight <= 0) return true;
// Add the remaining grid lines
- var i, numGridLines = Math.floor(pageHeight / lineHeight);
+ var i, numGridLines = Math.floor(pageHeight / lineHeight),
+ gridLines = '';
for (i = numGridLines - 1; i >= 1; i--) {
- overlay.append('<div class="horiz"></div>');
+ gridLines += '<div class="horiz"></div>';
}
+ overlay.append(gridLines);
// vertical grid
overlay.append($('<div class="vert-container"></div>'));
@@ -124,9 +126,11 @@ var hashgrid = function(set) {
// 30 is an arbitrarily large number...
// can't calculate the margin width properly
+ var gridVert = '';
for (i = 0; i < 30; i++) {
- overlayVert.append('<div class="vert">&nbsp;</div>');
+ gridVert += '<div class="vert">&nbsp;</div>';
}
+ overlayVert.append(gridVert);
overlayVert.children()
.height(pageHeight)

0 comments on commit 9cad415

Please sign in to comment.