Skip to content

Instantly share code, notes, and snippets.

View LucaColonnello's full-sized avatar
👋
Come say hello on Twitter!

Luca Colonnello LucaColonnello

👋
Come say hello on Twitter!
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="React Menu Content Example">
<script src="http://fb.me/react-with-addons-0.13.1.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
html,
body {
@LucaColonnello
LucaColonnello / Custom CSSTransitionGroup for React.markdown
Created June 16, 2015 22:18
Custom CSSTransitionGroup for React

Custom CSSTransitionGroup for React

The CSSTransitionGroup in the React Addons works fine for simple things, but since React components don’t have much knowledge of their children, more complex nested components can be re-rendering while the transitions are happening. This can lead to jerky animation.

This example implements a custom AnimationItem component that sits inside the TransitionGroup — note the lack of the CSS prefix there — which has an API for handling the various transition events. I’ve reimplemented the behaviour from the CSSTransitionsGroup in the AnimationItem component but using requestAnimationFrame to wait a render tick before triggering the transition, and Arrival to determine when the transition ends.

Again, it’s unnecessary in this example because the components are so simple, but it makes a massive difference on more complex components.

Forked from Max's Pen [Cus

// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
@LucaColonnello
LucaColonnello / HTTPInterface.js
Last active August 31, 2017 17:23
Loopback React SDK Proposals
// it could be part of the LoopBackSDK module
// evaluate usage of node http module for ajax call
var http = require( 'http' );
// LoopBack HTTP Interface
// Class that has the responsibility to call
// the LoopBack Application, must be instantiated for each models
function HTTPInterface(
@LucaColonnello
LucaColonnello / index.js
Last active October 16, 2015 09:50
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var patchHTML = require('html2idom').patchHTML;
function cond( cond, resTrue, resFalse ) {
if(cond){
return resTrue;
} else {
return resFalse;
@LucaColonnello
LucaColonnello / create-component.js
Last active August 29, 2015 14:27
createComponent module for use with React shallow rendering
import React from 'react/addons';
const TestUtils = React.addons.TestUtils;
export default createComponent;
function createComponent(component, props, ...children) {
const shallowRenderer = TestUtils.createRenderer();
shallowRenderer.render(React.createElement(component, props, children.length > 1 ? children : children[0]));
return shallowRenderer.getRenderOutput();
}
@LucaColonnello
LucaColonnello / App-test.js
Created August 23, 2015 09:36
React Test BDD with Mocha and JSDom
// components/App-test.jsx
import "../utils/test/dom";
import assert from 'assert';
import React from 'react/addons';
import App from '../App';
const TestUtils = React.addons.TestUtils;
@LucaColonnello
LucaColonnello / INSTALLATION.md
Created October 5, 2015 08:44 — forked from DenisIzmaylov/INSTALLATION.md
OS X 10.11 El Capitan: fresh install with Node.js (io.js) Developer Environment

OS X 10.11 (El Capitan) / Node.js and io.js Developer Environment

Custom recipe to get OS X 10.11 El Capitan running from scratch with useful applications and Node.js Developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after fresh install.

Content

@LucaColonnello
LucaColonnello / README.markdown
Created December 11, 2015 09:22 — forked from marijn/README.markdown
List of countries in YAML, CSV and TXT format

#List of countries

It's time someone compiled a list of countries to use within a web application. This gist attempts to make a first move at that.

List of nationalities

I've also compiled a list of nationalities

@LucaColonnello
LucaColonnello / README.markdown
Created December 11, 2015 10:56 — forked from marijn/README.markdown
List of nationalities in YAML, CSV and TXT format

List of nationalities

It's time someone compiled a list of nationalities to use within a web application. This gist attempts to make a first move at that.

##List of countries

I've also compiled a list of countries