
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
mini-lightbox
Advanced tools
Minimalist image lightbox
Check out the demo page.
<img id="myImage" src="myImage.png" alt="Some title">
<script>
new MiniLightbox("#myImage");
</script>
If you need more stuff (e.g. animations etc), you need to create custom handlers (customClose
and customOpen
handlers). Works like a charm with animate.css library. :smile:
MiniLightbox.customClose = function () {
var self = this;
self.img.classList.add("animated", "fadeOutDown");
setTimeout(function () {
self.box.classList.add("animated", "fadeOut");
setTimeout(function () {
self.box.classList.remove("animated", "fadeOut");
self.img.classList.remove("animated", "fadeOutDown");
self.box.style.display = "none";
}, 500);
}, 500);
// prevent default library behavior
return false;
};
MiniLightbox.customOpen = function () {
this.box.classList.add("animated", "fadeIn");
this.img.classList.add("animated", "fadeInUp");
};
data-image-opened
attributeIf data-image-opened
attribute is provided in img
element, it will be used for the path of the image when the popup is opened.
<img id="myImage" data-image-opened="./big.png" src="small.png" alt="Some title">
If images are added dynamically, you need to use delegation:
new MiniLightbox({
selector: ".content img"
// the common container where the images are appended
, delegation: "html"
});
Check out the dist
directory to download the needed files and include them on your page.
If you're using this module in a CommonJS environment, you can install it from npm
and require
it:
$ npm i --save mini-lightbox
MiniLightbox(options)
Initializes the lightbox according to the options.
Callbacks:
The following methods can be used to modify the default behavior:
Minilightbox.customOpen
(Function): If it's a function, it will be
called then the lightbox is opened. If it returns false
, the default
behavior will be prevented.Minilightbox.customClose
(Function): If it's a function, it will be
called then the lightbox is closed. If it returns false
, the default
behavior will be prevented.options
: An object containing the following fields:selector
(String): The image query selector.delegation
(String): The image container where to handle the delegation.close(id)
Closes the lightboxes.
id
: The lightbox id. If not provided, it will close all the opened lightboxes.open(id)
Opens the lightbox. This is called internally.
id
: The lightbox id.Have an idea? Found a bug? See how to contribute.
Another way to support the development of my open-source modules is to set up a recurring donation, via Patreon. :rocket:
PayPal donations are appreciated too! Each dollar helps.
Thanks! :heart:
FAQs
Minimalist image lightbox
The npm package mini-lightbox receives a total of 106 weekly downloads. As such, mini-lightbox popularity was classified as not popular.
We found that mini-lightbox demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.