Skip to content

Instantly share code, notes, and snippets.

View robpataki's full-sized avatar

Rob Pataki robpataki

  • Valtech
  • York UK
View GitHub Profile
@robpataki
robpataki / imageload.js
Created December 27, 2014 15:32
jQuery image load handling
var img = new Image();
$(img).on('load', function(e){
// Your code here
}).each(function() {
if(this.complete) $(this).load();
});
img.src = "http://dummyimage.com/600x400";
@robpataki
robpataki / resizeVideo.js
Created November 25, 2014 18:57
This script will always make sure that the video is covering the browser window and it is centred, whilst the aspect ratio is maintained.
function resizeVideo() {
var videoEl = document.getElementsByTagName('video')[0];
var videoOriginalWidth = 854;
var videoOriginalHeight = 480;
var videoRatio = videoOriginalWidth/videoOriginalHeight;
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var videoWidth;
var videoHeight;
var videoDimensionMultiplier = 1.1;