Giter Site home page Giter Site logo

woollymittens / photo-gallery Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 12.0 2.52 MB

This content gallery loads content progressively using AJAX and uses CSS3 transitions for animation and positioning. The optional web service providing the content is based on PHP, but the concept can be easily reproduced in other languages.

License: MIT License

JavaScript 79.82% PHP 11.70% HTML 8.48%

photo-gallery's Introduction

gallery.js: Pinboard Gallery

DEPRICATION WARNING: the functionality in this script has been superceeded / trivialised by updated web standards.

This content gallery loads content progressively using AJAX and uses CSS3 transitions for animation and positioning. The optional web service providing the content is based on PHP, but the concept can be easily reproduced in other languages.

How to include the script

The stylesheet is best included in the header of the document.

<link rel="stylesheet" href="css/gallery.css"/>

This include can be added to the header or placed inline before the script is invoked.

<script src="lib/requests.js"></script>
<script src="lib/transitions.js"></script>
<script src="js/gallery.js"></script>

Or use Require.js.

requirejs([
	'lib/requests.js',
	'lib/transitions.js',
	'js/gallery.js'
], function(requests, transitions, Gallery) {
	...
});

Or use imported as a component in existing projects.

@import {requests = require('lib/requests.js";
@import {transitions = require('lib/transitions.js";
@import {Gallery} from "js/gallery.js');

Using vanilla JavaScript

var gallery = new Gallery( document.getElementById('id'), {
	'aspectRatio' : 1,
	'carouselNames' : ['gallery_carousel_farleft', 'gallery_carousel_left', 'gallery_carousel_centre', 'gallery_carousel_right', 'gallery_carousel_farright'],
	'pinboardNames' : ['gallery_pinboard_left', 'gallery_pinboard_right', 'gallery_pinboard_loading'],
	'pagerLabels' : ['I', 'II', 'III', 'IV', 'V'],
	'rowOffset' : 18,
	'pinboardOffset' : 0,
	'fetchScrollBottom' : 100,
	'fetchTreshold' : 3,
	'fetchAmount' : 5,
	'limitSpeed' : true,
	'allowLoop' : false,
	'idleDelay' : 8000,
	'idleDirection' : 1,
	'toggleHint' : true,
	'togglePager' : true,
	'toggleFilter' : 'Filter',
	'togglePinboard' : 'View Pin Board',
	'toggleCarousel' : 'View Carousel',
	'toggleNext' : 'Next Slide',
	'togglePrev' : 'Previous Slide',
	'onMobile' : (navigator.userAgent.indexOf('Mobile')>-1)
});

id : {string} - The ID attribute of an element somewhere in the document.

aspectRatio : {float} - Defines the aspect ratio of the gallery (4:3 would be 0.75).

carouselNames : {array} - The script will cycle through these classes, the number is not limited.

pinboardNames : {array} - The script alternates between these classes to divide the slides across columns.

pagerLabels : {array} - By default the page numbers are shown as integers, but these strings will be substituted if given.

pinboardOffset : {integer} - Tweak for positioning of the pin-board.

rowOffset : {integer} - Distance between rows of slides in pin-board mode.

fetchScrollBottom : {integer} - Distance from the bottom of the pin board where new slides will be loaded if AJAX is enabled.

fetchTreshold : {integer} - How far from the unloaded slides preloading should commence.

fetchAmount : {integer} - How many slides to get in one go.

limitSpeed : {boolean} - Don't accept new input until the animation finished.

allowLoop : {boolean} - Immediately cycle to the first slide after reaching the last.

idleDelay : {integer} - Wait this long until starting the automatic slideshow.

idleDirection : {integer} - Direction to show the slides in. +1 is left to right, -1 is right to left.

toggleHint : {boolean} - Shows or hides the hint icon.

togglePager : {boolean} - Shows or hides the page count.

toggleFilter : {string / boolean} - Shows or hides the category filter. A string will override the label text.

togglePinboard : {string / boolean} - Shows or hides the pin-board mode switch. A string will override the label text.

toggleCarousel : {string / boolean} - Shows or hides the carousel mode switch. A string will override the label text.

toggleNext : {string / boolean} - Shows or hides the next slide button. A string will override the label text.

togglePrev : {string / boolean} - Shows or hides the previous slide button. A string will override the label text.

onMobile : {boolean} - How mobile devices are identified to enable touch controls

How to control the script

Focus

gallery.focus(index);

Highlights and centres a specific thumbnail.

index : {integer} - The index of the slide to show.

Previous

gallery.previous();

Shows the previous slide.

Next

gallery.next();

Shows the next slide

Pause

gallery.pause();

Stops the automatic slideshow.

Play

gallery.play();

Starts the automatic slideshow.

Transform

gallery.transform(mode);

Switches between slideshow and pin-board.

mode : {integer} - The index of the mode.

  • 0 - Slideshow mode
  • 1 - Pin-board mode

License

This work is licensed under a MIT License. The latest version of this and other scripts by the same author can be found on Github.

photo-gallery's People

Stargazers

 avatar  avatar Victor M avatar  avatar Basma Elshoky+ avatar  avatar Ilya avatar Jenny Qian avatar  avatar Shun Yamaguchi avatar maitokuwahara avatar Lajpat Shah avatar Carabineiro avatar

Watchers

James Cloos avatar Maurice van Creij avatar Carabineiro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.