Skip to content

Instantly share code, notes, and snippets.

View SanderSpies's full-sized avatar
🐫
wasm

Sander SanderSpies

🐫
wasm
View GitHub Profile
@SanderSpies
SanderSpies / PubSubManager.js
Created April 16, 2012 06:15
PubSubManager
define([], function () {
var PubSubManager = function PubSubManager() {
this.subscribers = {};
};
var instance = undefined;
PubSubManager.getInstance = function PubSubManager$getInstance() {
if (!instance) {
instance = new PubSubManager();
@SanderSpies
SanderSpies / Protected Inheritance
Created August 29, 2013 06:15
Example for inheritance that protects the parent's functions by using Object.freeze
var Parent = function Parent(){
};
Parent.prototype = {
a:function a(){
console.log(333);
}
};
@SanderSpies
SanderSpies / gist:7039585
Created October 18, 2013 10:26
Simple input event polyfill
// function
function onKeyDown(e){
// [input|textarea] trigger input with target.value // in case of input field, textarea
// [contenteditable] trigger input with textContent // in case of contentEditable ?
}
// detect support for input
if(!'oninput' in document.createElement("input")){
// add polyfill in this case
}
@SanderSpies
SanderSpies / gist:7132734
Created October 24, 2013 07:24
Graph Idea
var graphDefinition = {
'somewhere': 'there is a ${./over/therainbow}',
'over':{
'therainbow' : 'pot of gold'
},
'value': 'genius',
'act':{
'of': '${../value}'
@SanderSpies
SanderSpies / gist:9ce7eec0e1c3394c7003
Last active August 29, 2015 14:05
CSS reset for react-style
var allInitial;
var testElement = document.createElement('div');
// Firefox
if ('all' in testElement.style) {
allInitial = {
all: 'initial'
};
}
else {
testElement.style.display = 'initial';
'use strict';
var merge = require('../vendor/merge');
var TransitionMixin = {
transitionStart: function(opt) {
var self = this;
return new Promise(function(resolve) {
opt.transition = 'all ' + opt.duration + ' linear';

So this is my current solution for "fixing" the implicit nature of CSS. It basically replaces CSS selectors, classNames, etc. with the ability to directly reference to a style from JavaScript.

/**
 * @jsx React.DOM
 */
'use strict';

var React = require('react');
var ReactStyle = require('react-style');
@SanderSpies
SanderSpies / gist:0b2963e8e2d5eb2ca359
Last active August 29, 2015 14:14
React Animation prototyping
/**
* @jsx React.DOM
*/
'use strict';
var React = require('react');
var ReactAnimation = require('react-animation');
var Animation = ReactAnimation.Animation;
class Foo extends React.Component {
@SanderSpies
SanderSpies / gist:dc4e2a5ca1f95b3d2b26
Last active August 29, 2015 14:14
Rough touch support idea for React Magician
/**
* @jsx React.DOM
*/
'use strict';
var React = require('react');
var Animation = require('react-magician');
class Foo extends React.Component {
var foo = <div>
if (foo) {
<something>
for(var i = 0, l = 10; i < 10; i++) {
<a prop={i} />
}
</something>
}
"2222"
</div>;