View Single Post
  #3  
Old 03-20-2012, 06:44 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Getting the mini-cart to follow you down the page.

Well as with most things, what at first appeared to be perfect, was not at all.

My JS needed some serious re-working in order to get IE to play nice, and I needed to change the functions to wait until the scrolling had stopped. Had to practically rewrite the code from scratch.

Here is the finished javascript:

var scrollTimer = -1;
function bodyScroll() {
if (scrollTimer != -1)
clearTimeout(scrollTimer);
scrollTimer = window.setTimeout("scrollFinished()", 500);
}
function scrollFinished() {

var currentPos = $(window).scrollTop() + 10;

if (currentPos>200){
var nowTop = (currentPos-120) + "px";
} else {
var nowTop = 0 + "px";
}

$("#right-bar").animate(
{ top: nowTop }, {
duration: 500,
easing: 'swing'
});

return false;
}
window.onscroll = bodyScroll;

Now it appears to be working in all browsers, and it is much less resource intensive. I still may be getting some lag issues if you sit on the page for a while, but I can't completely confirm that yet. Time for some sleep.

If you feel like testing it for me, the link again is: http://trainingpen.com/home.php?cat=105
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote