├── .babelrc
├── .eslintignore
├── .eslintrc.json
├── .github
├── dependabot.yml
└── workflows
│ └── ci.yml
├── .gitignore
├── .husky
└── pre-commit
├── .npmignore
├── .prettierignore
├── .prettierrc
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE.md
├── LICENSE
├── README.md
├── __mocks__
└── fileMock.js
├── examples
├── cats
│ ├── app.js
│ ├── images
│ │ ├── 1.jpg
│ │ ├── 1_thumb.jpg
│ │ ├── 2.jpg
│ │ ├── 2_thumb.jpg
│ │ ├── 3.jpg
│ │ ├── 3_thumb.jpg
│ │ ├── 4.jpg
│ │ └── 4_thumb.jpg
│ ├── index.html
│ ├── index.js
│ └── stylesheets
│ │ ├── app.css
│ │ └── vendor
│ │ ├── github-light.css
│ │ └── stylesheet.css
└── shared
│ └── favicon
│ ├── apple-touch-icon.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── favicon.ico
│ └── safari-pinned-tab.svg
├── index.d.ts
├── jest.config.js
├── package.json
├── rollup.config.js
├── src
├── __tests__
│ ├── __snapshots__
│ │ └── react-image-lightbox.spec.js.snap
│ └── react-image-lightbox.spec.js
├── constant.js
├── index.js
├── react-image-lightbox.js
├── style.css
└── util.js
├── svg
├── left_arrow.svg
├── right_arrow.svg
├── x.svg
├── zoom_in.svg
└── zoom_out.svg
├── test-config
├── shim.js
└── test-setup.js
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "targets": {
7 | "browsers": ["last 2 versions", "ie >= 9"]
8 | }
9 | }
10 | ],
11 | "@babel/preset-react"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | build
3 | dist
4 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["airbnb", "prettier", "prettier/react"],
3 | "env": {
4 | "jest": true
5 | },
6 | "rules": {
7 | "jsx-a11y/control-has-associated-label": 0,
8 | "react/destructuring-assignment": 0,
9 | "react/jsx-filename-extension": 0,
10 | "react/jsx-props-no-spreading": 0,
11 | "react/prop-types": 0,
12 | "react/sort-comp": 0
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: npm
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | open-pull-requests-limit: 10
8 | ignore:
9 | - dependency-name: "@babel/core"
10 | versions:
11 | - 7.12.10
12 | - 7.12.13
13 | - 7.12.16
14 | - 7.12.17
15 | - 7.13.1
16 | - 7.13.10
17 | - 7.13.13
18 | - 7.13.14
19 | - 7.13.15
20 | - 7.13.8
21 | - dependency-name: y18n
22 | versions:
23 | - 4.0.1
24 | - 4.0.2
25 | - dependency-name: "@babel/preset-env"
26 | versions:
27 | - 7.12.11
28 | - 7.12.13
29 | - 7.12.16
30 | - 7.12.17
31 | - 7.13.0
32 | - 7.13.10
33 | - 7.13.12
34 | - 7.13.5
35 | - 7.13.8
36 | - 7.13.9
37 | - dependency-name: husky
38 | versions:
39 | - 4.3.8
40 | - 5.0.9
41 | - 5.1.0
42 | - 5.1.1
43 | - 5.1.2
44 | - 5.1.3
45 | - 5.2.0
46 | - dependency-name: react-modal
47 | versions:
48 | - 3.12.1
49 | - dependency-name: lodash
50 | versions:
51 | - 4.17.20
52 | - dependency-name: elliptic
53 | versions:
54 | - 6.5.3
55 | - dependency-name: handlebars
56 | versions:
57 | - 4.7.6
58 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 |
9 | jobs:
10 | test:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - name: Checkout
14 | uses: actions/checkout@v2
15 |
16 | - name: Setup NodeJS
17 | uses: actions/setup-node@v2
18 |
19 | - name: Install deps
20 | run: yarn
21 |
22 | - name: Run tests
23 | run: npm test -- --coverage
24 |
25 | - name: Coveralls
26 | uses: coverallsapp/github-action@master
27 | with:
28 | github-token: ${{ secrets.GITHUB_TOKEN }}
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | npm-debug.log
4 |
5 | # Editor and other tmp files
6 | *.swp
7 | *.un~
8 | *.iml
9 | *.ipr
10 | *.iws
11 | *.sublime-*
12 | .idea/
13 | *.DS_Store
14 |
15 | # Build directories (Will be preserved by npm)
16 | dist
17 | build
18 | /style.css
19 | /style.css.map
20 | .cache
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | . "$(dirname "$0")/_/husky.sh"
3 |
4 | yarn pretty-quick --staged
5 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | bower.json
2 | src/examples
3 | svg
4 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | CHANGELOG.md
2 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "trailingComma": "es5"
4 | }
5 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4 |
5 | ### [5.1.4](https://github.com/frontend-collective/react-image-lightbox/compare/v5.1.3...v5.1.4) (2021-07-13)
6 |
7 | ### [5.1.3](https://github.com/frontend-collective/react-image-lightbox/compare/v5.1.2...v5.1.3) (2021-07-13)
8 |
9 | ### [5.1.2](https://github.com/frontend-collective/react-image-lightbox/compare/v5.1.1...v5.1.2) (2021-07-13)
10 |
11 |
12 | ### Bug Fixes
13 |
14 | * fix cross origin iframe detection ([6683a29](https://github.com/frontend-collective/react-image-lightbox/commit/6683a29639f0df2609849d9c71f7da0fa08a4882))
15 |
16 | ### [5.1.1](https://github.com/frontend-collective/react-image-lightbox/compare/v5.1.0...v5.1.1) (2019-11-12)
17 |
18 |
19 | ### Bug Fixes
20 |
21 | * allow React.ReactNode as imageTitle and imageCaption in TypeScript projects ([#158](https://github.com/frontend-collective/react-image-lightbox/issues/158)) ([f1858a3](https://github.com/frontend-collective/react-image-lightbox/commit/f1858a3efe25b66b850565b308688669bd7bab66))
22 | * demo parcel site on github pages ([822140e](https://github.com/frontend-collective/react-image-lightbox/commit/822140ed665f55f664c1a5ea851f6b3aeaed31db))
23 | * don't prevent default inside a passive listener ([b2b6a79](https://github.com/frontend-collective/react-image-lightbox/commit/b2b6a798671de7027635123baec8584e3fefaaf2))
24 | * fix getOrigin issue within iFrames ([#175](https://github.com/frontend-collective/react-image-lightbox/issues/175)) ([f290cb3](https://github.com/frontend-collective/react-image-lightbox/commit/f290cb344ac89f6359b39c0fd4ab8fe00bb36205)), closes [#136](https://github.com/frontend-collective/react-image-lightbox/issues/136)
25 | * fix lint ([c2acf2c](https://github.com/frontend-collective/react-image-lightbox/commit/c2acf2ccd86610ad89f3af497e4eefc911da68ac))
26 |
27 |
28 |
29 | # [5.1.0](https://github.com/frontend-collective/react-image-lightbox/compare/v5.0.0...v5.1.0) (2018-12-10)
30 |
31 | ### Bug Fixes
32 |
33 | - change focus when zoom buttons becomes disabled to be able to still use arrow keys (fix issue [#132](https://github.com/frontend-collective/react-image-lightbox/issues/132)) ([#135](https://github.com/frontend-collective/react-image-lightbox/issues/135)) ([30ba946](https://github.com/frontend-collective/react-image-lightbox/commit/30ba946))
34 |
35 | ### Features
36 |
37 | - typescript declarations files ([#116](https://github.com/frontend-collective/react-image-lightbox/issues/116)) ([357a801](https://github.com/frontend-collective/react-image-lightbox/commit/357a801))
38 |
39 |
40 |
41 | # [5.0.0](https://github.com/frontend-collective/react-image-lightbox/compare/v4.6.0...v5.0.0) (2018-04-29)
42 |
43 | ### Features
44 |
45 | - migrated away from style-loader ([e74b7c9](https://github.com/frontend-collective/react-image-lightbox/commit/e74b7c9))
46 |
47 | ### BREAKING CHANGES
48 |
49 | - you must import the css for the component yourself,
50 | using `import 'react-image-lightbox/style.css';`. You only need to do this
51 | once in your application.
52 | - Versions of IE earlier than IE 11 are no longer supported.
53 |
54 |
55 |
56 | # [4.6.0](https://github.com/frontend-collective/react-image-lightbox/compare/v4.5.0...v4.6.0) (2018-03-09)
57 |
58 | ### Bug Fixes
59 |
60 | - avoid cross-origin errors from using window.top ([5bb5ac9](https://github.com/frontend-collective/react-image-lightbox/commit/5bb5ac9))
61 |
62 | ### Features
63 |
64 | - onImageLoad API ([b08be00](https://github.com/frontend-collective/react-image-lightbox/commit/b08be00))
65 |
66 |
67 |
68 | # [4.5.0](https://github.com/frontend-collective/react-image-lightbox/compare/v4.4.1...v4.5.0) (2018-01-21)
69 |
70 | ### Features
71 |
72 | - Custom error message prop for when images fail to load ([419998d](https://github.com/frontend-collective/react-image-lightbox/commit/419998d)), closes [#82](https://github.com/frontend-collective/react-image-lightbox/issues/82)
73 |
74 |
75 |
76 | ## [4.4.1](https://github.com/frontend-collective/react-image-lightbox/compare/v4.4.0...v4.4.1) (2018-01-14)
77 |
78 | ### Bug Fixes
79 |
80 | - handle environment with no navigator. Fixes [#97](https://github.com/frontend-collective/react-image-lightbox/issues/97) ([7f36b72](https://github.com/frontend-collective/react-image-lightbox/commit/7f36b72))
81 |
82 |
83 |
84 | # [4.4.0](https://github.com/frontend-collective/react-image-lightbox/compare/v4.3.0...v4.4.0) (2017-12-17)
85 |
86 | ### Bug Fixes
87 |
88 | - silence react-modal warning by setting appElement ([a26d597](https://github.com/frontend-collective/react-image-lightbox/commit/a26d597))
89 |
90 | ### Features
91 |
92 | - allow for override of react-modal props ([45a756d](https://github.com/frontend-collective/react-image-lightbox/commit/45a756d))
93 |
94 |
95 |
96 | # [4.3.0](https://github.com/frontend-collective/react-image-lightbox/compare/v4.2.2...v4.3.0) (2017-10-13)
97 |
98 | ### Bug Fixes
99 |
100 | - Hide orange outline around viewer in Chrome on Android ([359e9bd](https://github.com/frontend-collective/react-image-lightbox/commit/359e9bd))
101 |
102 | ### Features
103 |
104 | - Add react@16 support ([e3e63b6](https://github.com/frontend-collective/react-image-lightbox/commit/e3e63b6))
105 |
106 |
107 |
108 | ## [4.2.2](https://github.com/frontend-collective/react-image-lightbox/compare/v4.2.1...v4.2.2) (2017-10-05)
109 |
110 | ### Bug Fixes
111 |
112 | - Improve rendering on zoom in Safari ([bab9ca1](https://github.com/frontend-collective/react-image-lightbox/commit/bab9ca1))
113 |
114 |
115 |
116 | ## [4.2.1](https://github.com/frontend-collective/react-image-lightbox/compare/v4.1.0...v4.2.1) (2017-09-07)
117 |
118 | ### Bug Fixes
119 |
120 | - Default to null height instead of 0 ([faa996c](https://github.com/frontend-collective/react-image-lightbox/commit/faa996c))
121 |
122 | See the GitHub [Releases](https://github.com/frontend-collective/react-image-lightbox/releases) for information on previous releases.
123 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | - Using welcoming and inclusive language
18 | - Being respectful of differing viewpoints and experiences
19 | - Gracefully accepting constructive criticism
20 | - Focusing on what is best for the community
21 | - Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | - The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | - Trolling, insulting/derogatory comments, and personal or political attacks
28 | - Public or private harassment
29 | - Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | - Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | _Adapted from [bvaughn/react-virtualized/CONTRIBUTING.md](https://github.com/bvaughn/react-virtualized/blob/master/CONTRIBUTING.md)_
2 |
3 | [Bug Reports](#bugs) | [Features Requests](#features) | [Submitting Pull Requests](#pull-requests) | [Running Local Demo](#running-local-demo) | [Running Tests](#running-tests)
4 |
5 | # Contributing to this project
6 |
7 | Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
8 |
9 | Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project.
10 | In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
11 |
12 | ## Using the issue tracker
13 |
14 | The issue tracker is the preferred channel for bug reports but please respect the following restrictions:
15 |
16 | - Please **do not** use the issue tracker for personal support requests.
17 | - Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others.
18 |
19 |
20 |
21 | ## Bug reports
22 |
23 | A bug is a _demonstrable problem_ that is caused by the code in the repository.
24 | Good bug reports are extremely helpful - thank you!
25 |
26 | Guidelines for bug reports:
27 |
28 | 1. **Use the GitHub issue search** — check if the issue has already been reported.
29 | 2. **Check if the issue has been fixed** — try to reproduce it using the latest `master` or development branch in the repository.
30 | 3. **Isolate the problem** — create a [reduced test case](http://css-tricks.com/reduced-test-cases/) and a live example (by forking the [CodeSandbox example](https://codesandbox.io/s/wkw2mjm5l8)).
31 |
32 | A good bug report shouldn't leave others needing to chase you up for more information.
33 | Please try to be as detailed as possible in your report.
34 | Which versions of react-image-lightbox and React are you using?
35 | What steps will reproduce the issue? What browser(s) and OS experience the problem?
36 | What would you expect to be the outcome?
37 | All these details will help people to fix any potential bugs.
38 |
39 | Example:
40 |
41 | > Short and descriptive example bug report title
42 | >
43 | > A summary of the issue and the browser/OS environment in which it occurs.
44 | > If suitable, include the steps required to reproduce the bug.
45 | >
46 | > 1. This is the first step
47 | > 2. This is the second step
48 | > 3. Further steps, etc.
49 | >
50 | > `` - a link to the reduced test case
51 | >
52 | > Any other information you want to share that is relevant to the issue being reported.
53 | > This might include the lines of code that you have identified as causing the bug,
54 | > and potential solutions (and your opinions on their merits).
55 |
56 |
57 |
58 | ## Feature requests
59 |
60 | Feature requests are welcome.
61 | But take a moment to find out whether your idea fits with the scope and aims of the project.
62 | It's up to _you_ to make a strong case to convince the project's developers of the merits of this feature.
63 | Please provide as much detail and context as possible.
64 |
65 |
66 |
67 | ## Pull requests
68 |
69 | Good pull requests - patches, improvements, new features - are a fantastic help.
70 | They should remain focused in scope and avoid containing unrelated commits.
71 |
72 | **Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code, porting to a different language),
73 | otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
74 |
75 | Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage).
76 |
77 | Follow this process if you'd like your work considered for inclusion in the project:
78 |
79 | 1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes:
80 |
81 | ```bash
82 | # Clone your fork of the repo into the current directory
83 | git clone https://github.com//react-image-lightbox
84 | # Navigate to the newly cloned directory
85 | cd react-image-lightbox
86 | # Assign the original repo to a remote called "upstream"
87 | git remote add upstream https://github.com/frontend-collective/react-image-lightbox
88 | ```
89 |
90 | 2. If you cloned a while ago, get the latest changes from upstream:
91 |
92 | ```bash
93 | git checkout master
94 | git pull upstream master
95 | ```
96 |
97 | 3. Install/update dependencies:
98 |
99 | ```bash
100 | npm install
101 | ```
102 |
103 | 4. Create a new topic branch (off the main project development branch) to
104 | contain your feature, change, or fix:
105 |
106 | ```bash
107 | git checkout -b
108 | ```
109 |
110 | 5. Commit your changes in logical chunks.
111 | Please follow the [Conventional Commits Specification](https://conventionalcommits.org/) when writing commit messages. This enables use of [standard-version](https://github.com/conventional-changelog/standard-version) to generate a detailed CHANGELOG.
112 | Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase)
113 | feature to tidy up your commits before making them public.
114 |
115 | 6. Locally merge (or rebase) the upstream development branch into your topic branch:
116 |
117 | ```bash
118 | git pull [--rebase] upstream master
119 | ```
120 |
121 | 7. Push your topic branch up to your fork:
122 |
123 | ```bash
124 | git push origin
125 | ```
126 |
127 | 8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
128 | with a clear title and description.
129 |
130 | **IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by this project (MIT).
131 |
132 |
133 |
134 | ## Running Local Demo
135 |
136 | You can run the local demo with NPM like so:
137 |
138 | ```bash
139 | cd
140 | npm start
141 | ```
142 |
143 | The local app will then be available at http://localhost:3001
144 |
145 |
146 |
147 | ## Running Tests
148 |
149 | All unit tests must pass before a pull request will be approved.
150 | You can run unit tests with NPM like so:
151 |
152 | ```bash
153 | cd
154 | npm test
155 | ```
156 |
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Reporting a Bug?
2 |
3 | Please include either a failing unit test or a simple repro. You can start by forking the [CodeSandbox example](https://codesandbox.io/s/wkw2mjm5l8)
4 |
5 | # Requesting a Feature?
6 |
7 | Provide as much information as possible about your requested feature. Here are a few questions you may consider answering:
8 |
9 | - What's your use case? (Tell me about your application and what problem you're trying to solve.)
10 | - What interface do you have in mind? (What new properties or methods do you think might be helpful?)
11 | - Can you point to similar functionality with any existing libraries or components? (Working demos can be helpful.)
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Chris Fritz
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | > **NOTE**: This package is not maintained any more and will be archived.
2 | >
3 | > [react-photoswipe-gallery](https://www.npmjs.com/package/react-photoswipe-gallery) is a better-maintained and more feature-rich alternative (as of January 2023).
4 |
5 | # React Image Lightbox
6 |
7 | [](https://npmjs.org/package/react-image-lightbox)
8 | [](https://github.com/frontend-collective/react-image-lightbox/actions?query=workflow%3ACI)
9 | [](https://coveralls.io/github/frontend-collective/react-image-lightbox?branch=master)
10 |
11 | [](https://frontend-collective.github.io/react-image-lightbox/)
12 |
13 | A flexible lightbox component for displaying images in a React project.
14 |
15 | [DEMO](https://frontend-collective.github.io/react-image-lightbox/)
16 |
17 | Features
18 |
19 | - Keyboard shortcuts (with rate limiting)
20 | - Image Zoom
21 | - Flexible rendering using src values assigned on the fly
22 | - Image preloading for smoother viewing
23 | - Mobile friendly, with pinch to zoom and swipe (Thanks, [@webcarrot](https://github.com/webcarrot)!)
24 |
25 | ## Example
26 |
27 | ```jsx
28 | import React, { Component } from 'react';
29 | import Lightbox from 'react-image-lightbox';
30 | import 'react-image-lightbox/style.css'; // This only needs to be imported once in your app
31 |
32 | const images = [
33 | '//placekitten.com/1500/500',
34 | '//placekitten.com/4000/3000',
35 | '//placekitten.com/800/1200',
36 | '//placekitten.com/1500/1500',
37 | ];
38 |
39 | export default class LightboxExample extends Component {
40 | constructor(props) {
41 | super(props);
42 |
43 | this.state = {
44 | photoIndex: 0,
45 | isOpen: false,
46 | };
47 | }
48 |
49 | render() {
50 | const { photoIndex, isOpen } = this.state;
51 |
52 | return (
53 |
77 | );
78 | }
79 | }
80 | ```
81 |
82 | Play with the code on the [example on CodeSandbox](https://codesandbox.io/s/l9n3vnz8yz)
83 |
84 | ## Options
85 |
86 | | Property | Type | Description |
87 | | :------------------------------ | :----: | :------------------------------------------------------------------------------------------------------------------------------------------------------------ |
88 | | mainSrc _(required)_ | string | Main display image url |
89 | | prevSrc | string | Previous display image url (displayed to the left). If left undefined, `onMovePrevRequest` will not be called, and the button not displayed |
90 | | nextSrc | string | Next display image url (displayed to the right). If left undefined, `onMoveNextRequest` will not be called, and the button not displayed |
91 | | mainSrcThumbnail | string | Thumbnail image url corresponding to `props.mainSrc`. Displayed as a placeholder while the full-sized image loads. |
92 | | prevSrcThumbnail | string | Thumbnail image url corresponding to `props.prevSrc`. Displayed as a placeholder while the full-sized image loads. |
93 | | nextSrcThumbnail | string | Thumbnail image url corresponding to `props.nextSrc`. Displayed as a placeholder while the full-sized image loads. |
94 | | onCloseRequest _(required)_ | func | Close window event. Should change the parent state such that the lightbox is not rendered |
95 | | onMovePrevRequest | func | Move to previous image event. Should change the parent state such that `props.prevSrc` becomes `props.mainSrc`, `props.mainSrc` becomes `props.nextSrc`, etc. |
96 | | onMoveNextRequest | func | Move to next image event. Should change the parent state such that `props.nextSrc` becomes `props.mainSrc`, `props.mainSrc` becomes `props.prevSrc`, etc. |
97 | | onImageLoad | func | Called when an image loads.
|
99 | | imageLoadErrorMessage | node | What is rendered in place of an image if it fails to load. Centered in the lightbox viewport. Defaults to the string `"This image failed to load"`. |
100 | | onAfterOpen | func | Called after the modal has rendered. |
101 | | discourageDownloads | bool | When `true`, enables download discouragement (preventing [right-click -> Save Image As...]). Defaults to `false`. |
102 | | animationDisabled | bool | When `true`, image sliding animations are disabled. Defaults to `false`. |
103 | | animationOnKeyInput | bool | When `true`, sliding animations are enabled on actions performed with keyboard shortcuts. Defaults to `false`. |
104 | | animationDuration | number | Animation duration (ms). Defaults to `300`. |
105 | | keyRepeatLimit | number | Required interval of time (ms) between key actions (prevents excessively fast navigation of images). Defaults to `180`. |
106 | | keyRepeatKeyupBonus | number | Amount of time (ms) restored after each keyup (makes rapid key presses slightly faster than holding down the key to navigate images). Defaults to `40`. |
107 | | imageTitle | node | Image title (Descriptive element above image) |
108 | | imageCaption | node | Image caption (Descriptive element below image) |
109 | | imageCrossOrigin | string | `crossorigin` attribute to append to `img` elements ([MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-crossorigin)) |
110 | | toolbarButtons | node[] | Array of custom toolbar buttons |
111 | | reactModalStyle | Object | Set `z-index` style, etc., for the parent react-modal ([react-modal style format](https://github.com/reactjs/react-modal#styles)) |
112 | | reactModalProps | Object | Override props set on react-modal (https://github.com/reactjs/react-modal) |
113 | | imagePadding | number | Padding (px) between the edge of the window and the lightbox. Defaults to `10`. |
114 | | clickOutsideToClose | bool | When `true`, clicks outside of the image close the lightbox. Defaults to `true`. |
115 | | enableZoom | bool | Set to `false` to disable zoom functionality and hide zoom buttons. Defaults to `true`. |
116 | | wrapperClassName | string | Class name which will be applied to root element after React Modal |
117 | | nextLabel | string | `aria-label` and `title` set on the 'Next' button. Defaults to `'Next image'`. |
118 | | prevLabel | string | `aria-label` and `title` set on the 'Previous' button. Defaults to `'Previous image'`. |
119 | | zoomInLabel | string | `aria-label` and `title` set on the 'Zoom In' button. Defaults to `'Zoom in'`. |
120 | | zoomOutLabel | string | `aria-label` and `title` set on the 'Zoom Out' button. Defaults to `'Zoom out'`. |
121 | | closeLabel | string | `aria-label` and `title` set on the 'Close Lightbox' button. Defaults to `'Close lightbox'`. |
122 | | loader | node | Custom Loading indicator for loading |
123 |
124 | ## Browser Compatibility
125 |
126 | | Browser | Works? |
127 | | :------ | :----- |
128 | | Chrome | Yes |
129 | | Firefox | Yes |
130 | | Safari | Yes |
131 | | IE 11 | Yes |
132 |
133 | ## Contributing
134 |
135 | After cloning the repository and running `npm install` inside, you can use the following commands to develop and build the project.
136 |
137 | ```sh
138 | # Starts a webpack dev server that hosts a demo page with the lightbox.
139 | # It uses react-hot-loader so changes are reflected on save.
140 | npm start
141 |
142 | # Lints the code with eslint and my custom rules.
143 | yarn run lint
144 |
145 | # Lints and builds the code, placing the result in the dist directory.
146 | # This build is necessary to reflect changes if you're
147 | # `npm link`-ed to this repository from another local project.
148 | yarn run build
149 | ```
150 |
151 | Pull requests are welcome!
152 |
153 | ## License
154 |
155 | MIT
156 |
--------------------------------------------------------------------------------
/__mocks__/fileMock.js:
--------------------------------------------------------------------------------
1 | module.exports = 'test-file-stub';
2 |
--------------------------------------------------------------------------------
/examples/cats/app.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import Lightbox from '../../src';
3 | // import Lightbox from 'react-image-lightbox';
4 | // In your own app, you would need to use import styles once in the app
5 | // import 'react-image-lightbox/styles.css';
6 | import './stylesheets/vendor/stylesheet.css';
7 | import './stylesheets/vendor/github-light.css';
8 | import './stylesheets/app.css';
9 | import image1 from './images/1.jpg';
10 | import image2 from './images/2.jpg';
11 | import image3 from './images/3.jpg';
12 | import image4 from './images/4.jpg';
13 | import image1Thumb from './images/1_thumb.jpg';
14 | import image2Thumb from './images/2_thumb.jpg';
15 | import image3Thumb from './images/3_thumb.jpg';
16 | import image4Thumb from './images/4_thumb.jpg';
17 |
18 | const images = [image1, image2, image3, image4];
19 | const thumbs = [image1Thumb, image2Thumb, image3Thumb, image4Thumb];
20 |
21 | const titles = [
22 | '',
23 |
24 | by
25 |
26 | quatre mains
27 |
28 | (
29 |
34 | Some rights reserved
35 |
36 | )
37 | ,
38 |
39 | by
40 |
41 | latch.r
42 |
43 | (
44 |
49 | Some rights reserved
50 |
51 | )
52 | ,
53 |
54 | by
55 |
56 | fazen
57 |
58 | (
59 |
64 | Some rights reserved
65 |
66 | )
67 | ,
68 | ];
69 |
70 | const captions = [
71 | 'Cat in the snow',
72 | '',
73 |
74 | .. not in the
75 | mood
76 | for games right now
77 |
78 | ...
79 |
80 | ...
81 |
82 | ...
83 |
84 | ...
85 |
86 | ...
87 |
88 | ...
89 |
90 | C'mon. Seriously.
91 |