All Projects → electerious → Basiclightbox

electerious / Basiclightbox

Licence: mit
The lightest lightbox ever made.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Basiclightbox

react-layer-stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 158 (-47.16%)
Mutual labels:  modal, lightbox, popup
Ngx Gallery
Angular Gallery, Carousel and Lightbox
Stars: ✭ 417 (+39.46%)
Mutual labels:  image, modal, lightbox
Jbox
jBox is a jQuery plugin that makes it easy to create customizable tooltips, modal windows, image galleries and more.
Stars: ✭ 1,251 (+318.39%)
Mutual labels:  modal, popup, lightbox
Mediumlightbox
Nice and elegant way to add zooming functionality for images, inspired by medium.com
Stars: ✭ 671 (+124.41%)
Mutual labels:  image, modal, lightbox
React Layer Stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 152 (-49.16%)
Mutual labels:  modal, popup, lightbox
React Modal Image
A tiny React component providing modal image Lightbox.
Stars: ✭ 97 (-67.56%)
Mutual labels:  image, modal, lightbox
Body Scroll Lock
Body scroll locking that just works with everything 😏
Stars: ✭ 3,357 (+1022.74%)
Mutual labels:  modal, lightbox
MultiDialog
MultiDialog utilizes jQuery UI Dialog Widget for a full featured Modalbox / Lightbox application.
Stars: ✭ 23 (-92.31%)
Mutual labels:  modal, lightbox
jpopup
Simple lightweight (<2kB) javascript popup modal plugin
Stars: ✭ 27 (-90.97%)
Mutual labels:  modal, popup
react-spring-bottom-sheet
Accessible ♿️, Delightful ✨, & Fast 🚀
Stars: ✭ 604 (+102.01%)
Mutual labels:  modal, popup
Silentbox
A lightbox inspired Vue.js component.
Stars: ✭ 196 (-34.45%)
Mutual labels:  image, lightbox
LSDialogViewController
Custom Dialog for iOS written in Swift
Stars: ✭ 74 (-75.25%)
Mutual labels:  modal, popup
vue-modal
A customizable, stackable, and lightweight modal component for Vue.
Stars: ✭ 96 (-67.89%)
Mutual labels:  modal, popup
Popbox.js
A tiny and simple stackable modal plugin for web apps
Stars: ✭ 295 (-1.34%)
Mutual labels:  modal, popup
fancybox
jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.
Stars: ✭ 7,261 (+2328.43%)
Mutual labels:  modal, lightbox
body-scroll-freezer
↕️ Dependency-free JS module to freeze body scroll when opening modal box
Stars: ✭ 22 (-92.64%)
Mutual labels:  modal, lightbox
vue-modal
Reusable Modal component, supports own custom HTML, text and classes.
Stars: ✭ 29 (-90.3%)
Mutual labels:  modal, popup
react-native-popup
React Native Animated Popup Modal
Stars: ✭ 19 (-93.65%)
Mutual labels:  modal, popup
react-redux-modal-flex
[DEPRECATED] Make easy a modal/popup with Redux
Stars: ✭ 14 (-95.32%)
Mutual labels:  modal, popup
plain-modal
The simple library for customizable modal window.
Stars: ✭ 21 (-92.98%)
Mutual labels:  modal, popup

basicLightbox

Donate via PayPal

The lightest lightbox ever made.

Contents

Demos

Name Description Link
Default Includes most features. Try it on CodePen
DOM elements/nodes Use DOM elements/nodes in basicLightbox. Try it on CodePen
Create element Use .createElement() with basicLightbox. Try it on CodePen
Events Multiple ways to handle events. Try it on CodePen

Features

  • Works in all modern browsers and IE11 (with polyfills)
  • Supports images, videos, iframes and any kind of HTML
  • Creates a lightbox from a string or from a DOM element/node
  • Zero dependencies
  • CommonJS and AMD support
  • Simple JS API

Requirements

basicLightbox depends on the following browser features and APIs:

Some of these APIs are capable of being polyfilled in older browsers. Check the linked resources above to determine if you must polyfill to achieve your desired level of browser support.

Setup

We recommend installing basicLightbox using npm or yarn.

npm install basiclightbox
yarn add basiclightbox

Include the CSS file in the head tag and the JS file at the end of your body tag…

<link rel="stylesheet" href="dist/basicLightbox.min.css">
<script src="dist/basicLightbox.min.js"></script>

…or skip the JS file and use basicLightbox as a module:

const basicLightbox = require('basiclightbox')
import * as basicLightbox from 'basiclightbox'

API

.create(content, opts)

Creates a new basicLightbox instance.

Be sure to assign your instance to a variable. Using your instance, you can…

  • …show and hide the lightbox.
  • …check if the the lightbox is visible.
  • …modify the content of the lightbox.

Examples:

const instance = basicLightbox.create(`
	<h1>Dynamic Content</h1>
	<p>You can set the content of the lightbox with JS.</p>
`)
const instance = basicLightbox.create(`
	<h1>Not closable</h1>
	<p>It's not possible to close this lightbox with a click.</p>
`, {
	closable: false
})
const instance = basicLightbox.create(
	document.querySelector('#template')
)

Parameters:

  • content {Node|String} Content of the lightbox.
  • opts {?Object} An object of options.

Returns:

  • {Object} The created instance.

.visible()

Returns true when a lightbox is visible. Also returns true when a lightbox is currently in the process of showing/hiding and not fully visible/hidden, yet.

Example:

const visible = basicLightbox.visible()

Returns:

  • {Boolean} Visibility of any lightbox.

Instance API

Each basicLightbox instance has a handful of handy functions. Below are all of them along with a short description.

.show(cb)

Shows a lightbox instance.

Examples:

instance.show()
instance.show(() => console.log('lightbox now visible'))

Parameters:

  • cb(instance) {?Function} A function that gets executed as soon as the lightbox starts to fade in.

.close(cb)

Closes a lightbox instance.

Examples:

instance.close()
instance.close(() => console.log('lightbox not visible anymore'))

Parameters:

  • cb(instance) {?Function} A function that gets executed as soon as the lightbox has been faded out.

.visible()

Returns true when the lightbox instance is visible. Also returns true when the lightbox is currently in the process of showing/hiding and not fully visible/hidden, yet.

Example:

const visible = instance.visible()

Returns:

  • {Boolean} Visibility of lightbox.

.element()

Returns the DOM element/node associated with the instance.

Example:

const elem = instance.element()

Returns:

  • {Node} DOM element/node associated with the instance.

Options

The option object can include the following properties:

{
	/*
	 * Prevents the lightbox from closing when clicking its background.
	 */
	closable: true,
	/*
	 * One or more space separated classes to be added to the basicLightbox element.
	 */
	className: '',
	/*
	 * Function that gets executed before the lightbox will be shown.
	 * Returning false will prevent the lightbox from showing.
	 */
	onShow: (instance) => {},
	/*
	 * Function that gets executed before the lightbox closes.
	 * Returning false will prevent the lightbox from closing.
	 */
	onClose: (instance) => {}
}

Import src/styles/main.scss directly to customize the look of basicLightbox:

$basicLightbox__background: rgba(0, 0, 0, .8); // Background color
$basicLightbox__zIndex: 1000; // Stack order
$basicLightbox__duration: .4s; // Transition duration
$basicLightbox__timing: ease; // Transition timing

@import 'src/styles/main';
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].