A Pen by Robert Annett on CodePen.
Created
November 13, 2017 21:26
-
-
Save anonymous/e957ead41be27aabecbe60a4fe8ae3ee to your computer and use it in GitHub Desktop.
Zurb Video Modal - Autoplay on open & Pause on Close
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="body text-center"> | |
<div class="reveal" id="exampleModal1" data-reveal> | |
<video width="100%" controls> | |
<source src="http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4" type="video/mp4"> | |
Your browser does not support HTML5 video. | |
</video> | |
<button class="close-button" data-close aria-label="Close modal" type="button"> | |
<span aria-hidden="true">×</span> | |
</button> | |
</div> | |
<p><button class="button" data-open="exampleModal1">Click me for a modal</button></p> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('[data-reveal]').on('open.zf.reveal', function() { | |
$('#' + $(this).attr('id')).find('video').get(0).play(); | |
}); | |
$('[data-reveal]').on('closed.zf.reveal', function() { | |
$('#' + $(this).attr('id')).find('video').get(0).pause(); | |
}); | |
$(document).foundation(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.4.3/js/foundation.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.4.3/js/plugins/foundation.reveal.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
padding-top:50px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.4.3/css/foundation.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment