Skip to content

Instantly share code, notes, and snippets.

@zz85
zz85 / test.jsx
Last active July 26, 2022 18:59
Prototype to make Scroll Position Sticky When Changing Dynamic Element Heights for React Infinite
function sum(total, next) {
return total + next;
}
var old = 0;
var NUM = 102;
var VariableInfiniteList = React.createClass({
componentDidMount: function() {
@jonathanlurie
jonathanlurie / TrackballControls.js
Last active June 30, 2022 06:12
Some fragment shader playing with 3d world coordinates
/**
* @author Eberhard Graether / http://egraether.com/
* @author Mark Lundin / http://mark-lundin.com
* @author Simone Manini / http://daron1337.github.io
* @author Luca Antiga / http://lantiga.github.io
*/
THREE.TrackballControls = function ( object, domElement ) {
var _this = this;
@odirleiborgert
odirleiborgert / gulpfile.js
Created November 3, 2016 12:18 — forked from HPieters/gulpfile.js
BrowserSync Gulpfile
//load plugins
var gulp = require('gulp'),
compass = require('gulp-compass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
livereload = require('gulp-livereload'),
function setOnboardingStep(stepLabel) {
return {
type: 'SET_ONBOARDING_STEP',
payload: stepLabel
}
}
function addOnboardingMilestone(type) {
return {
type: 'ADD_ONBOARDING_MILESTONE',
function push(url) {
return {
type: 'PUSH_URL',
payload: url
}
}
function replace(url) {
return {
type: 'REPLACE_URL',
import { browserHistory } from 'react-router';
function locationReducer(state, action) {
switch (action.type) {
case 'PUSH_URL':
browserHistory.push(action.payload);
break;
case 'REPLACE_URL':
browserHistory.replace(action.payload);
break;
const exclusiveUrls = [
'/onboarding/route/1',
'/onboarding/route/2',
'/onboarding/route/3',
// ... and so on ...
];
let step = null;
const middleware = store => next => action => {
switch (action.type) {
case 'SET_ONBOARDING_STEP':
step = action.payload;
const { url } = steps[step];
// Make sure we "replace" instead of "push" when we have an on-boarding
// exclusive URL.
const redirectMethod = exclusiveUrls.indexOf(url) >= 0 ? replace : push;
if (step === finalStep) {
// Handle all LOCATION_CHANGE action from react-router-redux.
if (action.type === '@@router/LOCATION_CHANGE';) {
// Make sure the user is redirected away from on-boarding exclusive URLs.
if (exclusiveUrls.indexOf(action.payload.pathname) >= 0) {
store.dispatch( push('/somewhere/else') );
}
}
// If we're already on the last step, we don't need to steer the flow anymore,
if (milestones.indexOf(action.type) >= 0) {
const { nextStep } = states[step];
store.dispatch( setRegistrationStep(nextStep) );
}