[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Jquery flip animation or fade animation help

Posted on 2014-03-03
7
Medium Priority
?
612 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 59

Accepted Solution

by:
Julian Hansen earned 2000 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 59

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

 
LVL 59

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 59

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
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…

650 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