Note that there are some explanatory texts on larger screens.

plurals
  1. POSave the vertical position of a div between pages, then animate to a new position?
    primarykey
    data
    text
    <p>I am using <a href="http://code.google.com/p/sticky-panel/" rel="nofollow" title="Sticky Panel">Sticky Panel</a> to position a div on the homepage so that it scrolls with the page from about halfway down to stick 100px from the top of the page.</p> <p>On the rest of my site the div is already in a fixed position 100px from the top of the page. If somebody navigates from the homepage to any other page without having first scrolled the homepage, the div jumps to the 100px position. </p> <p>I would like to save the vertical position of the div (possibly in a cookie?) and transfer that to the new page, then have the div animate to the 100px position.</p> <p>Any help much appreciated</p> <p>UPDATE:</p> <p>I found some code for use with the jquery cookie plugin which I think could be adapted:</p> <pre><code>$(document).ready(function(){ // does cookie exist? if ($.cookie('menu_position')) { var coords = $.cookie('menu_position').split(','); } else { var coords = [100,100]; // default top and left } $('.menu').css({top:coords[0],left:coords[1]}); }); </code></pre> <p>Then, on the drag stop event of your draggable, set the cookie value with </p> <pre><code>$.cookie('menu_position',$('.menu').css('top')+','+$('.menu').css('left')); </code></pre> <p>Can I get away with simply setting the top position? Because the left position will vary depending on the first time visitors screen resolution won't it? Also I assume cookie should be set on the homepage unload event, read on every other page and deleted at the end of the session? So if someone lands on the about page goes to the homepage nothing happens. I think my logic works :-)</p> <p>Then just need to get it to animate! Phew</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload