AngularJS Video player trim
Delaying the trim function to allow video frames to catch up
by kmturley
HTML
<div class="app" ng-app="app">
<player class="player"></player>
</div>
CSS
/*
* Player css
*/
body {
margin: 0;
}
.player .wide {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
}
.player .wide video {
background-color: #000;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/* line 2, slider.scss */
slider, [slider] {
display: inline-block;
position: relative;
height: 7px;
width: 100%;
margin: 25px 5px 25px 5px;
vertical-align: middle;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/* line 10, slider.scss */
slider div, [slider] div {
white-space: nowrap;
position: absolute;
}
/* line 14, slider.scss */
slider div.bar, [slider] div.bar {
width: 100%;
height: 100%;
border-radius: 7px;
background: #444;
overflow: hidden;
}
/* line 21, slider.scss */
slider div.bar .selection, [slider] div.bar .selection {
width: 0%;
height: 100%;
background: #13b6ff;
}
/* line 28, slider.scss */
slider div.handle, [slider] div.handle {
cursor: pointer;
width: 20px;
height: 20px;
top: -8px;
background-color: #fff;
border: 1px solid #000;
z-index: 2;
border-radius: 100%;
}
/* line 38, slider.scss */
slider div.handle:after, [slider] div.handle:after {
content: '';
background-color: #777;
width: 8px;
height: 8px;
position: absolute;
top: 6px;
left: 6px;
border-radius: 100%;
}
/* line 48, slider.scss */
slider div.handle:after:hover, [slider] div.handle:after:hover {
background-color: #000;
}
/* line 53, slider.scss */
slider div.handle.active:after, [slider] div.handle.active:after {
background-color: #f00;
}
/* line 58, slider.scss */
slider div.bubble, [slider] div.bubble {
display: none;
cursor: default;
top: -22px;
padding: 1px 3px 1px 3px;
font-size: 0.7em;
font-family: sans-serif;
}
/* line 66, slider.scss */
slider div.bubble.active, [slider] div.bubble.active {
display: inline-block;
}
/* line 70, slider.scss */
slider div.bubble.limit,...
JavaScript
// Generated by CoffeeScript 1.8.0
(function() {
var MODULE_NAME, SLIDER_TAG, angularize, contain, events, gap, halfWidth, hide, module, offset, offsetLeft, pixelize, qualifiedDirectiveDefinition, roundStep, show, sliderDirective, width;
MODULE_NAME = 'ui.slider';
SLIDER_TAG = 'slider';
angularize = function(element) {
return angular.element(element);
};
pixelize = function(position) {
return "" + position + "px";
};
hide = function(element) {
return element.css({
opacity: 0
});
};
show = function(element) {
return element.css({
opacity: 1
});
};
offset = function(element, position) {
return element.css({
left: position
});
};
halfWidth = function(element) {
return element[0].offsetWidth / 2;
};
offsetLeft = function(element) {
return element[0].offsetLeft;
};
width = function(element) {
return element[0].offsetWidth;
};
gap = function(element1, element2) {
return offsetLeft(element2) - offsetLeft(element1) - width(element1);
};
contain = function(value) {
if (isNaN(value)) {
return value;
}
return Math.min(Math.max(0, value), 100);
};
roundStep = function(value, precision, step, floor) {
var decimals, remainder, roundedValue, steppedValue;
if (floor == null) {
floor = 0;
}
if (step == null) {
step = 1 / Math.pow(10, precision);
}
remainder = (value - floor) % step;
steppedValue = remainder > (step / 2) ? value + step - remainder : value - remainder;
decimals = Math.pow(10, precision);
roundedValue = steppedValue * decimals / decimals;
return parseFloat(roundedValue.toFixed(precision));
};
events = {
mouse: {
start: 'mousedown',
move: 'mousemove',
end: 'mouseup'
},
touch: {
start: 'touchstart',
move: 'touchmove',
end: 'touchend'
}
};
sliderDirective = function($timeout) {
return {
restrict: 'E',
...