i am trying to move a sticker when user will stop scrolling.
i have put my sticker at right top position, and i want if user has scrolled the window then it will show scrolling with the window but when user stopped scrolling, i want that sticker to be it on its real position,(right top corner).
i'm not getting any idea how to do this.
here is what i have tried so far.
$(document).ready(function() {
var sticker = $("#sticker");
var pos = sticker.position();
$(window).scroll(function(e) {
var s = $(this).scrollTop(),
d = $(document).height(),
c = $(this).height();
scrollPercent = (s / (d - c));
var position = (scrollPercent * ($(document).height() - sticker.height()));
sticker.css({
'top': position
});
});
});
Please help.
[EDITED]
I'm really sorry about that. i didn't clearly mention my question. I want my sticker to scroll with the body content but after stopping scrolling it should be go up/down with some sliding effect to the top right corner. and i dont want to fix sticker at scrolling time or at last. I have search around but didn't get anything use full.
May be it could be done by other way like using some sticker plugins or some tricks. So could somebody please give me some hints or any trick to do so.
Thanks.