Skip to content
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

Make jquery.poptrox work on galleries which are dynamically modified via DOM #16

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

joshuaboshi
Copy link

This pull request is changing how gallery entries are initialized and opened.

Orignally, each gallery entry was loaded to a plugin variable and onclick handler was attached to it (anchor node) during the initialization step.
This effectively disallowed further dynamic modifications of the gallery via DOM (adding more entries to the gallery, changing the captions etc.).

With commits in this PR, onclick handler is only attached to the gallery container ($('#gallery').poptrox();) as a delegate. Meaning that whenever any link (settings.selector) is clicked, the event bubbles up to the container, where it is handled.

To implement this, I had removed the queue, which was prefilled during the initialization orignally. The JS representation of a gallery entry is now being built everytime the entry is clicked (see the function open).

poptrox_next and poptrox_previous are now reading the entries from DOM on every invocation to take into account any changes in gallery.

Let me know if there are any things to discuss!

Best regards,
Tomas

Notes:

  • I have tested it on demo/demo1.html + some other configuration options
  • I have renamed some ambiguous variables on the way of understanding the code
  • I have minified the source with UglifyJS2 version 2.3.6
  • the original API of jquery.poptrox is not changed in any way

@Coriou
Copy link

Coriou commented Jun 9, 2015

Hey, I know it's a 6 months old pull request but why wasn't it merged ? It'd be great if Poptrox supported dynamically modified galleries (yes, I'm struggling with this right now) =)

@joshuaboshi
Copy link
Author

Hello @Coriou
I am not the owner of this project. Currently there are some conflicts which I would have to resolve to get this merge accepted.
@n33 Will you accept this PR if I sync with master?
Thanks!

@rampatra
Copy link

It's a very nice feature to have and I am too struggling with this but I tried with the changes in your PR and poptrox doesn't seem to smoothly work. For example, when I click on an image and then click on the right arrow, the pop-up closes, instead, the next image should pop open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants