Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


		<div class="videoArea">
			<video id="vid" playsinline muted controls>
<!-- 				<source src="" type="video/mp4" /> -->
				<source src="" type="video/mp4" />
<!-- 				<source src="" type="video/ogg" /> -->
			<div class="text-overlay">This text</div>
			<div class="text-overlay">will remain</div>
			<div class="text-overlay">scynced to the video</div>
			<div class="text-overlay">no matter</div>
			<div class="text-overlay">what</div>


                html, body {
	padding: 0;
	margin: 0;

main {
	display: flex;
	width: 100vw;
	min-height: 100vh;
	align-items: center;
	justify-content: space-around

section {
	text-align: center;

.videoArea {
	position: relative;
	display: inline-block;

video {
	max-width: 400px;

.text-overlay {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	text-shadow: 1px 1px 2px black;
	color: orange;
	text-transform: uppercase;
	font-size: 2rem;


                var syncGSAPwVideo = function(timeline, opts) {
	var _opts = opts || {};
	var _readyToPlay = false;
	var vid = document.querySelector(_opts.holder || 'video');
	// Have we got a video element?
	if(!vid) throw 'No <video> element present';
	// Have we got a timeline to work with?
	if(!timeline) throw 'No GSAP timeline provided';
	var _tl = timeline;
	_tl.pause(); // Pause it immediately to sync with the video
	/* Video event listeners */
	vid.addEventListener('playing', _playing);
	vid.addEventListener('waiting', _waiting);
	vid.addEventListener('pause', _waiting);
	vid.addEventListener('ended', _ended);

	/* Video events */
	function _waiting() {

	function _playing() {
		console.log( 'playing', vid.currentTime)
		if(_readyToPlay) {		
		} else {
			// Firefox does not seem to fire the 'loadedmetadata' event so, we wait for the first call to playing dispatched from the video element
			_readyToPlay = true;			
	function _ended() {
		console.log('video ended', new Date().getMilliseconds())

	// Return the video object so it can be easily controlled
	return vid;

// Create one timeline for your overlay animation
var overlayTl = new TimelineLite({
	// paused: true,
	onComplete: function(){
		console.log('timeline complete', new Date().getMilliseconds())
});'.text-overlay', 1, {y:"+=100"})'.text-overlay', 1, {rotation:"+=360"})'.text-overlay', 1, {y:"-=50"})
overlayTl.add(TweenMax.staggerFrom('.text-overlay', 0.1, {
}, 1.1), 0)

var mySyncedTl = syncGSAPwVideo(overlayTl);

// Because we return the video object in syncGSAPwVideo we have access to all methods and properties of it.
mySyncedTl.addEventListener('ended', ended);

// No real use, only to test that the timeline and the video complete next to each other
function ended() {
	console.log("external", new Date().getMilliseconds())
	mySyncedTl.currentTime = 0