Fix and then unfix div on scroll
<p>Using Scrollspy, I am trying to fix the contents of a div upon entering and then have it go back to relative. It works until you leave that div and the content reverts back to its original relative position. I am going for this <a href="http://jobs.powerof12.org/good/jobs" rel="nofollow">effect here</a>: </p>

<p>I am familiar with <a href="https://github.com/bigspotteddog/ScrollToFixed" rel="nofollow">ScrollToFixed</a> but am trying to make a more simple function -</p>

<p><a href="http://arch-lab.co/HousePlans/Internal/Infographic/New%20Layout/scroll_spy_infographic.html" rel="nofollow">With adding a new class upon exit I can get it to work, except when you re-enter the div it falls apart.</a></p>

<p>How do I make sure that it does not jump back up?</p>

<pre><code>$(document).scroll(function(){                 
    // grab the scroll amount and the window height
    var scrollAmount = $(window).scrollTop();
    var documentHeight = $(document).height();
    console.log(documentHeight);
    // calculate the percentage the user has scrolled down the page
    var scrollPercent = (scrollAmount / documentHeight);


    $('#segment-1').each(function(i) {
        var position = $(this).position();
        console.log(position);//why is it console logged?
        console.log('min: ' + position.top + ' / max: ' + parseInt(position.top + $(this).height()));//why is it console logged?
        $(this).scrollspy({
            min: position.top,
            max: position.top + $(this).height(),
            onEnter: function(element, position) {
                if(console) console.log('entering ' +  element.id);

                $('#test').removeClass("pre-absolute");
                $('#test').addClass("fixed");

                $(".arrow").css( {height: (scrollPercent  * 900) + 'px'});
                $(".house").css({bottom: (scrollPercent  * 1000) + 'px'});
            },
            onLeave: function(element, position) {
                $('#test').addClass("post-absolute");
                $('#test').removeClass("fixed");

            }
        });
    });
});
</code></pre>
