Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tbusser
tbusser / docpad.coffee
Created November 4, 2014 10:52
DocPad config for faster regeneration and Grunt integration for static builds
# DocPad Configuration File
# http://docpad.org/docs/config
# Define the DocPad Configuration
docpadConfig = {
events:
generateAfter: (opts, next) ->
if 'static' in @docpad.getEnvironments()
@docpad.log('info', 'generateAfter: starting grunt task generateAfter')
@tbusser
tbusser / .jscs.json
Last active August 29, 2015 14:07
My preferred settings for jscs
{
"requireCurlyBraces" : [
"catch",
"do",
"else",
"for",
"if",
"try",
"while"
],
@tbusser
tbusser / .jshintrc.js
Last active August 29, 2015 14:07
My preferred settings for JSHint
{
// Enforcing options
"bitwise" : true, // Warn when using bitwise operators, most of the time it is a typo
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
"curly" : true, // Always put curly braces around blocks in loops and conditionals
"eqeqeq" : true, // Always compare using === and !==
"forin" : true, // Force the use of hasOwnProperty() checks when iterating object properties
"freeze" : true, // Prohibit overwriting prototypes of native objects like Array
"immed" : true, // Prohibits the use of immediate function invocations without wrapping them in parentheses
"indent" : 4, // Tab width for the code
@tbusser
tbusser / easeoutcubic.js
Last active August 29, 2015 14:07
JavaScript method, sans jQuery, for a cubic ease-out function
/*
* Robert Penner's algorithm for an cubic ease out function
* @param {Number} currentIteration The current iteration of the animation, on each subsequent
* call this should be increased by 1
* @param {Number} startValue The start value, this should be a constant throughout the
* animation.
* @param {Number} changeInValue The difference between the start value and the desired end value
* @param {Number} totalIterations The number of iterations over which we want to go from start
* to end
* @return {Number} The value for the current step in the animation
@tbusser
tbusser / transitionend.js
Last active August 29, 2015 14:07
Determine the name of the `transtitionend` event
var NO_TRANSITIONS = 'no-transitions';
/**
* This method tries to determine the name of the transitionend event, it
* could be the user's browser is using a prefixed version
*/
function getTransitionEndEventName () {
// 1: The variable we use to keep track of the current key when
// iterating over the transitions object
// 2: An element we can use to test if a CSS property if known to the
// browser
@tbusser
tbusser / iterate.js
Last active January 29, 2016 08:57
Iterate over object properties
/**
* Iterates over the properties of an object and calls a callback function when the
* key belongs to the object itself and not to its prototype chain.
*
* The iterate method will iterate over all properties but can be stopped by
* returning true from the callback method.
*
* @param {Object} source The object whose properties should be iterated over
* @param {Function} callback The function to be called for each property defined
* on the source object itself and not its prototype
/**
* This method is used to scroll a bit closer to the top of the window. As long as the top
* hasn't been reached the method will call itself at the next animation frame.
*/
_animationLoop: function() {
var self = this;
// Perform a step of the animation to go to the top of the window
window.scrollTo(0, this._easeOutCubic(this._iteration, this._scrollPosition, -this._scrollPosition, this._maxIterations));
// Increase the iteration counter