Skip to content

Instantly share code, notes, and snippets.

View maxxcrawford's full-sized avatar

Maxx Crawford maxxcrawford

View GitHub Profile
@maxxcrawford
maxxcrawford / fixed-pos-cover.html
Last active August 29, 2015 14:03
Fixed Position / Cover Image Fix (Src: http://goo.gl/0wkXIk)
<div id="wrapper">
<div id="container"></div>
<p>Scroll Down</p>
</div>
<div id="content">
</div>
@maxxcrawford
maxxcrawford / randomize.js
Last active August 29, 2015 14:03
Randomize Child Elements
$.fn.randomize = function(selector, callback) {
var $elems = selector ? $(this).find(selector) : $(this).children(),
$parents = $elems.parent();
$parents.each(function() {
$(this).children(selector).sort(function() {
return Math.round(Math.random()) - 0.5;
// }). remove().appendTo(this); // 2014-05-24: Removed `random` but leaving for reference. See notes under 'ANOTHER EDIT'
}).detach().appendTo(this);
});
// ImageMagick - Convert SVG to PNG w/ transparency
//
// - open terminal
//
// - confirm you have imagemagick installed
// --- type: convert -v
//
// - cd to folder
//
// - single file
@maxxcrawford
maxxcrawford / placeholder-shim.js
Created April 14, 2014 21:37
Placeholder Shim (Modernizr Test)
/* global Modernizr */
(function (app, $, window, document, undefined) {
/* SHIM: <input> placeholder shim
--------------------------------------------------------------------------- */
if(!Modernizr.input.placeholder){
$(document).on('focus', 'input[placeholder], textarea[placeholder]', function() {
var input = $(this);
if (input.val() === input.attr('placeholder')) {
input.val('').removeClass('placeholder');
}
@maxxcrawford
maxxcrawford / sphere-scale.html
Created February 12, 2014 20:44
CSS Transform/Animation Scale Example ( http://jsfiddle.net/aNX9h )
<!doctype html>
<html>
<head>
<title>CSS animations: Example 1</title>
<style type="text/css">
body {
padding: 20px;
}
@maxxcrawford
maxxcrawford / newYear.js
Last active January 3, 2016 14:39
A simple JS snippet to automatically display the current year. This is primarily used for the copyright located in the footer.
document.write(new Date().getFullYear());
@maxxcrawford
maxxcrawford / unknownCentering-IE.css
Created January 17, 2014 17:25
An update to a method found on css-tricks.com to center items within each other without using table positioning. Source: http://css-tricks.com/centering-in-the-unknown/
.block:before {
border: none;
width: 0;
}
@maxxcrawford
maxxcrawford / ajaxCall.js
Created November 19, 2013 21:24
AJAX Call
var cache = {};
function getData( val ){
// Return a promise from the cache (if available)
// or create a new one (a jqXHR object) and store it in the cache.
var promise = cache[val];
if (!promise) {
promise = $.ajax('/foo/', {
data: { value: val },
@maxxcrawford
maxxcrawford / smoothScroll.js
Created November 14, 2013 23:25
Smooth animate/scroll to snippet
$(".scroll").click(function(event){
event.preventDefault();
//calculate destination place
var dest=0;
if($(this.hash).offset().top > $(document).height()-$(window).height()){
dest=$(document).height()-$(window).height();
}else{
dest=$(this.hash).offset().top;
}
//go to destination
@maxxcrawford
maxxcrawford / addEventListenerIE8.js
Last active December 21, 2015 23:09
addEventListener / IE8 Fix
if (!window.addEventListener) {
// DO NOTHING
//window.attachEvent("orientationchange", resizeColorBox);
}
else {
window.addEventListener("orientationchange", resizeColorBox, false);
}