Skip to content

Instantly share code, notes, and snippets.

@msenkpiel
Created February 20, 2014 15:01
Show Gist options
  • Save msenkpiel/9115604 to your computer and use it in GitHub Desktop.
Save msenkpiel/9115604 to your computer and use it in GitHub Desktop.
responsive helper
App.responsive = {
breakpoints: [
{
name:'xs',
width: 641
}
],
addWatcher:function(){
var scope = this;
$(window).on('resize', function(e) {
scope.watcher();
});
},
watcher:function(){
var w = $(window).width();
var target = $('.resp-target');
_.each(_.pluck(this.breakpoints, 'name'), function(val){
target.removeClass(val);
});
for(var i = 0, len = this.breakpoints.length; i < len; i++){
var obj = this.breakpoints[i];
if(w < obj.width){
target.addClass(obj.name);
return;
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment