0

I'm a little abashed as to why this Sticky footer won't allow a slide toggle animation?

Is there a particular reason why this won't work properly?

#PopupMessage{
    width:95%;
    height:30px;
        background: #999;
    color: #ececec;
    position:fixed;
    bottom:0px; 
    margin:2%;
    padding:1%;
    border-radius:10px;
              -webkit-box-shadow: 0px 5px 5px rgba(0,0,0,.9);
              -moz-box-shadow: 0px 5px 5px rgba(0,0,0,.9);
                         box-shadow: 0px 5px 5px rgba(0,0,0,.9);
    transition: all 0.8s;
    display:none;
}

#PopupMessage:hover{
    opacity:0;
}

The hover effect works, yet for some reason the 'slideToggle' won't work in this context?

I also have an issue (not sure if it is project specific, since it doesn't happen on the fiddle) is that my footer disappears after a few seconds (as if i've double clicked, or similar).

Any suggestions as to why this is occuring?

jbutler483
  • 24,074
  • 9
  • 92
  • 145

4 Answers4

2

Change transition to :

transition: opacity 0.8s;

Because, .slideToggle() worked on display property and you hover css is working with opacity. So , for :hover just apply transition on opacity. It will not put effect on slideToggle().

Based on comment, where OP wants to use all for transition but not for display:

transition: all 0.8s, display: 0s;
Community
  • 1
  • 1
thecodeparadox
  • 86,271
  • 21
  • 138
  • 164
  • If, say, there was more than just a mere opacity change, could you do all 0.8s display / something similar? – jbutler483 Nov 21 '14 at 16:33
  • @jbutler483 you have describe properties you want to apply transition. http://stackoverflow.com/questions/9670075/css-transition-shorthand-with-multiple-properties – thecodeparadox Nov 21 '14 at 16:34
  • I feared that. I was using all simply for that fact it was saving me a lot of time writing out the same definition for color/etc – jbutler483 Nov 21 '14 at 16:37
  • @that last update doesn't seem to work unfortunately - the msgbox just 'disappears' completely on hover – jbutler483 Nov 21 '14 at 16:42
1

http://jsfiddle.net/5p4k1hmz/3/

Your transition: all 0.8s; is getting in the way.

Try using transition: opacity 0.8s; instead.

superUntitled
  • 22,351
  • 30
  • 83
  • 110
  • I suppose there's no way around having both a transitional hover effect AND jquery slidetoggle? – jbutler483 Nov 21 '14 at 16:30
  • See my update. Using 'all' is messing with jQuery's height animation. – superUntitled Nov 21 '14 at 16:33
  • If, say, there was more than just a mere opacity change, could you do all 0.8s display / something similar? i.e. set all transitions to .8seconds, all but not this display property – jbutler483 Nov 21 '14 at 16:34
0

You need to removed transition and it works, see Demo

You can also define the time taken in the slide toggle, see the documentation for more info Slide Toggle doc

     $('#openPopup').click(function () {
         $('#PopupMessage').slideToggle("slow", function () {
             // Animation complete.
         });
     });
#PopupMessage {
    width:95%;
    height:30px;
    background: #999;
    color: #ececec;
    position:fixed;
    bottom:0px;
    margin:2%;
    padding:1%;
    border-radius:10px;
    -webkit-box-shadow: 0px 5px 5px rgba(0, 0, 0, .9);
    -moz-box-shadow: 0px 5px 5px rgba(0, 0, 0, .9);
    box-shadow: 0px 5px 5px rgba(0, 0, 0, .9);
    display:none;
}
#PopupMessage:hover {
    opacity:0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<button id="openPopup">Press me to show popup</button>
<div id="PopupMessage">this will be popup message</div>
Tony_89
  • 797
  • 11
  • 39
0

Before to start:

toggle functions are deprecated in jQuery 2.1.0.

Anyway, the problem is that you have put in your CSS code:

transition: all 0.8s;

that makes a conflict with javascript animations. As you can see without this code, your script works perfectly:

http://jsfiddle.net/5p4k1hmz/5/

If you want more control of events you can use jQuery 1.7.2 and use the toggle function with slideUp() and slideDown() functions:

http://jsfiddle.net/5p4k1hmz/6/

If you want an hover effect with opacity: 0 here there is a sample:

http://jsfiddle.net/5p4k1hmz/8/

Davide Scanu
  • 64
  • 1
  • 1
  • 7