Skip to content

Instantly share code, notes, and snippets.

View chriswrightdesign's full-sized avatar

Chris Wright chriswrightdesign

View GitHub Profile
@chriswrightdesign
chriswrightdesign / nullHack.scss
Created November 20, 2013 02:27
The null "go faster hack". This also can fix some problems with flickering on webkit browsers during an animation. See http://aerotwist.com/blog/on-translate3d-and-layer-creation-hacks/
-webkit-transform: translateZ(0);
//or
-webkit-translate3d(0, 0, 0);
@chriswrightdesign
chriswrightdesign / sassforloop.scss
Created November 20, 2013 02:39
Sass for loop example with nth-of-child animation
@for $i from 1 throught 6 {
.box:nth-of-type(#{$i}) {
-webkit-animation-delay: $i * 0.25s;
-moz-animation-delay:$i * 0.25s;
animation-delay:$i * 0.25s;
}
}
@chriswrightdesign
chriswrightdesign / ie8Events.js
Created November 20, 2013 23:47
Polyfill for IE8 Javascript Event Listeners
(function() {
if (!Event.prototype.preventDefault) {
Event.prototype.preventDefault=function() {
this.returnValue=false;
};
}
if (!Event.prototype.stopPropagation) {
Event.prototype.stopPropagation=function() {
this.cancelBubble=true;
};
@chriswrightdesign
chriswrightdesign / mobilecheck.js
Created December 14, 2013 03:48
Mobile check returns boolean Feature detection is better, but sometimes this is useful
// http://coveroverflow.com/a/11381730/989439
function mobilecheck() {
var check = false;
(function(a){if(/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|i
@chriswrightdesign
chriswrightdesign / arrayJS
Created January 7, 2014 21:45
Cached array length javascript for better performance
for (i = 0, len = arr.length; i < len; i++) {
//Calculated once
}
@chriswrightdesign
chriswrightdesign / 3rdpartyasync
Created January 8, 2014 02:51
Loading 3rd party content asynchronously (from http://browserdiet.com/)
var script = document.createElement('script'),
scripts = document.getElementsByTagName('script')[0];
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@chriswrightdesign
chriswrightdesign / ajax.js
Created January 18, 2014 03:50
Ajax sans jQuery (i think the last time I did this was 2006 or 2007) source: www.aaron-powell.com/posts/2013-08-02-ajax-without-jquery.html
//instance
var xhr = new XMLHttpRequest();
//open the request with method
xhr.open('get', '/foo');
//dom events- load, progress, error
//progress listen for and inform user of status if it takes a long time
xhr.addEventListener('load', function(e) {
//handle success
}, false);
xhr.send(); // sends the request
<!doctype html>
<html>
<head>
<title>Number Test</title>
<style>
tr {
background: #ddd;
}
tr:nth-child(odd) {
@chriswrightdesign
chriswrightdesign / ios8nozoom
Created March 4, 2015 11:35
Disable form field auto zoom on ios8 devices
select:focus,
textarea:focus,
input:focus,
select:hover,
input:hover,
option:hover,
option:focus,
select:focus option,
select:hover option {
font-size: 1em;
Script to build URLs
https://github.com/cgiffard/node-simplecrawler
Script to build CSS selector file
https://github.com/caplin/SuperSelector
http://selectorgadget.com/
Script to convert :hover, :focus, etc to .hover, .focus etc
https://github.com/jacobrask/styledocco/blob/master/share/previews.js
Apply for any selectors that match