Skip to content

Commit

Permalink
undo change that prevented position: 0 option for non-array galleries
Browse files Browse the repository at this point in the history
make sure array galleries w/ specified position have correct caption
  • Loading branch information
henrygd committed Oct 5, 2019
1 parent a6c7e08 commit 59fd252
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dist/BigPicture.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
// is array of images
galleryPosition = position || 0;
galleryEls = gallery;
captionContent = gallery[0].caption;
captionContent = gallery[galleryPosition].caption;
} else {
// is element selector or nodelist
galleryEls = [].slice.call(
Expand All @@ -361,7 +361,7 @@
);
// find initial gallery position
var elIndex = galleryEls.indexOf(el);
galleryPosition = position ? position : elIndex !== -1 ? elIndex : 0;
galleryPosition = (position === 0 || position) ? position : (elIndex !== -1 ? elIndex : 0);
// make gallery object w/ els / src / caption
galleryEls = galleryEls.map(function(el) {
return {
Expand Down
2 changes: 1 addition & 1 deletion dist/BigPicture.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example_page/js/BigPicture.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
// is array of images
galleryPosition = position || 0;
galleryEls = gallery;
captionContent = gallery[0].caption;
captionContent = gallery[galleryPosition].caption;
} else {
// is element selector or nodelist
galleryEls = [].slice.call(
Expand All @@ -361,7 +361,7 @@
);
// find initial gallery position
var elIndex = galleryEls.indexOf(el);
galleryPosition = position ? position : elIndex !== -1 ? elIndex : 0;
galleryPosition = (position === 0 || position) ? position : (elIndex !== -1 ? elIndex : 0);
// make gallery object w/ els / src / caption
galleryEls = galleryEls.map(function(el) {
return {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
// is array of images
galleryPosition = position || 0;
galleryEls = gallery;
captionContent = gallery[0].caption;
captionContent = gallery[galleryPosition].caption;
} else {
// is element selector or nodelist
galleryEls = [].slice.call(
Expand All @@ -361,7 +361,7 @@
);
// find initial gallery position
var elIndex = galleryEls.indexOf(el);
galleryPosition = position ? position : elIndex !== -1 ? elIndex : 0;
galleryPosition = (position === 0 || position) ? position : (elIndex !== -1 ? elIndex : 0);
// make gallery object w/ els / src / caption
galleryEls = galleryEls.map(function(el) {
return {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bigpicture",
"version": "2.2.0",
"version": "2.2.1",
"description": "Lightweight image and video viewer, supports youtube / vimeo",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 59fd252

Please sign in to comment.