but only find scrolling solutions.
What I’m trying to do is move a circle across the screen using animate (left or right), then of course up / down, which I can do.
The issue is when I want the browser to scroll with the circle up / down if needed, in a nice smooth manner.
This is some simple quick dirty code I wrote just to mess around
$('#circle').animate({'left': (start)+'px'},'slow').fadeIn('slow', function(){
$(this).animate({'left': '+='+(stopRight)+'px'}, 2000, function(){
$(this).animate({'top': '+='+(downRight)+'px'}, 2000, function(){
$(this).animate({'left': '-='+(leftRight)+'px'}, 2000, function(){
});
});
});
});
Where / how would i make it scroll, Any suggestions tip, I plan on getting ride of the code I have below anyways.
This is a working solution, based on your animation sequence:
See this working Fiddle Example!
HTML
CSS normalized on the Fiddle, but not relevant
jQuery You will need the plug-in
.watch(), see link belowPlug-in used
jQuery CSS Property Monitoring Plug-in
What this does is to track the element movement and manipulate the scrollbars to keep it visible at all times.
The jQuery .scrollTop() Get the current vertical position of the scroll bar for the first element in the set of matched elements.
The jQuery .scrollLeft() Get the current horizontal position of the scroll bar for the first element in the set of matched elements.
The jQuery .offset() Get the current coordinates of the first element in the set of matched elements, relative to the document.