Giter Club home page Giter Club logo

lightbox's Introduction

Lightbox

CircleCI

An implementation comprising chainable lightbox customisations, resulting in a highly flexible way of composing new lightboxes from pre-existing ones.

Examples

Basic, single instance

  • can be activated by an element
  • includes a callback that's fired when the lightbox is opened
  • attaches to a DOM node with an ID attribute value of 'demo-one'
lightbox
  .settings({ DOMActivation: true })
  .on('open', function() {
    console.log('it has opened!')
  })
  .attach('demo-one')

Instance composition

It's easy to compose lightbox from another predefined instance.

  • includes a callback that's fired when the lightbox becomes attached to it's DOM node
var myLightbox = lightbox
  .on('attach', function() {
    console.log('it has become attached!');
  })
  • compose instance from lightbox
  • includes a callback that's fired when the lightbox becomes attached to it's DOM node
  • opens upon instantiation
var contextSpecificLightbox = myLightbox
  .on('attach', function() {
    console.log('the new instance has become attach!');
  })
  .attach('demo-two')
  .open()

API

Defining settings

.settings([options])

options {Object} Optional

The options hash can include the following key/value combinations:

  • DOMActivation {Boolean}: Indicates that there's an associated DOM node that, when clicked, will invoke the lightbox. This DOM node must have a data-lightbox-activation-control attribute value that corresponds to the id value of the element that contains the lightbox content.

Observer

.on(eventType, callback)

eventType {String} attach | open | close
callback {Function} The callback that will be invoked when the specified eventType has been invoked

Allows you to register a callback against the specified eventType. The current lightbox instance is provided as the callback parameter, giving you access to all the current settings (at that point in the chain) and methods.

You can of course register multiple callbacks against a single eventType throughout your composition chain. These will be executed in the order they're registered.

DOM interaction

.attach(id)

id {String} The ID of the content that the lightbox will encapsulate

Creates the resulting DOM instantiation based on predefined configuration set earlier in the chain. For this reason, this method should only be called at the end of a chain.

.open([context])

context {String}, Optional, Default: system

Opens the lightbox. The context gives context as to which lightbox component called the method. Internal components currently supported are:

  • Close button: close
  • Viewport overlay: overlay

In this way, when calling .open() yourself, have the chance to include a custom context flag. For example:

lightbox
  .on('open', function(lightbox) {
    console.log('See! You can ' + lightbox.config.context);
  })
  .on('attach', function(lightbox) {
    instance.open('do-it-yourself');
  })
  .attach('demo-two')

.close([context])

context {String}, Optional, Default: system

Closes the lightbox. The context gives context as to which lightbox component called the method. Internal components currently supported are:

lightbox's People

Contributors

jameshopkins avatar

Watchers

James Cloos avatar  avatar

lightbox's Issues

Support close transitions

This is likely dependent on using the skyComponents.event component, so we have access to animationend

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.