Skip to content

Instantly share code, notes, and snippets.

View csuwildcat's full-sized avatar

Daniel Buchner csuwildcat

View GitHub Profile
@csuwildcat
csuwildcat / new_gist_file
Created August 10, 2013 14:58
Visual logging for mobile
var msg = document.getElementById('msg');
var msgs = [];
var log = function(m, e){
if (e) console.log(e);
msgs.unshift(m + ' ' + new Date().getTime());
msgs = msgs.slice(0,5);
msg.innerHTML = msgs.join('<br/>');
};
var logEvent = function(e){
var sanitize = (function(doc){
var slice = Array.prototype.slice,
range = doc.createRange(),
frag = doc.createDocumentFragment(),
wrap = frag.appendChild(doc.createElement('div'));
function cleanNode(node, unwrap){
var parent = node.parentNode;
if (unwrap){
accessors: {
foo: {
attribute: { boolean: true }
set: function(){
// do something when this prop is set
}
}
}
@csuwildcat
csuwildcat / transitionall
Created October 4, 2013 00:07
A custom event that notifies you when all declared transition properties have completed a transition
var replaceSpaces = / /g;
xtag.customEvents.transitionall = {
observe: { transitionend: document },
condition: function(e, tap){
var element = e.target;
if (!element.__transall__ && (element.__tranend__ ? element.__tranend__ > e.elapsedTime : true)) {
delete element.__transtime__;
var trans = element.__transall__ = { duration: 0 };
style = getComputedStyle(element),
props = (style.transitionProperty || style[xtag.prefix.js + 'TransitionProperty']).replace(replaceSpaces, '').split(','),
var replaceSpaces = / /g;
xtag.customEvents.transitionall = {
observe: { transitionend: document },
condition: function(e, tap){
var element = e.target;
if (!element.__transall__ && (element.__tranend__ ? element.__tranend__ > e.elapsedTime : true)) {
delete element.__transtime__;
var trans = element.__transall__ = { duration: 0 };
style = getComputedStyle(element),
props = (style.transitionProperty || style[xtag.prefix.js + 'TransitionProperty']).replace(replaceSpaces, '').split(','),
@csuwildcat
csuwildcat / gist:7000935
Created October 16, 2013 00:45
Unfinished gesture events
(function(){
var directions = {
up: 0,
down: 180,
left: 270,
right: 90
};
(function(){
var views = {};
var setAttrProto = Element.prototype.setAttribute;
var removeAttrProto = Element.prototype.removeAttribute;
/*** Prototype Upgrades ***/
Element.prototype.setAttribute = function(name, value){
if (name == 'view') switchView(this, value);
(function(){
var directions = {
up: 0,
down: 180,
left: 270,
right: 90
};
@csuwildcat
csuwildcat / Transitionall Event & Transition Mixing
Created November 4, 2013 21:40
Transitionall event and transition mixin
var replaceSpaces = / /g;
xtag.customEvents.transitionall = {
observe: { transitionend: document },
condition: function(e, tap){
var element = e.target;
if (!element.__transall__ && (element.__tranend__ ? element.__tranend__ > e.elapsedTime : true)) {
delete element.__transtime__;
var trans = element.__transall__ = { duration: 0 };
style = getComputedStyle(element),
props = (style.transitionProperty || style[xtag.prefix.js + 'TransitionProperty']).replace(replaceSpaces, '').split(','),
/*** JS ***/
'show:transition(before)': function(){
this.removeAttribute('hidden');
},
'hide:transition(after)': function(){
this.setAttribute('hidden', '');
}
/*** CSS ***/