Skip to content

Instantly share code, notes, and snippets.

View skhilko's full-sized avatar

Sergey Khilko skhilko

  • Personal Capital
  • Mountain View, CA
View GitHub Profile
@skhilko
skhilko / jquery.oncssanimationend.js
Created June 28, 2015 23:15
Detecting CSS Animation and Transition End with JavaScript
/*
By Osvaldas Valutis, www.osvaldas.info
Available for use under the MIT License
*/
;( function( $, window, document, undefined )
{
var s = document.body || document.documentElement, s = s.style, prefixAnimation = '', prefixTransition = '';
if( s.WebkitAnimation == '' ) prefixAnimation = '-webkit-';
@skhilko
skhilko / scroll_width.js
Last active August 29, 2015 14:08
Detect scrollbar width with JavaScript. Based on a technique by David Walsh http://davidwalsh.name/detect-scrollbar-width
var scrollWidth = (function() {
var scrollDiv = document.createElement("div");
scrollDiv.className = "scrollbar-measure";
document.body.appendChild(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
@skhilko
skhilko / Dom Snippets
Last active August 29, 2015 14:05
A collection of cross-browser snippets to serve as a reference guide for simple DOM tasks
/**
* The width of the viewport.
* Does not include the scroll bar.
*/
function viewportWidth () {
return document.documentElement.clientWidth;
}
/**
@skhilko
skhilko / Revealing Module Pattern
Created September 11, 2013 03:42
Revealing Module Pattern: Keep consistent syntax and mix and match what to make global.
module = function(){
var current = null;
var labels = {
'home':'home',
'articles':'articles',
'contact':'contact'
};
var init = function(){
};
var show = function(){
@skhilko
skhilko / Absolute Centering
Created August 28, 2013 05:52
A simple yet powerful absolute centering technique from http://codepen.io/shshaw/full/gEiDt
.center-container {
position: relative;
}
.absolute-center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
@skhilko
skhilko / jQuery Plugin
Last active October 11, 2015 12:58
jQuery: Plugin Boilerplate
/**
* jQuery Plugin Boilerplate
* Author: Sergey Khilko
*
* Usage Examples:
* $('#id').pluginName({ option: 'value' });
* $('#id').pluginName('function', arg1, arg2);
* $('#id').data("pluginName").function(arg1, arg2);
*
* Based on: