Created
February 20, 2014 15:01
-
-
Save msenkpiel/9115604 to your computer and use it in GitHub Desktop.
responsive helper
This file contains hidden or 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
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