Skip to content

Commit 42e5d3a

Browse files
authored
Merge pull request #17 from DCzajkowski/open-at-prop
Open at prop
2 parents 6822ac8 + 5002708 commit 42e5d3a

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ import styles from 'vue-pure-lightbox/dist/VuePureLightbox.css'
117117

118118
### Available props:
119119

120-
| Prop | Type | Value |
121-
| -------------- | ----------------- | ----------------------------------------------- |
122-
| thumbnail | string | Path to a file being your thumbnail |
123-
| images | string[] or array | Array of paths to files visible in the lightbox |
124-
| alternate-text | string | **(Optional)** alt="" text for your image |
125-
| value | boolean | **(Optional)** reactive visibility prop |
120+
| Prop | Type | Value |
121+
| -------------- | ----------------- | --------------------------------------------------------------- |
122+
| thumbnail | string | Path to a file being your thumbnail |
123+
| images | string[] or array | Array of paths to files visible in the lightbox |
124+
| alternate-text | string | **(Optional)** alt="" text for your image |
125+
| value | boolean | **(Optional)** reactive visibility prop |
126+
| open-at-index | integer | **(Optional)** index of an image to show when opening the modal |
126127

127128
### Available slots:
128129
| Slot | Description | Default |

src/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
class="lb-demo"
44
:thumbnail="thumbnail"
55
:images="images"
6+
:openAtIndex="1"
67
>
78
<LightboxDefaultLoader slot="loader" />
89
<div slot="content" slot-scope="{ url }">

src/Components/Lightbox.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
images: {
5858
type: Array,
5959
},
60+
openAtIndex: {
61+
type: Number,
62+
default: 0,
63+
},
6064
alternateText: {
6165
type: String,
6266
default: '',
@@ -72,7 +76,7 @@
7276
data() {
7377
return {
7478
visible: this.value,
75-
index: 0,
79+
index: this.openAtIndex,
7680
displayImage: true,
7781
}
7882
},
@@ -95,11 +99,11 @@
9599
methods: {
96100
show() {
97101
this.visible = true
98-
this.index = 0
102+
this.index = this.openAtIndex
99103
},
100104
hide() {
101105
this.visible = false
102-
this.index = 0
106+
this.index = this.openAtIndex
103107
},
104108
previous() {
105109
if (this.hasPrevious) {

0 commit comments

Comments
 (0)