Giter Site home page Giter Site logo

seanwash / luminous Goto Github PK

View Code? Open in Web Editor NEW

This project forked from strawdynamics/luminous

0.0 3.0 0.0 170 KB

A simple, lightweight, no-dependencies JavaScript lightbox.

Home Page: https://blog.imgix.com/2016/01/06/better-lightbox-zoom-viewer-with-imgix.html

License: BSD 2-Clause "Simplified" License

JavaScript 80.70% CSS 13.66% HTML 5.65%

luminous's Introduction

imgix logo

Luminous Build Status Slack Status

A simple, lightweight, no-dependencies JavaScript image lightbox.

Installation

  • NPM: npm install luminous-lightbox
  • Bower: bower install luminous
  • Manual: Download and use dist/luminous.min.js or dist/luminous.js

If your build process will re-run dist/Luminous.js or dist/Luminous.min.js through Browserify, you'll need to add noParse: ['luminous-lightbox'] to your Browserify config. If you skip this, Browserify will attempt to re-require Luminous' dependencies which have already been inlined.

Usage

Once you've installed Luminous via one of the above methods, you're ready to get started. There are no dependencies, so you can just start making cool stuff. Check out the announcement blog post for a demo, or take a peek here: https://imgix.github.io/luminous. Here's an example of the most basic possible implementation:

<a href="http://assets.imgix.net/dog.png?w=1600">
  <img alt="A dog!" src="http://assets.imgix.net/dog.png?w=400">
</a>
new Luminous(document.querySelector('a'));

LuminousGallery Usage

Luminous supports gallery-style navigation using the LuminousGallery class. It works nearly the same as Luminous, but has a slightly different method of instantiation.

<ul>
  <li>
    <a class="gallery-demo" href="http://assets.imgix.net/unsplash/coyote.jpg?w=1600">
      <img src="http://assets.imgix.net/unsplash/coyote.jpg?w=100" alt="Coyote">
    </a>
  </li>
  <li>
    <a class="gallery-demo" href="http://assets.imgix.net/unsplash/motorbike.jpg?w=1600">
      <img src="http://assets.imgix.net/unsplash/motorbike.jpg?w=100" alt="Motorbike">
    </a>
  </li>
  <li>
    <a class="gallery-demo" href="http://assets.imgix.net/unsplash/hotairballoon.jpg?w=1600">
      <img src="http://assets.imgix.net/unsplash/hotairballoon.jpg?w=100" alt="Hot air balloon">
    </a>
  </li>
</ul>
new LuminousGallery(document.querySelectorAll('.gallery-demo'));

Options / Defaults

Here's an example of using Luminous with a custom configuration. All of the listed options are displayed with their default value.

var options = {
	// Prefix for generated element class names (e.g. `my-ns` will
	// result in classes such as `my-ns-lightbox`. Default `lum-`
	// prefixed classes will always be added as well.
	namespace: null,
	// Which attribute to pull the lightbox image source from.
	sourceAttribute: 'href',
	// Which attribute to pull the caption from, if any.
	captionAttribute: null,
	// The event to listen to on the _trigger_ element: triggers opening.
	openTrigger: 'click',
	// The event to listen to on the _lightbox_ element: triggers closing.
	closeTrigger: 'click',
	// Allow closing by pressing escape.
	closeWithEscape: true,
	// Automatically close when the page is scrolled.
	closeOnScroll: false,
	// A selector defining what to append the lightbox element to.
	appendToSelector: 'body',
	// If present (and a function), this will be called
	// whenever the lightbox is opened.
	onOpen: null,
	// If present (and a function), this will be called
	// whenever the lightbox is closed.
	onClose: null,
	// When true, adds the `imgix-fluid` class to the `img`
	// inside the lightbox. See https://github.com/imgix/imgix.js
	// for more information.
	includeImgixJSClass: false,
	// Add base styles to the page. See the "Theming"
	// section of README.md for more information.
	injectBaseStyles: true,
};

new Luminous(document.querySelector('a'), options);

LuminousGallery Options / Defaults

LuminousGallery supports two sets of options arguments. The first set is specific to the gallery itself, and the second specifies the options that get passed to its child Luminous instances.

var galleryOpts = {
	// Whether pressing the arrow keys should move to the next/previous slide.
	arrowNavigation: true,
};

var luminousOpts = {
	// These options have the same defaults and potential values as the Luminous class.
}

new LuminousGallery(document.querySelectorAll('a'), galleryOpts, luminousOpts);

Theming

By default, Luminous injects an extremely basic set of styles into the page. You will almost certainly want to extend these basic styles for a prettier, more usable experience that matches your site. There is an included basic theme that may meet your needs, or at least give a good example of how to build out your own custom styles. The namespace option can be used as a way to easily apply different themes to specific instances of Luminous.

If you need to do something very out of the ordinary, or just prefer to include the default styles in CSS yourself, you can pass injectBaseStyles: false when instantiating a new instance of Luminous. Please note that if you disable the included base styles, you will still need to provide an animation for .lum-lightbox.lum-opening and .lum-lightbox.lum-closing (this can be a "noop" style animation, as seen in the base styles source).

Browser Support

We support the latest version of Google Chrome (which automatically updates whenever it detects that a new version of the browser is available). We also support the current and previous major releases of desktop Firefox, Internet Explorer, and Safari on a rolling basis. Mobile support is tested on the most recent minor version of the current and previous major release for the default browser on iOS and Android (e.g., iOS 9.2 and 8.4). Each time a new version is released, we begin supporting that version and stop supporting the third most recent version.

Meta

Luminous was made by imgix. It's licensed under the BSD 2-Clause license (see the license file for more info). Any contribution is absolutely welcome, but please review the contribution guidelines before getting started.

luminous's People

Contributors

paulstraw avatar bertramakers avatar seanwash avatar rakuista avatar jackmcdade avatar

Watchers

 avatar James Cloos avatar  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.