Solved

Smooth Jquery Transitions

Posted on 2011-03-23
26
775 Views
Last Modified: 2012-06-27
Hey Experts!!

I have this page here: http://rdsrc.us/vAOdbc 

The jquery transition is sloppy and it also is showing the first image for a second while the other one is loading.  I've tried a Jquery CSS image preloader.  However, I don't think it's working correctly.

How can I clean up the transitions as well as negate showing the 1st background image while another one is loading.  
0
Comment
Question by:LZ1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 12
26 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 35204335
you may embed each image in each page and use jquery tabs, for example : http://www.designchemical.com/blog/index.php/jquery/simple-tabs-with-ajax-and-jquery/


$.ajax({
    "url":toLoad,
    success:function(html) {
       $("#slide-container").empty().append(html);
    }
});

Open in new window

0
 
LVL 30

Author Comment

by:LZ1
ID: 35206722
Where can I put that inside of my current script?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35206798
Check section << 2. The jQuery Code >> you will see an ajax call. This is your version.

You put it inside $('#nav li a').click(function(){
the same way you did it with your load : $('#slide-container').load(toLoad)
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 30

Author Comment

by:LZ1
ID: 35214699
I implemented your code leakim. Would you be able to check for me that it's working correctly and that I've implemented the code correctly as well.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35215124
Not really. load and ajax is the same function in background, an ajax call. Currently you use it twice.
OK, forgot the previous code and link. I think you know how to put two div at the same position in the document.
The first one is visible, the second hidden. We load the content in the second div and once the content is fully loaded, we fadeOut/FadeIn

<div class="slide-container current">first one</div>
<div class="slide-container">second one</div>

Open in new window


$('#nav li a').click(function(e){
        e.preventDefault(); 
        var toLoad = $(this).attr('href')+' #slide-container';
        window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
        $(".slide-container:not(:visible)").load(toLoad, function() {
             $(".slide-container.current").fadeOut("slow", function() { $(this).removeClass("current"); });
             $(".slide-container").fadeIn("slow", function() { $(this).addClass("current"); });
        });
    });

Open in new window

0
 
LVL 30

Author Comment

by:LZ1
ID: 35216470
And that replaces the top of my current jquery code?  I'm sorry for the ignorance...I'm still trying to learn Jquery..
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35216979
Yes and remove the previous one, the csspreloader code too
Don't forget to add a new div with the same class
Change the class name of the parent div
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 500 total points
ID: 35217442
Check this :


LZ1.zip
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35217509
I removed the initial/default content to let you see clearly the two divs with the class slide-container
The second one is hidden, we load the content inside it and when the content (the page) is fully loaded, we fadeOut the "current" div and fadeIn the "hidden" one.
leakim971-436905.flv
0
 
LVL 30

Author Comment

by:LZ1
ID: 35218523
Very slick.  I like it alot leakim.  However, I do need that initial content on the page.  How can I get it back there?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35218552
Update with its filename ?

$(".slide-container:first").load("filename.html #slide-container");
0
 
LVL 30

Author Comment

by:LZ1
ID: 35219686
hhhhhhmmmmm.......doesn't seem to be working right.  If I click on "Financial Services" it's showing the home.html page.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35219792
>If I click on "Financial Services" it's showing the home.html page.

remove the useless old code and css, check my page in the archive
0
 
LVL 30

Author Comment

by:LZ1
ID: 35219839
I've now lost the highlighting of the menu above as well.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35219883
I have it on my side
0
 
LVL 30

Author Comment

by:LZ1
ID: 35219957
I unzipped your files and uploaded them here.  I've lost the highlighting of the current page on the menu

http://rdsrc.us/7Ev44e
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35220032
You don't have it like this (the video below) ?
Or I did not understood something ?
leakim971-437046.flv
0
 
LVL 30

Author Comment

by:LZ1
ID: 35220110
The hover works fine.  But when the user clicks, the menu li and a tags need to have the class "current" applied.  
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35220174
OK, check this :
LZ1v2.zip
0
 
LVL 30

Author Comment

by:LZ1
ID: 35220321
Close........I still need to have the <a> tag classed to current
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35220376
add this :
			$("a.current").removeClass("current");
			$(this).addClass("current");

Open in new window

after :
			$("#nav ul li").removeClass("current");
			$(this).parent().addClass("current");

Open in new window

0
 
LVL 30

Author Comment

by:LZ1
ID: 35220415
Perfect.  However, the first home.html page still doesn't load.....
0
 
LVL 82

Expert Comment

by:leakim971
ID: 35220505
what is the filename of the page ?
0
 
LVL 30

Author Comment

by:LZ1
ID: 35220507
home.html
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 500 total points
ID: 35220517
So put the following in $(document).ready(function() :

$(".slide-container:first").load("home.html #slide-container");

Open in new window

0
 
LVL 30

Author Closing Comment

by:LZ1
ID: 35220538
Thanks so much for sticking with me leakim!  I've opened up another question regarding jquery validation if your so inclined.  :)

Thanks again!
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question