Solved

Smooth Jquery Transitions

Posted on 2011-03-23
26
772 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using jQuery to set a DIV attribute on page load 9 33
how can i make the array into an object? 4 33
asp.net mvc5 6 17
html Uncheck Checkbox 2 11
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

810 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