Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Smooth Jquery Transitions

Posted on 2011-03-23
26
Medium Priority
?
776 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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 2000 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 2000 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

721 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