WordPress.org

Ready to get started?Download WordPress

Forums

Keyboard post navigation with Cleaner (Lightbox) Post Gallery (4 posts)

  1. Aya
    Member
    Posted 1 year ago #

    Hello,

    I am trying to implement navigation between posts using the instructions here: http://reallysimpleworks.com/blog/navigating-between-blog-posts-with-jquery-keyboard-shortcuts/

    It works, except I also have a lightbox post gallery on the page (using the Hatch theme). So if I open lightbox and navigate between photos using the left and right arrows, it triggers the navigation between blog posts already but only goes to the next page once the lightbox is closed.

    I want to be able to keep these two navigation actions separate - perhaps having the post navigation be disabled while the lightbox is opened, though I'm not sure how this would be done.

    Thanks so much in advance!

    Aya

  2. bcworkz
    Member
    Posted 1 year ago #

    The navigation works by associating (binding) script to run on a particular key event. To do what you want, you need to attach your own script to run when the lightbox opens that removes the previous key binding. Then another script when the lightbox closes to restore the binding.

  3. Aya
    Member
    Posted 1 year ago #

    Thanks so much for the info! I don't have much experience with the intricacies of Lightbox, so how would I be able to detect with Lightbox is opened/closed from outside of the Lightbox script itself?

  4. bcworkz
    Member
    Posted 1 year ago #

    Yeah, well I have no experience, I only understand the general concept. No matter, it is a DOM object of the page document, which is all that really matters. There's probably a way to do this with straight javascript, but jQuery would be more convenient, especially since it is part of WP anyway and perhaps the Lightbox plugin you're using.

    Either way, you need to bind your own function to some event that happens when the lightbox opens. This could be a click on a thumbnail, or some element in the lightbox getting focus, or probably other events as well. After all, lightbox is triggered by some event itself. Unfortunately, I'm not well versed in Lightbox or jQuery. I only know enough to be certain there is way to accomplish this and have a vague idea of what needs to happen, so I can't really give you any specifics, sorry.

Topic Closed

This topic has been closed to new replies.

About this Topic