{"id":13624360,"url":"https://github.com/deoostfrees/Parvus","last_synced_at":"2025-04-15T21:30:54.657Z","repository":{"id":38190208,"uuid":"301515486","full_name":"deoostfrees/Parvus","owner":"deoostfrees","description":"An open source, dependency free image lightbox with the goal of being accessible.","archived":false,"fork":false,"pushed_at":"2024-05-01T17:36:57.000Z","size":4697,"stargazers_count":407,"open_issues_count":2,"forks_count":14,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-01T18:35:08.413Z","etag":null,"topics":["a11y","accessibility","dependency-free","javascript","lightbox","vanilla"],"latest_commit_sha":null,"homepage":"https://codepen.io/collection/DwLBpz","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/deoostfrees.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["deoostfrees"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-10-05T19:18:06.000Z","updated_at":"2024-06-04T09:39:01.410Z","dependencies_parsed_at":"2023-11-10T21:25:59.415Z","dependency_job_id":"26a6666a-e855-450f-80b7-6ec133c09c30","html_url":"https://github.com/deoostfrees/Parvus","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deoostfrees%2FParvus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deoostfrees%2FParvus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deoostfrees%2FParvus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deoostfrees%2FParvus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deoostfrees","download_url":"https://codeload.github.com/deoostfrees/Parvus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223685219,"owners_count":17185803,"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":["a11y","accessibility","dependency-free","javascript","lightbox","vanilla"],"created_at":"2024-08-01T21:01:41.724Z","updated_at":"2025-04-15T21:30:54.651Z","avatar_url":"https://github.com/deoostfrees.png","language":"JavaScript","readme":"# Parvus\n\nOverlays suck, but if you need one, consider using Parvus. Parvus is an open source, dependency free image lightbox with the goal of being accessible.\n\n![Screenshot of Parvus. It shows the first picture of a gallery.](https://rqrauhvmra.com/parvus/parvus.png)\n\n[Open in CodePen](https://codepen.io/collection/DwLBpz)\n\n## Table of Contents\n\n- [Installation](#installation)\n  - [Download](#download)\n  - [Package Managers](#package-managers)\n- [Usage](#usage)\n  - [Captions](#captions)\n  - [Gallery](#gallery)\n  - [Responsive Images](#responsive-images)\n  - [Localization](#localization)\n- [Options](#options)\n- [API](#api)\n- [Events](#events)\n- [Browser Support](#browser-support)\n\n## Installation\n\n### Download\n\n- CSS:\n  - `dist/css/parvus.min.css` (minified) or\n  - `dist/css/parvus.css` (un-minified)\n- JavaScript:\n  - `dist/js/parvus.min.js` (minified) or\n  - `dist/js/parvus.js` (un-minified)\n\nLink the `.css` and `.js` files in your HTML:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003e\n  \u003ctitle\u003ePage title\u003c/title\u003e\n\n  \u003c!-- CSS --\u003e\n  \u003clink href=\"path/to/parvus.min.css\" rel=\"stylesheet\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- HTML content --\u003e\n\n  \u003c!-- JS --\u003e\n  \u003cscript src=\"path/to/parvus.min.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Package Managers\n\nYou can also install Parvus using npm or yarn:\n\n```sh\nnpm install parvus\n```\n\nor\n\n```sh\nyarn add parvus\n```\n\nAfter installation, import Parvus into your JavaScript codebase:\n\n```js\nimport Parvus from 'parvus'\n```\n\nBe sure to include the corresponding SCSS or CSS file.\n\n## Usage\n\nLink a thumbnail image with the class `lightbox` to a larger image:\n\n```html\n\u003ca href=\"path/to/image.jpg\" class=\"lightbox\"\u003e\n  \u003cimg src=\"path/to/thumbnail.jpg\" alt=\"\"\u003e\n\u003c/a\u003e\n```\n\nInitialize the script:\n\n```js\nconst prvs = new Parvus()\n```\n\n### Captions\n\nTo show a caption under the image, add a `data-caption` attribute:\n\n```html\n\u003ca href=\"path/to/image.jpg\" class=\"lightbox\" data-caption=\"I'm a caption\"\u003e\n  \u003cimg src=\"path/to/thumbnail.jpg\" alt=\"\"\u003e\n\u003c/a\u003e\n```\n\nAlternatively, set the option `captionsSelector` to select captions from an element's innerHTML:\n\n```html\n\u003ca href=\"path/to/image.jpg\" class=\"lightbox\"\u003e\n  \u003cfigure class=\"figure\"\u003e\n    \u003cimg src=\"path/to/thumbnail.jpg\" alt=\"\"\u003e\n\n    \u003cfigcaption class=\"figure__caption\"\u003e\n      \u003cp\u003eI'm a caption\u003c/p\u003e\n    \u003c/figcaption\u003e\n  \u003c/figure\u003e\n\u003c/a\u003e\n```\n\n```js\nconst prvs = new Parvus({\n  captionsSelector: '.figure__caption',\n})\n```\n\n### Gallery\n\nTo group related images into a set, add a `data-group` attribute:\n\n```html\n\u003ca href=\"path/to/image.jpg\" class=\"lightbox\" data-group=\"Berlin\"\u003e\n  \u003cimg src=\"path/to/thumbnail.jpg\" alt=\"\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"path/to/image_2.jpg\" class=\"lightbox\" data-group=\"Berlin\"\u003e\n  \u003cimg src=\"path/to/thumbnail_2.jpg\" alt=\"\"\u003e\n\u003c/a\u003e\n\n//...\n\n\u003ca href=\"path/to/image_8.jpg\" class=\"lightbox\" data-group=\"Kassel\"\u003e\n  \u003cimg src=\"path/to/thumbnail_8.jpg\" alt=\"\"\u003e\n\u003c/a\u003e\n```\n\nAlternatively, set the option `gallerySelector` to group all images with a specific class within a selector:\n\n```html\n\u003cdiv class=\"gallery\"\u003e\n  \u003ca href=\"path/to/image.jpg\" class=\"lightbox\"\u003e\n    \u003cimg src=\"path/to/thumbnail.jpg\" alt=\"\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"path/to/image_2.jpg\" class=\"lightbox\"\u003e\n    \u003cimg src=\"path/to/thumbnail_2.jpg\" alt=\"\"\u003e\n  \u003c/a\u003e\n\n  // ...\n\u003c/div\u003e\n```\n\n```js\nconst prvs = new Parvus({\n  gallerySelector: '.gallery',\n})\n```\n\n### Responsive Images\n\nSpecify different image sources and sizes using the `data-srcset` and `data-sizes` attributes:\n\n```html\n\u003ca href=\"path/to/image.jpg\" class=\"lightbox\"\n\ndata-srcset=\"path/to/small.jpg 700w,\n             path/to/medium.jpg 1000w,\n             path/to/large.jpg 1200w\"\n\ndata-sizes=\"(max-width: 75em) 100vw,\n            75em\"\n\u003e\n  \u003cimg src=\"path/to/thumbnail.jpg\" alt=\"\"\u003e\n\u003c/a\u003e\n```\n\n### Localization\n\nImport the language module and set it as an option for localization:\n\n```js\nimport de from 'parvus/src/l10n/de'\n\nconst prvs = new Parvus({\n  l10n: de\n})\n```\n\n## Options\n\nCustomize Parvus by passing an options object when initializing:\n\n```js\nconst prvs = new Parvus({\n  // Clicking outside does not close Parvus\n  docClose: false\n})\n```\n\nAvailable options include:\n\n```js\n{\n  // Selector for elements that trigger Parvus\n  selector: '.lightbox',\n\n  // Selector for a group of elements combined as a gallery, overrides the `data-group` attribute.\n  gallerySelector: null,\n\n  // Display zoom indicator\n  zoomIndicator: true,\n\n  // Display captions if available\n  captions: true,\n\n  // Selector for the element where the caption is displayed; use \"self\" for the `a` tag itself.\n  captionsSelector: 'self',\n\n  // Attribute to get the caption from\n  captionsAttribute: 'data-caption',\n\n  // Clicking outside closes Parvus\n  docClose: true,\n\n  // Close Parvus by swiping up/down\n  swipeClose: true,\n\n  // Accept mouse events like touch events (click and drag to change slides)\n  simulateTouch: true,\n\n  // Touch dragging threshold in pixels\n  threshold: 100,\n\n  // Hide browser scrollbar\n  hideScrollbar: true,\n\n  // Icons\n  lightboxIndicatorIcon: '\u003csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"\u003e\u003cpath d=\"M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3\"/\u003e\u003c/svg\u003e',\n  previousButtonIcon: '\u003csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"\u003e\u003cpath stroke=\"none\" d=\"M0 0h24v24H0z\"/\u003e\u003cpolyline points=\"15 6 9 12 15 18\" /\u003e\u003c/svg\u003e',\n  nextButtonIcon: '\u003csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"\u003e\u003cpath stroke=\"none\" d=\"M0 0h24v24H0z\"/\u003e\u003cpolyline points=\"9 6 15 12 9 18\" /\u003e\u003c/svg\u003e',\n  closeButtonIcon: '\u003csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"\u003e\u003cpath d=\"M18 6L6 18M6 6l12 12\"/\u003e\u003c/svg\u003e',\n\n  // Localization of strings\n  l10n: en\n}\n```\n\n## API\n\nParvus provides the following API functions:\n\n| Function | Description |\n| --- | --- |\n| `open(element)` | Open the specified `element` (DOM element) |\n| `close()` | Close Parvus |\n| `previous()` | Show the previous image |\n| `next()` | Show the next image |\n| `select(index)` | Select a slide with the specified `index` (integer) |\n| `add(element)` | Add the specified `element` (DOM element) |\n| `remove(element)` | Remove the specified `element` (DOM element) |\n| `destroy()` | Destroy Parvus |\n| `isOpen()` | Check if Parvus is currently open |\n| `currentIndex()` | Get the index of the currently displayed slide |\n\n## Events\n\nBind and unbind events using the `.on()` and `.off()` methods:\n\n```js\nconst prvs = new Parvus()\n\nconst listener = () =\u003e {\n  console.log('eventName happened')\n}\n\n// Bind event listener\nprvs.on(eventName, listener)\n\n// Unbind event listener\nprvs.off(eventName, listener)\n```\n\nAvailable events:\n\n| eventName | Description |\n| --- | --- |\n| `open` | Triggered after Parvus has opened |\n| `select` | Triggered when a slide is selected |\n| `close` | Triggered after Parvus has closed |\n| `destroy` | Triggered after Parvus has destroyed |\n\n## Browser Support\n\nParvus is supported on the latest versions of the following browsers:\n\n- Chrome\n- Edge\n- Firefox\n- Safari\n","funding_links":["https://github.com/sponsors/deoostfrees"],"categories":["javascript","JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeoostfrees%2FParvus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeoostfrees%2FParvus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeoostfrees%2FParvus/lists"}