Solved

Jquery flip animation or fade animation help

Posted on 2014-03-03
7
580 Views
Last Modified: 2014-04-01
Need help with jquery! I have six boxes developed with css and I would like to have a fade or flip animation that could then reveal additional content. Currently boxes are done in css, but not sure if need to be images to be able to have animation. My knowledge of jquery is minimal, so I would appreciate any help provided.

Example page and code can be founds here, http://www.pdesignz.com

Thanks
0
Comment
Question by:Pdesignz
[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
  • 4
  • 3
7 Comments
 
LVL 57

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39902733
One of doing the fade is to have the div like so
    <li class="emotion">
      <div class="first">
        <img src="http://www.pdesignz.com/Images/emotion-icon.png">
        <h2>Emotional Involvement and a Positive Mental Attitude</h2>
      </div>
      <div class="second">
        <p>New content and the rest goes here blah blah blah. The rain in spain falls mainly on the empire state building is in New York City of the Ancients is featured on what famous TV is bad for you so don't watch it or you will trip over your own shoes were made for walking and that is what they do</p>
      </div>
    </li>

Open in new window

Then  JQuery
<script type="text/javascript">
$(function() {
  $('#value-boxes li').click(function() {
    $(this).find('div.first').fadeToggle(500);
    $(this).find('div.second').fadeToggle(500);
  });
});
</script>

Open in new window

Finally CSS
#value-boxes li {
  ...
  color: white;  /* ADD THIS */
}
.second {
  display: none;
  color: white;
}
#value-boxes li div {
  position: absolute;
  left: 0;
  top: 0;
}

Open in new window

Full listing attached

Working sample here
t579.html
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39902741
Explanation of previous post.

We put the two different views in their own div's which are then positioned absolutely within their container (the <li>). We do this because we want fading in while the other is fading out and if they are not absolutely positioned then they are going to push each other down as they each are in transition.

We then use the toggleFade function on each of the div's in the <li> to change state from one to the other.
0
 

Author Comment

by:Pdesignz
ID: 39902991
Looks great in example, I implemented but when I toggle the fade it appears below the box for a split second and then jumps up. I am not sure if I missed something or not.

http://www.pdesignz.com

Thanks
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39903003
Yup - that is why I made the content div's position: absolute; When I posted the updated styles I made an error and edited the wrong style. Style posting should have looked like this
#value-boxes li {
  ...
  position: relative; /* ADD THIS */
}
.second {
  display: none;
  color: white;
}
#value-boxes li div {
  position: absolute;
  left: 0;
  top: 0;
}

Open in new window

The reason it is jumping is because the container div's are effectively one below the other with the inactive one hidden. When the toggleFade fires both become visible as they transition, but because they are both position: relative the one appears below the other until the top one fades out at which point the bottom one jumps up.

By making the boxes position absolute it means that both boxes are positioned relative to the top left corner of the <li> container and as they each transition from hidden to visible and vice versa they maintain their positions relative to the parent <li> giving the impression of fading from one to the other.

You probably just need to add the position: relative to the #value-boxes li style (remove the color: white - that was an error.
0
 

Author Comment

by:Pdesignz
ID: 39903010
OK, I missed the absolute...if I wanted to try a flip animation instead of a fade, how would I go about doing that?

Thanks
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39903836
You can do a CSS flip using the technique described here

http://davidwalsh.name/css-flip

Might not work on older browsers espectially IE

Here is a list of some Flip libraries that you could also look at.

http://www.jqueryrain.com/2012/08/jquery-flip-effect-plugin-examples/

Post back if you get stuck.
0
 

Author Closing Comment

by:Pdesignz
ID: 39970256
Great Work! Thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

724 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