Div follow pages as user scrolls

Not sure why this code would not work


            var $body = $('body');
            var $outer = $('#content');
            var $follow = $('#follow');
            var followHt = $follow.height();
            var minY = $outer.offset().top;
            var maxY = minY + $outer.height() - followHt;
                var yoff = $(#follow).scrollTop();
                if (yoff > maxY) {
                    yoff = maxY;
                else if (yoff < minY) {
                    yoff = minY;
                $follow.css('top', yoff);
            $follow.css('top', minY);

& have a inside <div id="content" class="site-content">
this smaller div

```<div id="follow" class="follow" >follow you</div>```

follow is positioned absolutely, content has height of 100%.
as i scroll down follow should do that. follow. but it doesn’t

better yet…trying to rewrite the code starting with this, if the horizonatal scroll top is less than 200px for exmpale. the follow div should not display. but if it goes below that it display.

	var follow = $("#follow");
	var windowHeight = $(window).height();

	function scroll(){
		if(window.height =< 200){

never mind. solved.
used a fixed position in css and jquery to bring user back to top if needed.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.