{"id":21033461,"url":"https://github.com/electerious/basiclightbox","last_synced_at":"2025-05-16T03:02:12.527Z","repository":{"id":45834145,"uuid":"52428703","full_name":"electerious/basicLightbox","owner":"electerious","description":"The lightest lightbox ever made.","archived":false,"fork":false,"pushed_at":"2022-10-01T13:59:21.000Z","size":128,"stargazers_count":586,"open_issues_count":5,"forks_count":55,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-16T03:01:50.420Z","etag":null,"topics":["image","lightbox","modal","popup","video"],"latest_commit_sha":null,"homepage":"https://basiclightbox.electerious.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/electerious.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"electerious","custom":["https://paypal.me/electerious","https://www.buymeacoffee.com/electerious"]}},"created_at":"2016-02-24T09:05:02.000Z","updated_at":"2025-05-12T14:42:34.000Z","dependencies_parsed_at":"2022-08-12T12:21:14.204Z","dependency_job_id":null,"html_url":"https://github.com/electerious/basicLightbox","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electerious%2FbasicLightbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electerious%2FbasicLightbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electerious%2FbasicLightbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electerious%2FbasicLightbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/electerious","download_url":"https://codeload.github.com/electerious/basicLightbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254459078,"owners_count":22074604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image","lightbox","modal","popup","video"],"created_at":"2024-11-19T12:57:14.385Z","updated_at":"2025-05-16T03:02:12.504Z","avatar_url":"https://github.com/electerious.png","language":"JavaScript","funding_links":["https://github.com/sponsors/electerious","https://paypal.me/electerious","https://www.buymeacoffee.com/electerious","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=CYKBESW577YWE"],"categories":[],"sub_categories":[],"readme":"# basicLightbox\n\n[![Donate via PayPal](https://img.shields.io/badge/paypal-donate-009cde.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=CYKBESW577YWE)\n\nThe lightest lightbox ever made.\n\n## Contents\n\n- [Demos](#demos)\n- [Features](#features)\n- [Requirements](#requirements)\n- [Setup](#setup)\n- [API](#api)\n- [Instance API](#instance-api)\n- [Options](#options)\n\n## Demos\n\n| Name | Description | Link |\n|:-----------|:------------|:------------|\n| Default | Includes most features. | [Try it on CodePen](https://codepen.io/electerious/pen/rLBvGz) |\n| DOM elements/nodes | Use DOM elements/nodes in basicLightbox. | [Try it on CodePen](https://codepen.io/electerious/pen/pOBLxQ) |\n| Create element | Use `.createElement()` with basicLightbox. | [Try it on CodePen](https://codepen.io/electerious/pen/wEZmQy) |\n| Events | Multiple ways to handle events. | [Try it on CodePen](https://codepen.io/electerious/pen/pOBLQQ) |\n\n## Features\n\n- Works in all modern browsers and IE11 ([with polyfills](#requirements))\n- Supports images, videos, iframes and any kind of HTML\n- Creates a lightbox from a string or from a DOM element/node\n- Zero dependencies\n- CommonJS and AMD support\n- Simple JS API\n\n## Requirements\n\nbasicLightbox depends on the following browser features and APIs:\n\n- [Array.from](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)\n- [Node​List​.prototype​.for​Each](https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach)\n- [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)\n- [window.requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame)\n\nSome 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.\n\n## Setup\n\nWe recommend installing basicLightbox using [npm](https://npmjs.com) or [yarn](https://yarnpkg.com).\n\n```sh\nnpm install basiclightbox\n```\n\n```sh\nyarn add basiclightbox\n```\n\nInclude the CSS file in the `head` tag and the JS file at the end of your `body` tag…\n\n```html\n\u003clink rel=\"stylesheet\" href=\"dist/basicLightbox.min.css\"\u003e\n```\n\n```html\n\u003cscript src=\"dist/basicLightbox.min.js\"\u003e\u003c/script\u003e\n```\n\n…or skip the JS file and use basicLightbox as a module:\n\n```js\nconst basicLightbox = require('basiclightbox')\n```\n\n```js\nimport * as basicLightbox from 'basiclightbox'\n```\n\n## API\n\n### .create(content, opts)\n\nCreates a new basicLightbox instance.\n\nBe sure to assign your instance to a variable. Using your instance, you can…\n\n* …show and hide the lightbox.\n* …check if the the lightbox is visible.\n* …modify the content of the lightbox.\n\nExamples:\n\n```js\nconst instance = basicLightbox.create(`\n\t\u003ch1\u003eDynamic Content\u003c/h1\u003e\n\t\u003cp\u003eYou can set the content of the lightbox with JS.\u003c/p\u003e\n`)\n```\n\n```js\nconst instance = basicLightbox.create(`\n\t\u003ch1\u003eNot closable\u003c/h1\u003e\n\t\u003cp\u003eIt's not possible to close this lightbox with a click.\u003c/p\u003e\n`, {\n\tclosable: false\n})\n```\n\n```js\nconst instance = basicLightbox.create(\n\tdocument.querySelector('#template')\n)\n```\n\nParameters:\n\n- `content` `{Node|String}` Content of the lightbox.\n- `opts` `{?Object}` An object of [options](#options).\n\nReturns:\n\n- `{Object}` The created instance.\n\n### .visible()\n\nReturns `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.\n\nExample:\n\n```js\nconst visible = basicLightbox.visible()\n```\n\nReturns:\n\n- `{Boolean}` Visibility of any lightbox.\n\n## Instance API\n\nEach basicLightbox instance has a handful of handy functions. Below are all of them along with a short description.\n\n### .show(cb)\n\nShows a lightbox instance.\n\nExamples:\n\n```js\ninstance.show()\n```\n\n```js\ninstance.show(() =\u003e console.log('lightbox now visible'))\n```\n\nParameters:\n\n- `cb(instance)` `{?Function}` A function that gets executed as soon as the lightbox starts to fade in.\n\n### .close(cb)\n\nCloses a lightbox instance.\n\nExamples:\n\n```js\ninstance.close()\n```\n\n```js\ninstance.close(() =\u003e console.log('lightbox not visible anymore'))\n```\n\nParameters:\n\n- `cb(instance)` `{?Function}` A function that gets executed as soon as the lightbox has been faded out.\n\n### .visible()\n\nReturns `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.\n\nExample:\n\n```js\nconst visible = instance.visible()\n```\n\nReturns:\n\n- `{Boolean}` Visibility of lightbox.\n\n### .element()\n\nReturns the DOM element/node associated with the instance.\n\nExample:\n\n```js\nconst elem = instance.element()\n```\n\nReturns:\n\n- `{Node}` DOM element/node associated with the instance.\n\n## Options\n\nThe option object can include the following properties:\n\n```js\n{\n\t/*\n\t * Prevents the lightbox from closing when clicking its background.\n\t */\n\tclosable: true,\n\t/*\n\t * One or more space separated classes to be added to the basicLightbox element.\n\t */\n\tclassName: '',\n\t/*\n\t * Function that gets executed before the lightbox will be shown.\n\t * Returning false will prevent the lightbox from showing.\n\t */\n\tonShow: (instance) =\u003e {},\n\t/*\n\t * Function that gets executed before the lightbox closes.\n\t * Returning false will prevent the lightbox from closing.\n\t */\n\tonClose: (instance) =\u003e {}\n}\n```\n\nImport `src/styles/main.scss` directly to customize the look of basicLightbox:\n\n```scss\n$basicLightbox__background: rgba(0, 0, 0, .8); // Background color\n$basicLightbox__zIndex: 1000; // Stack order\n$basicLightbox__duration: .4s; // Transition duration\n$basicLightbox__timing: ease; // Transition timing\n\n@import 'src/styles/main';\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felecterious%2Fbasiclightbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felecterious%2Fbasiclightbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felecterious%2Fbasiclightbox/lists"}