Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <!-- 

Date: 2015-18-07
Inline Video Player v0.0.1
Copyright 2015 Mike Newell
Released under the MIT license
https://tldrlegal.com/license/mit-license
http://iwearshorts.com/
https://github.com/newshorts/InlineVideo

because apple wont allow us web developers to choose if we want a video to play inline on the iphone
 
hit play a couple times, its kinda jenky

-->

<video controls width="300">
  <source src="https://www.w3schools.com/html/mov_bbb.mp4">
</video>
<canvas></canvas>
<button>Play</button>
              
            
!

CSS

              
                // ====================================
// Bar Graph
// ====================================
$graph-title-color: swatch(copy);
$graph-label-color: swatch(smallcta);
.graph-title {
	text-align: center;
	margin: 0 auto 0.5em;
	color: $graph-title-color;
}

.section-bargraph {
	@include viewport(small){
		margin: 0 auto;
		width: 90%;
	}
	.touch-nav {
		display: none;
	}
}

.graph-toggles {
	text-align: center;
	margin-bottom: 3em;

	@include viewport(small){
		margin-left: auto;
		margin-right: auto;
	}

	.graph-toggle {
		color: swatch(smallcta);
		border-bottom: 2px swatch(graphgray) solid;
		padding-bottom: 5px;
		transition: color 0.7s ease-in, border 0.085s linear;
		&.active {
			color: swatch(copy);
			border-bottom: 2px swatch(copy) solid;
			cursor: default;
			&:nth-of-type(1) {
				padding-right: 0px;
			}
			&:nth-of-type(2) {
				padding-left: 0px;
			}
		}
		&:hover {
			text-decoration: none;
		}
		&:nth-of-type(1) {
			padding-right: 25px;
		}
		&:nth-of-type(2) {
			padding-left: 25px;
			margin-left: -5px;
		}
	}
	// NOTE: keeping these styles until we know if the dot should be in or not
	.divider {
		display: none; // was inline-block
		text-align: center;
		width: 40px;
		@include viewport(medium){
			width: 20px;
		}
	}
}

.scrollsnap.touch {
	.section-bargraph {
		@include viewport(small){
			.touch-nav {
				display: block;
			}
		}
		.bargraph-panels {
			@include viewport(small){
				overflow: hidden;
				overflow-x: auto;
				-webkit-overflow-scrolling: touch;
				-webkit-scroll-snap-type: mandatory;
				-webkit-scroll-snap-destination: 0 0;
				-webkit-scroll-snap-points-x: repeat(100%);
			}
		}
		.graph-toggles {
			@include viewport(small){
				white-space: nowrap;
				width: 200%;
				height: 247px;
				z-index: 2;
				.graph-toggle {
					width: 50%;
					position: relative;
					white-space: nowrap;
					display: inline-block;
					pointer-events: none;
					color: swatch(graphgray);
				}
			}
		}
		.bar-graph-wrapper {
			@include viewport(small){
				pointer-events: none;
				margin: 0 auto 2em;
				top: -247px;
				height: 0;
			}
		}
		.divider {
			@include viewport(small){
				display: none;
			}
		}
	}
}

.bar-graph-wrapper {
	width: 730px;
	margin: 0 auto 1em;
	position: relative;
	@include viewport(medium){
		width: 536px;
	}
	@include viewport(small){
		width: 240px;
	}
	.bar-graph {
		width: 730px;
		height: 415px;
		margin: 0 45px;
		margin: 1em auto;
		overflow: hidden;
		position: relative;
		background-size: 100px 104px;
		border-bottom: 1px solid #cccccc;
		background-image: linear-gradient(to bottom, #cccccc 1px, transparent 1px);
		@include viewport(medium){
			width: 536px;
			height: 389px;
			margin: 0 auto;
			background-size: 100px 98px;
		}
		@include viewport(small){
			width: 240px;
			height: 183px;
			margin: 0 auto;
			background-size: 100px 46px;
		}
		.graph-data {
			opacity: 0;
		}
	}
	.bar {
		bottom: 0;
		width: 4px;
		height: 100%;
		position: relative;
		display: inline-block;
		margin: 0 17px 0 38px;
		background-color: #548c8c;
		transform: scale3d(1, 0, 1);
		background: linear-gradient(to top, #aae07e 0%, #548c8c);
		@include viewport(medium){
			margin: 0 9px 0 30px;
		}
		@include viewport(small){
			margin: 0 8px;
		}
	}
	.axis-labels {
		font-size: 13px;
		color: $graph-label-color;
		font-weight: 400;
		line-height: 8.05em;
		position: absolute;
		text-align: right;
		top: -4.4em;
		left: -5em;
		width: 60px;
		@include viewport(medium){
			line-height: 7.61em;
			top: -4.2em;
		}
		@include viewport(small){
			line-height: 3.61em;
			top: -2em;
		}
	}
	.y-labels {
		transition: transform 1s cubic-bezier(0.215, 0.61, 0.355, 1),
					opacity 1s cubic-bezier(0.215, 0.61, 0.355, 1);
		&.off {
			transform: translateY(20px);
			@include viewport(small){
				transform: translateY(10px);
			}
			opacity: 0;
		}
	}
	.x-labels {
		top: 0;
		left: 0;
		width: 730px;
		margin: 5px auto 0;
		text-align: center;
		position: relative;
		line-height: 1.2em;
		@include viewport(medium){
			width: 536px;
		}
		@include viewport(small){
			width: 280px;
			margin-left: -31px;
		}
		span {
			display: inline-block;
			text-align: center;
			font-weight: 400;
			color: $graph-label-color;
			width: 56px;
			margin: 0;
			em {
				font-style: normal;
				font-weight: 400;
				display: block;
			}
			@include viewport(medium){
				width: 40px;
			}
			@include viewport(small){
				&:nth-child(even){ display: none; }
				width: 37px;
			}
		}
	}
}

html {
	&.fallback {
		.graph-data {
			visibility: hidden;
		}
		.bar-graph-wrapper {
			.y-labels {
				&.off { visibility: hidden; }
			}
		}
	}
}

              
            
!

JS

              
                /*!
 * Inline Video Player v0.0.1
 * http://iwearshorts.com/
 *
 * Includes jQuery js
 * https://jquery.com/
 *
 * Copyright 2015 Mike Newell
 * Released under the MIT license
 * https://tldrlegal.com/license/mit-license
 *
 * Date: 2015-18-07
 * 
 * TODO: look for the webkit-playsinline playsinline attributes and replace videos on iphones with canvas
 * 
 */

var video = $('video')[0];
var canvas = $('canvas')[0];
var ctx = canvas.getContext('2d');
var lastTime = Date.now();
var animationFrame;
var framesPerSecond = 25;
function loop() {
    var time = Date.now();
    var elapsed = (time - lastTime) / 1000;

    // render
    if(elapsed >= ((1000/framesPerSecond)/1000)) {
        video.currentTime = video.currentTime + elapsed;
        $(canvas).width(video.videoWidth);
        $(canvas).height(video.videoHeight);
        ctx.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
        lastTime = time;
    }

    // if we are at the end of the video stop
    var currentTime = (Math.round(parseFloat(video.currentTime)*10000)/10000);
    var duration = (Math.round(parseFloat(video.duration)*10000)/10000);
    if(currentTime >= duration) {
        console.log('currentTime: ' + currentTime + ' duration: ' + video.duration);
        return;
    }

    animationFrame = requestAnimationFrame(loop);
}

$('button').on('click', function() {
  video.load();
  loop();
});
              
            
!
999px

Console