javascript - Ease Transition Effect For Dimming Screen When Video Is Played -
i have page set when user presses play on video dims background. when press pause turn off dimming effect. trying add ease transition effect it's little smoother when effect turned on , off. i'm not sure add transition css because i've don't far doesn't seem work.
html
<div id="overlay"></div> <div class="col-md-6"> <div id="introright"> <video poster="img/whoweare.jpg" preload="auto" controls> <source src="video/whoweare_hi.mp4" type='video/mp4; codecs="avc1.42e01e, mp4a.40.2"'> <source src="video/whoweare_hi.ogv" type='video/ogg; codecs="theora, vorbis"'> <source src="video/whoweare_hi.webm" type='video/webm; codecs="vp8, vorbis"'> </video> </div> <!-- end introright --> </div>
javascript
<script> $("video").on('play',function(){ $("#overlay").show(); }); $("video").on('pause',function(){ $("#overlay").hide(); }); $("video").on('ended',function(){ $("#overlay").hide(); }); </script>
css
#overlay { display:none; position:fixed; width:100%; height:100%; top:0; left:0; opacity:0.8; background-color: #282828; z-index: 20; transition: opacity .25s ease-in-out; -moz-transition: opacity .25s ease-in-out; -webkit-transition: opacity .25s ease-in-out; } video { width: 100% !important; height: auto !important; margin: 0 auto; margin-top: 50px; z-index: 999; position: relative; -webkit-box-shadow: 3px 3px 11px 0 rgba(50, 50, 50, 0.75); -moz-box-shadow: 3px 3px 11px 0 rgba(50, 50, 50, 0.75); box-shadow: 3px 3px 11px 0 rgba(50, 50, 50, 0.75); }
use fadein() instead of show(), , fadeout() instead of hide(). also, have remove display: none css , set default opacity 0.
this link might helpful.
Comments
Post a Comment