Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/RobinCK/vue-gallery
:camera: Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers. πΊπ¦
https://github.com/RobinCK/vue-gallery
carousel gallery images mobile nuxt nuxtjs pictures slider touch vue vue-component vuejs
Last synced: 3 months ago
JSON representation
:camera: Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers. πΊπ¦
- Host: GitHub
- URL: https://github.com/RobinCK/vue-gallery
- Owner: RobinCK
- License: mit
- Created: 2017-06-07T04:26:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-06T19:37:35.000Z (over 1 year ago)
- Last Synced: 2024-04-17T02:32:52.802Z (7 months ago)
- Topics: carousel, gallery, images, mobile, nuxt, nuxtjs, pictures, slider, touch, vue, vue-component, vuejs
- Language: Vue
- Homepage: https://robinck.github.io/vue-gallery/
- Size: 894 KB
- Stars: 468
- Watchers: 11
- Forks: 86
- Open Issues: 43
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# vue-gallery
[![Greenkeeper badge](https://badges.greenkeeper.io/RobinCK/vue-gallery.svg)](https://greenkeeper.io/)
:camera: VueJS responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.## Example
[jsFiddle - image](https://fiddle.jshell.net/Robin_ck/LffrLb2k/show/light/)
[jsFiddle - video](https://fiddle.jshell.net/Robin_ck/djqcrm8m/show/light/)
## Install
#### CDNRecommended: https://unpkg.com/vue-gallery, which will reflect the latest version as soon as it is published to npm. You can also browse the source of the npm package at https://unpkg.com/vue-gallery/
#### npm
``` bash
npm install vue-gallery```
#### Yarn
``` bash
yarn add vue-gallery```
### Nuxt
1. Add a new file named `vue-gallery.client.js` to your nuxt plugins folder. It is important that your filename ends in `.client.js` ([more info on this convention](https://nuxtjs.org/guide/plugins/#name-conventional-plugin), only works from Nuxt v.2.4.0).
2. Copy paste the following content in it:
```js
import Vue from 'vue'
import VueGallery from 'vue-gallery'Vue.component('VGallery', VueGallery)
```
3. Add it to your list of plugins in `nuxt.config.js`:
```js
plugins: ['~plugins/vue-gallery.client.js']
```
4. You can now use the component globally:
```js```
## Usage
### VueJS single file (ECMAScript 2015)
```html
import VueGallery from 'vue-gallery';
export default {
data: function () {
return {
images: [
'https://dummyimage.com/800/ffffff/000000',
'https://dummyimage.com/1600/ffffff/000000',
'https://dummyimage.com/1280/000000/ffffff',
'https://dummyimage.com/400/000000/ffffff',
],
index: null
};
},components: {
'gallery': VueGallery
},
}
.image {
float: left;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
border: 1px solid #ebebeb;
margin: 5px;
}```
### Browser (ES5)
```html
new Vue({
el: '#app',
data: function () {
return {
images: [
'https://dummyimage.com/800/ffffff/000000',
'https://dummyimage.com/1600/ffffff/000000',
'https://dummyimage.com/1280/000000/ffffff',
'https://dummyimage.com/400/000000/ffffff'
],
index: null
};
},components: {
'gallery': VueGallery
}
});```
## Props
| Props | Type | Default | Description |
| --------------------|:----------| ------------------------------------------------|--------------|
| images | Array | [] | Urls list |
| index | Number | null | Opened image index |
| options | Object | | [blueimp-gallery](https://github.com/blueimp/Gallery) options |## Events
| Name | Params | Description |
| -----------------|:------------------------|--------------|
| onopen | | |
| onopened | | |
| onslide | | |
| onslideend | | |
| onslidecomplete | | |
| onclose | | |
| onclosed | | |## Known Issues
### 1. Multiple VueGallery components in same page breaks functionalities
**Fix:** Give each gallery a unique id. [jsFiddle Example](https://jsfiddle.net/sam_saama/nzjp13ec/)
### 2. Images not oriented correctly.
It's because the image isn't in the "correct" orientation and the exif orientation data is what "fixes" the orientation when you view the images. Browsers don't fix the image orientation based on the exif data. Some browsers show it "correctly" when you open the image in a new tab by itself but don't fix it if you use the image link in a src attribute. [Relevant stackoverflow](https://stackoverflow.com/questions/24658365/img-tag-displays-wrong-orientation).
**Fix:** Use the `onslide` callback to read the exif data and "correct" the orientation based of the exif orientation. [More info on blueimp-gallery](https://github.com/blueimp/Gallery#event-callbacks).
[jsFiddle Example](https://jsfiddle.net/sam_saama/72k0xr3n/)
Code excerpt:
```html
```
```js
data() {
//...
options: {
onslide: function(index, slide) {
const rotation = {
1: 'rotate(0deg)',
3: 'rotate(180deg)',
6: 'rotate(90deg)',
8: 'rotate(270deg)'
}//Conditionally change rotation of image based on the image orientation data. Example jsfiddle --> https://jsfiddle.net/orotemo/obvna6qn/ Or use something like https://github.com/mattiasw/ExifReader
//But for this example, the fix has been hardcoded.
slide.getElementsByTagName(
'img'
)[0].style = `transform: ${rotation['3']};`
}
}
}```
## Other my Vue JS plugins
| Project | Status | Description |
|---------|--------|-------------|
| [vue-ls](https://github.com/RobinCK/vue-ls) | ![npm](https://img.shields.io/npm/v/vue-ls.svg) | Vue plugin for work with local storage, session storage and memory storage from Vue context |
| [vue-popper](https://github.com/RobinCK/vue-popper) | ![npm](https://img.shields.io/npm/v/vue-popperjs.svg) | VueJS popover component based on popper.js |## Development Setup
``` bash
# install dependencies
npm install# build dist files
npm run build
```## Contributors
### Code Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
### Financial Contributors
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/vue-gallery/contribute)]
#### Individuals
#### Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/vue-gallery/contribute)]
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FRobinCK%2Fvue-gallery.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FRobinCK%2Fvue-gallery?ref=badge_large)MIT Β© [Igor Ognichenko](https://github.com/RobinCK)