Q: Sticky navigation only if bigger than 960px I have a question about jquery. I'm trying to apply a sticky navigation only if the window size is bigger than 960px. So I need to check if there is a window resizing or a scrolling event... I can't figure it out...
May someone please help me fixing that stuff?
Here's the code I tried to adapt
$(function() {

    var sticky_navigation_offset_top = $('#nav').offset().top;

    var sticky_navigation = function(){
        var scroll_top = $(window).scrollTop(); // our current vertical position from the top

        if (scroll_top > sticky_navigation_offset_top) { 
            $('#nav').css({ 'position': 'fixed', 'top':0, 'left':0 });


        } else {
            $('#nav').css({ 'position': 'relative' }); 
        }   
    };

    sticky_navigation();

    $(window).resize(function() {
  if ($(window).width() > 960) {
        $(window).scroll(function() {
         sticky_navigation();
    });
  }
});
});


A: LIVE DEMO
function stickNav() { 
    var setPosition = $(window).width() > 960 ? 'fixed' : 'relative';
    $('#nav').css({position:setPosition, left:0, top:0});
}


$(function() {
    stickNav();  // Do it on DOM ready
});

$(window).resize(function() {
    stickNav();  // Do in on Resize
});

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Conditional_Operator

A: roXon is not taking the nav offset into consideration and the calculation has to be made on resize and on scroll too. 
Here's my solution: http://jsfiddle.net/victmo/SZV6m/
Im  using jquery's 1.8 on function: win.on('resize scroll', function(){...
Javascript
var minWidthToStick = 300;

var nav = $('#nav'); // caching nav
var offset = nav.offset().top; // getting offset
var win = $(window); // caching window

win.on('resize scroll', function(){
    if(
        win.width() >= minWidthToStick && 
        win.scrollTop() >= offset
    ){
        nav.css('position', 'fixed');
    }else{
        nav.css('position', 'relative');
    }
}).resize();

Don't forget to put that code inside your $(document).ready(function(){ ... }) function :)
