Skip to content

Instantly share code, notes, and snippets.

@jtangelder
jtangelder / inview.js
Last active August 29, 2015 13:59
inview.js
/**
* triggers a callback when an element gets into the viewport
* uses a little bit of jQuery. elements auto receive the class `inview`
*
* the threshold parameter is on scale from 0 to 1 of the height.
* 0 means it triggers directly, 1 means it must be full visible
*
* @example
* // images needs to be 50% in view
* inview.register("img", .5, function(item, inview_state) {
@jtangelder
jtangelder / slideshow.scss
Last active August 29, 2015 13:59
slideshow.css
/**
* @example
* div.slideshow
* div first pane
* div.active active pane
* div last pane
*/
.slideshow {
position: relative;
overflow: hidden;
var IE = (function() {
if (document.documentMode) {
return document.documentMode;
} else {
for (var i = 7; i > 4; i--) {
var div = document.createElement("div");
div.innerHTML = "<!--[if IE " + i + "]><span></span><![endif]-->";
if (div.getElementsByTagName("span").length) {
@jtangelder
jtangelder / example
Last active August 29, 2015 14:05
input[type="calc"]
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>input[type="calc"]</h1>
@jtangelder
jtangelder / django.jquery.polyfill.js
Last active August 29, 2015 14:06
django.jQuery 1.4.2 upgrade functions to support some 'newer' jQuery methods.
(function(jQuery) {
if(!jQuery) {
return;
}
var $version = jQuery.prototype.jquery;
/**
* find out if a version number is greater then or equal (>=) as the compare version
* @example
@jtangelder
jtangelder / jquery.raf.coffee
Last active December 21, 2015 22:38
hack jQuery to use requestAnimationFrame for animations
# hack jQuery to use requestAnimationFrame for animations
((win, $)->
# use Modernizr to get the (prefixed)DOM method
raf = Modernizr.prefixed('requestAnimationFrame', win)
if not raf
return
animating = false;
@jtangelder
jtangelder / modernizr.positionfixed.js
Created September 5, 2013 13:12
Modernizr position fixed check. A modified version of https://gist.github.com/bobslaede/1221602
;(function(Modernizr, window) {
Modernizr.addTest('positionfixed', function () {
var ret;
// no (solid) support on <Android2 and <iOS4
var ua = navigator.userAgent;
if(ua.match(/android [0-2]/i) || ua.match(/(iphone|ipad|ipod).+(OS [0-4])/i)) {
return false;
}

Keybase proof

I hereby claim:

  • I am jtangelder on github.
  • I am jtangelder (https://keybase.io/jtangelder) on keybase.
  • I have a public key ASCKQzxwTobC0hWn_XhXcj4xV7vaufd6s1ZVFlhlNF4Mbgo

To claim this, I am signing this object:

@jtangelder
jtangelder / createResource.js
Last active March 20, 2016 17:55
Redux resources, untested
/*
Create (cacheable) resources, and endpoints that require some state that you want to hide from the
arguments, like a JWT for authenticating remote calls.
Returns a function that will be accepted by redux-thunk.
*/
/**
* create a redux-resource function
* @param {Function} remote(args, getState)
@jtangelder
jtangelder / push_service_worker.js
Created November 16, 2016 12:20
Twitter push serviceWorker
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
// no_unit_test
module.exports = {
visible: function(client) { return client.visibilityState === 'visible'; },
topLevel: function(client) { return client.frameType === 'top-level'; },
focused: function(client) { return client.focused; },
urlEndsWith: function(endsWith) {
return function(client) { return client.url.endsWith(endsWith); };
}
};