So, I'm trying to make one DIV move from the screen to the left, and then pre-set the DIV (offscreen) to shift to the right. This works pretty much, except for one: It pushes the old DIV to the bottom when it comes to life.
But they need to stay close to each other, as if you were viewing pages.
You will understand when you check this: http://gasmar.home.xs4all.nl/flits/index.html First click βAgendaβ and then βzakelijkβ, you will notice that the DIV, which should be shifted to the left, It should be beautifully animated, like the incoming DIV, but it falls to the bottom of the new DIV .. after that the right position occurs, but this is simply not so.
Here is my code:
//Preload DIV outside page: $(document).ready(function() { //preLoad 2 HTMLS: preLoad("agendaPage", "agenda.html"); preLoad("zakelijkPage", "zakelijk.html"); //preLoad Function function preLoad(page, file){ $('#preloadDIV').after('<DIV id="'+ page+ '">'+page+'</DIV>'); $('#'+ page +'').css( { //Load page DIV and hide it 1000px to the right 'marginLeft' : "1000px", }).load(''+file+' #'+page+'DIV').hide(); }; }); //Bind ClickEvent $('#zakelijk').bind('click', function(){ clickButton("zakelijk"); }); //Button function function clickButton(name) { fadeCurrentPageLeft(name); //Load Page renderPage(name); }; //Fade in new DIV function renderPage(name) { $('#' + name).unbind('click'); $('#'+name+'Page') .attr("id", 'currentPage') .animate( { 'marginLeft' : "-=1000px", 'position' : "absolute", }, {duration: 800, queue: false }, 'linear') .show(); //Set ID to current Page $('#'+name+'Page'); }; //Fade out old DIV function fadeCurrentPageLeft(name) { $('#currentPage') .animate( { 'marginLeft' : "-=1000px", }, {duration: 3000, queue: false }, 'linear') .hide("drop", {}, {duration: 3000, queue: false }) .attr("id", name+'Page'); };
I tried to do this with relative coordinates, but they just keep pushing each other away, even when the z-position is different for each DIV, it doesn't work.
Perhaps I need to preload the DIV differently? but I donβt know in what other way ...
(In addition, as a continuation, I would like the DIV to remain at the level at which they end (not all streams, as it is now), although I have most of the parameters in%, so when you resize windows, and proportionally)