Skip to content

Instantly share code, notes, and snippets.

View charliecm's full-sized avatar

Charlie Chao charliecm

View GitHub Profile
@charliecm
charliecm / subLayerByPath.coffee
Last active October 2, 2015 21:49
(Framer module) Extends the Layer class with a new function that returns the first nested sublayer from the provided path of names.
# Extends the Layer class with a new function that returns the first nested
# sublayer from the provided path of names.
# e.g., innerCircle = screenLayer.sublayerByPath('Box/Inner_Box/Inner_Circle')
Layer.prototype.subLayerByPath = (path = '', delimeter = '/') ->
names = path.split(delimeter)
layers = this.subLayersByName(names.shift() || '')
if (layers.length && names.length)
path = names.join(delimeter)
return layers[0].subLayerByPath(path)
@charliecm
charliecm / no-scrollbar.js
Last active August 29, 2015 14:23
No scrollbar console snippet (webkit)
(function(d,s){s=d.createElement('style');s.innerHTML='::-webkit-scrollbar{display:none}';d.head.appendChild(s)})(document)
@charliecm
charliecm / Gruntfile.js
Created November 24, 2014 04:23
Gruntfile from font-icons-workflow.
module.exports = function(grunt) {
grunt.initConfig({
shell: {
exportIcons: {
command: 'sketchtool export slices assets/icons.sketch --output=assets/icons/'
}
},
webfont: {
icons: {
string.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
@charliecm
charliecm / scroll-test.js
Created March 30, 2014 19:36
Paste this in the console so that the page smooth scrolls by viewport height. Good for testing out websites with parallax effects that is broken into sections.
$('body').bind('click', function() { $('body,html').stop().animate({ scrollTop: $('body').scrollTop() + $('body').height() }, 1000); });
@charliecm
charliecm / tricks.css
Created December 16, 2013 01:57
Quick CSS tricks.
/* Smooth font */
.smooth-font {
transform: rotate(-0.0000000001deg);
}
/* Center an element vertically + horizontally */
.center {
position: absolute;
top: 0;
right: 0;
@charliecm
charliecm / placeholder.js
Created October 8, 2013 18:31
Fallback for input placeholder. Uses a .is-placeholder class to style placeholder text.
if(!Modernizr.input.placeholder){
$('input[placeholder], textarea[placeholder]').each(function() {
$(this).val($(this).attr('placeholder'));
$(this).addClass('is-placeholder');
}).blur(function() {
if ($(this).val() === '') {
$(this).val($(this).attr('placeholder'));
$(this).addClass('is-placeholder');
}
}).focus(function() {
@charliecm
charliecm / ie10.js
Created October 7, 2013 16:54
Detection code for IE10+.
// Apply IE10+ detection
if ((/*@cc_on!@*/false && document.documentMode === 10) || navigator.userAgent.match(/Trident\/7.0/)) {
document.documentElement.className += ' ie10';
}
@charliecm
charliecm / social-share-links.html
Created October 3, 2013 17:50
Share link snippets for major social networks.
// Animation
$('selector').on('animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd', function() {
});
// Transition
$('selector').on('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function() {
});