Skip to content

Instantly share code, notes, and snippets.

View amnuts's full-sized avatar

Andrew Collington amnuts

View GitHub Profile
@amnuts
amnuts / crossfade.js
Last active December 27, 2015 08:59
Quick and easy way to cross-fade between elements in a list. If those elements contained images then you have a very simple slideshow. (Requires jQuery.)
if ($('ul.crossfade').length) {
$('ul.crossfade').each(function(){
var ul = $(this);
if ($('li', ul).length > 1) {
$('li:gt(0)', ul).hide();
var fadeSpeed = (ul.attr('data-fadespeed') !== undefined ? ul.attr('data-fadespeed') : 1000);
var nextSpeed = (ul.attr('data-nextspeed') !== undefined ? ul.attr('data-nextspeed') : 5000);
setInterval(function(){
$('li:first', ul)
.fadeOut(fadeSpeed).next('li')
@amnuts
amnuts / jquery.sameheight.js
Created November 4, 2013 10:40
A jQuery plug-in to make elements the same height (by max height or min height)
/**
* Same Height, jQuery plug-in.
*
* This plug-in allows you to automatically have all of the elements marked
* with a particular class to be the same height, either by smallest or
* largest.
*
* By default, 'samemaxheight' and 'sameminheight' will be used.
*
* Examples of use: