Created
September 11, 2012 13:51
-
-
Save laustdeleuran/3698641 to your computer and use it in GitHub Desktop.
Resize repaint pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var $content = $site.find('.site-content'), | |
lastSeenHeight = -1, | |
lastSeenWidth = -1, | |
lastSeenContentHeight = -1, | |
$win = $(window); | |
$win.smartresize(function(){ | |
var winHeight = $win.height(), | |
winWidth = $win.width(); | |
// Avoid unecessary repaints if no real change has occured to window size | |
if (winHeight === lastSeenHeight && winWidth === lastSeenWidth) return; | |
lastSeenHeightlastSeenWidth = winWidth; | |
lastSeenHeight = winHeight; | |
// Avoid unecessary repaints if no real change has occured to content size | |
var newContentHeight = $content.outerHeight(); | |
if (lastSeenContentHeight === newContentHeight) return; | |
lastSeenContentHeight = newContentHeight; | |
// Now do changes | |
$content.css('background','#f0f'); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment