-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow single link galleries #83
Conversation
When the gallery selector points to <A> elements, the elements themselves are used as lightbox links (instead of their <A> descendants). Allows users to setup heterogeneous galleries where elements are not contained by a single element.
Not bad, but I believe #81 will be more flexible. |
@@ -149,8 +149,14 @@ | |||
[].forEach.call(gallery, function(galleryElement) { | |||
if(userOptions && userOptions.filter) | |||
regex = userOptions.filter; | |||
|
|||
if(galleryElement.tagName === 'A') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs formatting, brackets, spaces, etc.
Also, you shouldn't declare the var like that; it can be misleading. Better declare it outside and set its value then.
@XhmikosR: #81 looks very promising. However, I would argue that this addition allows to create simple galleries without having to change the existing markup of the page (if you have no control over the markup or if you have a large number of pages that would need to be changed). Fixed formatting and brackets as rightly noted in your previous comment. |
@@ -159,8 +159,13 @@ | |||
if (userOptions && userOptions.filter) { | |||
regex = userOptions.filter; | |||
} | |||
var tags = []; | |||
if(galleryElement.tagName === 'A') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after if
.
I see both points, don't get me wrong. I believe a combination of both would be the best. |
Doesn't this conflict with #101? |
Ping @feimosi |
Hi @LorenzCK, quite a little bit has changed in the codebase lately, could you take a look and rebase your branch? |
Hi @feimosi, sure! Will look into it by tomorrow. Thanks. |
Conflicts: src/baguetteBox.js
selectorData.galleries.push(gallery); | ||
|
||
|
||
var gallery = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it's much cleaner this way 👍
When the gallery selector points to single
<A>
elements, the elements themselves are used as lightbox links instead of their<A>
descendants.Rationale
On pages with multiple stand-alone images, which are not part of a gallery and are not enclosed in a wrapping gallery tag, it can make sense for users to setup the lightbox individually for each link.
For instance, in:
it can be difficult to enable the lightbox on both images. With the changes in this pull request, the
<A>
elements can be directly used to create single-image galleries:Nota bene
These changes make it impossible to create galleries enclosed by an
<A>
tag. For instance:In this case the
.gallery
selector couldn't be used anymore to setup a gallery. However, since enclosing a gallery in an anchor tag should be highly unlikely, these changes probably wouldn't impact any real existing code.