Skip to content

Instantly share code, notes, and snippets.

@lpand

lpand/resizer.js

Created Oct 1, 2013
Embed
What would you like to do?
function resizeHandler () {
if (this._svg && !this._svg.empty()) {
this._svg.attr({
width: $(window).width()
height: $(window).height()
})
}
}
function resize (listener, interval) {
var resizeTimeout
window.addEventListener('resize', function() {
if (! resizeTimeout) {
resizeTimeout = setTimeout(function() {
resizeTimeout = null
listener.apply(null, arguments)
}, interval || 66)
}
})
}
resize(resizeHandler.bind(this))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.