Skip to content

Instantly share code, notes, and snippets.

View parrfolio's full-sized avatar
My God, It's Full of Stars

Ryan Parr parrfolio

My God, It's Full of Stars
View GitHub Profile
@parrfolio
parrfolio / find-in-json.js
Created January 9, 2016 16:43 — forked from iwek/find-in-json.js
Searching through JSON
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
@parrfolio
parrfolio / css_media_queriesv2
Created November 12, 2012 17:00
CSS Media Queries v2
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-width : 320px)
and (max-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
/* Styles */
@parrfolio
parrfolio / touch_resize_rotate
Created October 22, 2012 04:10
Touch Resizing and Rotating
var width = 100,
height = 200,
rotation = 0;
node.addEventListener("gesturechange", function(event){
var style = event.target.style;
// scale and rotation are relative values,
// so we wait to change our variables until the gesture ends
style.width = (width * event.scale) + "px";
style.height = (height * event.scale) + "px";
@parrfolio
parrfolio / touch_drag_drop
Created October 22, 2012 04:09
Basic Touch Drag and Drop
node.addEventListener("touchmove", function(event){
// Only deal with one finger
if(event.touches.length == 1){
// Get the information for finger #1
var touch = event.touches[0],
// Find the style object for the node the drag started from
style = touch.target.style;
// Position the element under the touch point
style.position = "absolute";
style.left = touch.pageX + "px";
@parrfolio
parrfolio / box-decoration-break
Created October 14, 2012 20:20
Box Decoration Break
box-decoration-break: slice | clone;
Info: http://css-infos.net/property/box-decoration-break
@parrfolio
parrfolio / classList
Created October 14, 2012 19:53
ClassList
{
length: {number}, /* # of class on this element */
add: function() { [native code] },
contains: function() { [native code] },
item: function() { [native code] }, /* by index */
remove: function() { [native code] },
toggle: function() { [native code] }
}
@parrfolio
parrfolio / mult-line-ellipsis
Created August 23, 2012 20:14
Mult-Line Ellipsis
.giveMeEllipsis {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2; /* number of lines to show */
-webkit-box-orient: vertical;
}
@parrfolio
parrfolio / slideshow.html
Created June 24, 2012 23:11 — forked from kara-ryli/slideshow.html
A Webkit-only version of Jonathon Snook's "Simplest jQuery Slideshow" that meets his requirements (concise, less than 20 lines) without requiring jQuery.
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Simplest jQuery Slideshow</title>
<style>
body { font-family:Arial, Helvetica, sans-serif; font-size:12px; }
.fadein { position:relative; height:332px; width:500px; }
.fadein img { position:absolute; left:0; top:0;}
.fadein.ready img { -webkit-transition: opacity 1s linear;}
</style>
@parrfolio
parrfolio / optimize_animations
Created May 24, 2012 03:43
Optimize iOS Animations
/*Set these on animated elements for iPad and iPhone to possibly optimize*/
#foo {
-webkit-transform: translate3d(x,y,z); /* hardware acceleration */
-webkit-perspective: 0; /*prevent flickering */
-webkit-backface-visibility: hidden; /*prevent backgrounds showing through */
}