Solved

Jquery flip animation or fade animation help

Posted on 2014-03-03
7
570 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 56

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 56

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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 56

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 56

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

730 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