Repository: codrops/AnimatedResponsiveImageGrid Branch: master Commit: 60aa60b8871a Files: 15 Total size: 83.8 KB Directory structure: gitextract_utmmypxf/ ├── README.md ├── bower.json ├── css/ │ ├── demo.css │ ├── fallback.css │ └── style.css ├── images/ │ └── ImageAttribution.txt ├── index.html ├── index2.html ├── index3.html ├── index4.html ├── index5.html ├── index6.html ├── index7.html └── js/ ├── jquery.gridrotator.js └── modernizr.custom.26633.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: README.md ================================================ AnimatedResponsiveImageGrid ========= A jQuery plugin for creating a responsive image grid that will switch images using different animations and timings. This can work nicely as a background or decorative element of a website since we can randomize the appearance of new images and their transitions. [article on Codrops](http://tympanus.net/codrops/?p=10139) [demo](http://tympanus.net/Development/AnimatedResponsiveImageGrid/) Licensed under the MIT License ================================================ FILE: bower.json ================================================ { "name": "AnimatedResponsiveImageGrid", "version": "1.0.0", "homepage": "https://github.com/codrops/AnimatedResponsiveImageGrid", "authors": [ "Pedro Botelho" ], "description": "A jQuery plugin for creating a responsive image grid that will switch images using different animations and timings.", "main": "js/jquery.gridrotator.js", "license": "MIT", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ] } ================================================ FILE: css/demo.css ================================================ @import url(http://fonts.googleapis.com/css?family=Lato:300,400,700); *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0; margin: 0; } /* General Demo Style */ body { font-family: 'Lato', 'Myriad Pro','Trebuchet MS', sans-serif; background: #f9f9f9 url(../images/bg.jpg) repeat top left; font-weight: 300; font-size: 14px; color: #333; overflow: scroll; overflow-x: hidden; } a { color: #555; text-decoration: none; } a img { border: none; } .container { position: relative; background: transparent url(../images/light.png) fixed no-repeat center top; } .codrops-header{ margin: 10px; padding: 20px 10px 10px 10px; position: relative; display: block; text-align: center; text-shadow: 0 1px 1px rgba(255,255,255,0.7); } .codrops-header h1, .codrops-header-special h1{ font-size: 26px; line-height: 26px; margin: 0; position: relative; font-weight: 700; color: #000; } .codrops-header h2, .codrops-header-special h2{ font-size: 14px; line-height: 14px; font-weight: 300; margin: 0; padding: 3px 5px; margin: 10px 0 5px; color: #000; display: inline-block; } /* Header Style */ .codrops-top { line-height: 24px; font-size: 11px; background: #fff; background: rgba(255, 255, 255, 0.8); text-transform: uppercase; z-index: 9999; position: relative; box-shadow: 1px 0px 2px rgba(0,0,0,0.2); } .codrops-top a { padding: 0px 10px; letter-spacing: 1px; color: #333; display: inline-block; } .codrops-top a:hover { background: rgba(255,255,255,0.3); } .codrops-top span.right { float: right; } .codrops-top span.right a { float: left; display: block; } .codrops-info { padding: 20px; margin: 0 auto; text-align: center; text-shadow: 0 1px 1px rgba(255,255,255,0.7); line-height: 22px; } /* Demo Buttons Style */ .codrops-demos{ text-align: center; display: block; line-height: 30px; padding: 5px 0px; } .codrops-demos a{ display: inline-block; margin: 0px 10px; font-weight: bold; color: #333; line-height: 20px; font-size: 12px; background: #fff; background: rgba(255,255,255,0.4); padding: 0 4px; } .codrops-demos a:hover{ border-bottom: 2px solid #f7bb6d; } .codrops-demos a.current-demo, .codrops-demos a.current-demo:hover{ border-bottom: 2px solid #f7bb6d; color: #777; } .codrops-header-special{ position: absolute; top: 80px; left: 0px; text-align: left; } .codrops-header-special h2{ padding: 5px 20px 5px 10px; color: #fff; line-height: 26px; background: #000; background: rgba(0,0,0,0.8); } .codrops-header-special h1{ background: #000; background: rgba(0,0,0,0.8); display: inline-block; font-size: 32px; line-height: 32px; padding: 20px; color: #fff; text-shadow: 0 0 1px #fff; } .codrops-header-special .codrops-demos{ text-align: left; } .codrops-header-special .codrops-demos a{ background: rgba(255,255,255,1); } .codrops-header-special .codrops-info{ color: #fff; background: #000; background: rgba(0,0,0,0.8); text-shadow: 1px 1px 1px rgba(0,0,0,0.5); padding: 5px 20px 5px 10px; line-height: 26px; margin-top: 30px; text-align: left; } ================================================ FILE: css/fallback.css ================================================ .ri-grid{ width: 600px; } .ri-grid ul li, .ri-grid ul li a{ width: 100px; height: 100px; } .ri-grid ul li a img{ width: 100%; } ================================================ FILE: css/style.css ================================================ .ri-grid{ margin: 30px auto 30px; position: relative; height: auto; } .ri-grid ul { list-style: none; display: block; width: 100%; margin: 0; padding: 0; } /* Clear floats by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */ .ri-grid ul:before, .ri-grid ul:after{ content: ''; display: table; } .ri-grid ul:after { clear: both; } .ri-grid ul { zoom: 1; /* For IE 6/7 (trigger hasLayout) */ } .ri-grid ul li { -webkit-perspective: 400px; -moz-perspective: 400px; -o-perspective: 400px; -ms-perspective: 400px; perspective: 400px; margin: 0; padding: 0; float: left; position: relative; display: block; overflow: hidden; background: #000; } .ri-grid ul li a{ display: block; outline: none; position: absolute; left: 0; top: 0; width: 100%; height: 100%; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -o-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -o-transform-style: preserve-3d; -ms-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-background-size: 100% 100%; -moz-background-size: 100% 100%; background-size: 100% 100%; background-position: center center; background-repeat: no-repeat; background-color: #333; -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box; } /* Grid wrapper sizes */ .ri-grid-size-1{ width: 55%; } .ri-grid-size-2{ width: 100%; } .ri-grid-size-3{ width: 100%; margin-top: 0px; } /* Shadow style */ .ri-shadow:after, .ri-shadow:before{ content: ""; position: absolute; z-index: -2; bottom: 15px; left: 10px; width: 50%; height: 20%; max-width: 300px; max-height: 100px; box-shadow: 0 15px 10px rgba(0, 0, 0, 0.7); -webkit-transform: rotate(-3deg); -moz-transform: rotate(-3deg); -ms-transform: rotate(-3deg); -o-transform: rotate(-3deg); transform: rotate(-3deg); } .ri-shadow:after{ right: 10px; left: auto; -webkit-transform: rotate(3deg); -moz-transform: rotate(3deg); -ms-transform: rotate(3deg); -o-transform: rotate(3deg); transform: rotate(3deg); } .ri-grid-loading:after, .ri-grid-loading:before{ display: none; } .ri-loading-image{ display: none; } .ri-grid-loading .ri-loading-image{ position: relative; width: 30px; height: 30px; left: 50%; margin: 100px 0 0 -15px; display: block; } ================================================ FILE: images/ImageAttribution.txt ================================================ Images by Sherman Geronimo-Tan: http://www.flickr.com/people/smanography/ http://creativecommons.org/licenses/by/2.0/deed.en ================================================ FILE: index.html ================================================ Animated Responsive Image Grid
« Previous Demo: Photo Booth Strips with Lightbox Images by Sherman Geronimo-Tan Back to the Codrops Article

Animated Responsive Image Grid

Cycling through a set of images in a responsive grid.

Demo 1: Random animations / 55% container width / 3s between switching

================================================ FILE: index2.html ================================================ Animated Responsive Image Grid
« Previous Demo: Photo Booth Strips with Lightbox Images by Sherman Geronimo-Tan Back to the Codrops Article

Animated Responsive Image Grid

Cycling through a set of images in a responsive grid.

Demo 2: "fadeInOut" animation / 100% container width / 1 image switch at a time / 600ms between switching

================================================ FILE: index3.html ================================================ Animated Responsive Image Grid
« Previous Demo: Photo Booth Strips with Lightbox Images by Sherman Geronimo-Tan Back to the Codrops Article

Animated Responsive Image Grid


Cycling through a set of images in a responsive grid.

Demo 3: Random animations / 100% container width / max. 2 images switch at a time / 2s between switching

================================================ FILE: index4.html ================================================ Animated Responsive Image Grid
« Previous Demo: Photo Booth Strips with Lightbox Images by Sherman Geronimo-Tan Back to the Codrops Article

Animated Responsive Image Grid

Cycling through a set of images in a responsive grid.

Demo 4: Random animations / 55% container width / 3s between switching / elements 1,2,3 and 4 don't switch / clickable elements

================================================ FILE: index5.html ================================================ Animated Responsive Image Grid
« Previous Demo: Photo Booth Strips with Lightbox Images by Sherman Geronimo-Tan Back to the Codrops Article

Animated Responsive Image Grid

Cycling through a set of images in a responsive grid.

Demo 5: rotateBottom animation / 55% container width / no slideshow / onhover true

================================================ FILE: index6.html ================================================ Animated Responsive Image Grid
« Previous Demo: Photo Booth Strips with Lightbox Images by Sherman Geronimo-Tan Back to the Codrops Article

Animated Responsive Image Grid

Cycling through a set of images in a responsive grid.

Demo 1: Random animations / 55% container width / 3s between switching / some images unavailabe, replaced with color block

================================================ FILE: index7.html ================================================ Animated Responsive Image Grid
« Previous Demo: Photo Booth Strips with Lightbox Images by Sherman Geronimo-Tan Back to the Codrops Article

Animated Responsive Image Grid

Cycling through a set of images in a responsive grid.

Demo 1: Random animations / 55% container width / 3s between switching / some images unavailabe, replaced with substitute image

================================================ FILE: js/jquery.gridrotator.js ================================================ /** * jquery.gridrotator.js v1.1.0 * http://www.codrops.com * * Licensed under the MIT license. * http://www.opensource.org/licenses/mit-license.php * * Copyright 2012, Codrops * http://www.codrops.com */ ;( function( $, window, undefined ) { 'use strict'; /* * debouncedresize: special jQuery event that happens once after a window resize * * latest version and complete README available on Github: * https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js * * Copyright 2011 @louis_remi * Licensed under the MIT license. */ var $event = $.event, $special, resizeTimeout; $special = $event.special.debouncedresize = { setup: function() { $( this ).on( "resize", $special.handler ); }, teardown: function() { $( this ).off( "resize", $special.handler ); }, handler: function( event, execAsap ) { // Save the context var context = this, args = arguments, dispatch = function() { // set correct event type event.type = "debouncedresize"; $event.dispatch.apply( context, args ); }; if ( resizeTimeout ) { clearTimeout( resizeTimeout ); } execAsap ? dispatch() : resizeTimeout = setTimeout( dispatch, $special.threshold ); }, threshold: 100 }; // http://www.hardcode.nl/subcategory_1/article_317-array-shuffle-function function shuffle(a) { var i=a.length,p,t; while (i--) { p = Math.floor(Math.random()*this.length); t = a[i]; a[i]=a[p]; a[p]=t; } } // HTML5 PageVisibility API // http://www.html5rocks.com/en/tutorials/pagevisibility/intro/ // by Joe Marini (@joemarini) function getHiddenProp(){ var prefixes = ['webkit','moz','ms','o']; // if 'hidden' is natively supported just return it if ('hidden' in document) return 'hidden'; // otherwise loop over all the known prefixes until we find one for (var i = 0; i < prefixes.length; i++){ if ((prefixes[i] + 'Hidden') in document) return prefixes[i] + 'Hidden'; } // otherwise it's not supported return null; } function isHidden() { var prop = getHiddenProp(); if (!prop) return false; return document[prop]; } function isEmpty( obj ) { return Object.keys(obj).length === 0; } // global var $window = $( window ), Modernizr = window.Modernizr; $.GridRotator = function( options, element ) { this.$el = $( element ); if( Modernizr.backgroundsize ) { var self = this; this.$el.addClass( 'ri-grid-loading' ); this._init( options ); } }; // the options $.GridRotator.defaults = { // number of rows rows : 4, // number of columns columns : 10, w1024 : { rows : 3, columns : 8 }, w768 : {rows : 3,columns : 7 }, w480 : {rows : 3,columns : 5 }, w320 : {rows : 2,columns : 4 }, w240 : {rows : 2,columns : 3 }, // step: number of items that are replaced at the same time // random || [some number] // note: for performance issues, the number "can't" be > options.maxStep step : 'random', // change it as you wish.. maxStep : 3, // prevent user to click the items preventClick : true, // animation type // showHide || fadeInOut || // slideLeft || slideRight || slideTop || slideBottom || // rotateBottom || rotateLeft || rotateRight || rotateTop || // scale || // rotate3d || // rotateLeftScale || rotateRightScale || rotateTopScale || rotateBottomScale || // random animType : 'random', // animation speed animSpeed : 800, // animation easings animEasingOut : 'linear', animEasingIn: 'linear', // the item(s) will be replaced every 3 seconds // note: for performance issues, the time "can't" be < 300 ms interval : 3000, // if false the animations will not start // use false if onhover is true for example slideshow : true, // if true the items will switch when hovered onhover : false, // ids of elements that shouldn't change nochange : [], // callback function when drawn onDraw : function(){}, // Height to Width Ratio (Height/Width). A 0.5 ratio would be used for an image that is twice as large as it's height. Default is 1 (square images). heightToWidthRatio : 1, subImg : false }; $.GridRotator.prototype = { _init : function( options ) { // options this.options = $.extend( true, {}, $.GridRotator.defaults, options ); // cache some elements + variables this._config(); }, _config : function() { var self = this, transEndEventNames = { 'WebkitTransition' : 'webkitTransitionEnd', 'MozTransition' : 'transitionend', 'OTransition' : 'oTransitionEnd', 'msTransition' : 'MSTransitionEnd', 'transition' : 'transitionend' }; // support CSS transitions and 3d transforms this.supportTransitions = Modernizr.csstransitions; this.supportTransforms3D = Modernizr.csstransforms3d; this.transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ] + '.gridrotator'; // all animation types for the random option this.animTypes = this.supportTransforms3D ? [ 'fadeInOut', 'slideLeft', 'slideRight', 'slideTop', 'slideBottom', 'rotateLeft', 'rotateRight', 'rotateTop', 'rotateBottom', 'scale', 'rotate3d', 'rotateLeftScale', 'rotateRightScale', 'rotateTopScale', 'rotateBottomScale' ] : [ 'fadeInOut', 'slideLeft', 'slideRight', 'slideTop', 'slideBottom' ]; this.animType = this.options.animType; if( this.animType !== 'random' && !this.supportTransforms3D && $.inArray( this.animType, this.animTypes ) === -1 && this.animType !== 'showHide' ) { // fallback to 'fadeInOut' if user sets a type which is not supported this.animType = 'fadeInOut'; } this.animTypesTotal = this.animTypes.length; // the