Skip to content

Instantly share code, notes, and snippets.

@brianpkelley
brianpkelley / watch.js
Created April 10, 2017 15:57
Kill livereload servers on Gulp run
/**
Credit to https://danisadesigner.com/blog/killing-livereload-server/ for the initial command (and a handy bash script)
*/
const gulp = require('gulp');
const exec = require('child_process').exec;
const livereload = require('gulp-livereload');
// YOUR INCLUDES HERE!
@brianpkelley
brianpkelley / PinchZoomPan.js
Last active December 3, 2019 09:11 — forked from iammerrick/PinchZoomPan.js
React Pinch + Zoom + Pan with mouse support
import React from 'react';
const MIN_SCALE = 0.75;
const MAX_SCALE = 2;
const SETTLE_RANGE = 0.001;
const ADDITIONAL_LIMIT = 0.2;
const DOUBLE_TAP_THRESHOLD = 300;
const ANIMATION_SPEED = 0.04;
const RESET_ANIMATION_SPEED = 0.08;
const INITIAL_X = 0;
@brianpkelley
brianpkelley / ngTouchEvents
Created March 20, 2015 15:25
Angular Touch Events. Replicated angular event directives adapted for touch events.
// Direct copy + paste of angular event directives adapted for touch events.
'use strict';
var prefix = 'ng';
var tbTouch = angular.module(prefix+'TouchEvents',[]);
angular.forEach(
'touchstart touchmove touchend'.split(' '),
function(eventName) {
var directiveName = prefix+eventName[0].toUpperCase()+eventName.substr(1);
tbTouch.directive(directiveName, ['$parse', '$rootScope', function($parse, $rootScope) {
return {
@brianpkelley
brianpkelley / textTrackLoading
Created July 18, 2014 15:48
Unloading and loading of Video.js text tracks while updating their menuButton
(function() {
'use strict';
videojs.Player.prototype.unloadTextTracks = function( kind ) {
var kinds = ['captions','subtitles','chapters','descriptions','metadata'];
var i;
var tracks = this.textTracks_ = this.textTracks_ || [];
// If no specific type is specified then clear them all
if ( !kind ) {