Skip to content

Instantly share code, notes, and snippets.

Created November 13, 2017 21:26
Show Gist options
  • Save anonymous/e957ead41be27aabecbe60a4fe8ae3ee to your computer and use it in GitHub Desktop.
Save anonymous/e957ead41be27aabecbe60a4fe8ae3ee to your computer and use it in GitHub Desktop.
Zurb Video Modal - Autoplay on open & Pause on Close
<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">&times;</span>
</button>
</div>
<p><button class="button" data-open="exampleModal1">Click me for a modal</button></p>
</div>
$('[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();
<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>
body {
padding-top:50px;
}
<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