Solved

Smooth Jquery Transitions

Posted on 2011-03-23
26
770 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
  • 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now