Skip to content

Instantly share code, notes, and snippets.

@vctrfrnndz
vctrfrnndz / equalizer.js
Created October 29, 2015 19:50
Calculate equal height based on content
function heightEqualizer($row) {
var $columns = $row.find('> *');
function calculateHeight($el) {
var height = 0;
$el.each(function() {
var heightVal = $(this).css('height');
$(this).css('height', '');
@vctrfrnndz
vctrfrnndz / sticky.js
Last active August 29, 2015 14:28
Sticky
$(window)
.on('scroll', onScroll);
function onScroll() {
var sticky = $('.js-sticky-nav').filter(':visible');
if (sticky.length) {
toggleSticky(sticky);
}
}
@vctrfrnndz
vctrfrnndz / val.js
Created July 8, 2015 17:03
input validations
function inputValidations() {
function isAlphaNumeric(val) {
var letter = /[a-zA-Z]/,
number = /[0-9]/;
var valid = number.test(val) && letter.test(val);
return valid;
}
@vctrfrnndz
vctrfrnndz / letteravatar.js
Created May 18, 2015 17:06
Generate SVG letter avatar
function drawCircle(text, size, color) {
var textSize = Math.ceil(size / 2.5);
var font = 'Proxima Nova, proxima-nova, HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif';
var colors = ["#1abc9c", "#16a085", "#f1c40f", "#f39c12", "#2ecc71", "#27ae60", "#e67e22", "#d35400", "#3498db", "#2980b9", "#e74c3c", "#c0392b", "#9b59b6", "#8e44ad", "#bdc3c7", "#34495e", "#2c3e50", "#95a5a6", "#7f8c8d", "#ec87bf", "#d870ad", "#f69785", "#9ba37e", "#b49255", "#b49255", "#a94136"];
var colorIndex = Math.floor((text.charCodeAt(0) - 65) % colors.length);
var finalColor = color || colors[colorIndex];
var template = [
'<svg height="' + size + '" width="' + size + '" style="background: ' + finalColor + '">',
'<text text-anchor="middle" x="50%" y="50%" dy="0.35em" fill="white" font-size="' + textSize + '" font-family="' + font + '">' + text.toUpperCase() + '</text>',
Avatar Generator from Name
--------------------------
A name (first name and surname) is input and output using the initials from the name and a background colour (based on the first name first letter). The background colors are from from http://flatuicolors.com/
function scrollAnimated(to, duration) {
var start = $(window).scrollTop(),
change = to - start,
currentTime = 0,
increment = 20;
function easeInOut(currentTime, startValue, change, duration) {
currentTime /= duration / 2;
if (currentTime < 1) {
@vctrfrnndz
vctrfrnndz / debounce.js
Last active November 8, 2019 04:23
Debounce
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
@vctrfrnndz
vctrfrnndz / jquery.accordion.defautls.js
Last active August 29, 2015 14:02
jQuery Accordion Defaults
{
transitionSpeed: 300,
transitionEasing: 'ease',
controlElement: '[data-control]',
contentElement: '[data-content]',
groupElement: '[data-accordion-group]',
singleOpen: true
}
@mixin grid($cols: 1, $gutter: 0, $childs: ".item") {
width: auto;
margin-right: -$gutter;
#{$childs} {
float: left;
width: (100% / $cols);
padding-right: $gutter;
background-clip: content-box;
@vctrfrnndz
vctrfrnndz / gist:6526989.less
Last active December 22, 2015 20:29
Ultimate grid mixin
// Group class for clearing floats
.group {
&:before,
&:after {
content: " ";
display: table;
}
&:after {