Is there a way to enable Fancybox to change to the adjacent gallery by simply using the 'up' or 'down' arrow keys?

I am currently working on a layout that consists of a vertical column of thumbnail images, each linked to its own gallery with additional images. When the user clicks on a thumbnail image, Fancybox opens, allowing them to navigate through the images within that specific gallery using the arrow keys.

You can view a demo of this setup here: http://jsfiddle.net/Q6tmq/

My question is how can I customize the functionality so that when the 'up' and 'down' arrow keys are pressed, instead of moving to the next or previous image within the current gallery, it will display the first image from the next or previous gallery?

In essence, I want users to be able to open Fancybox, navigate through all the images in all galleries present on the page without having to close Fancybox each time.

<!-- GALLERY 1 -->
<li>
    <!-- THUMB -->
    <a class="fancybox" rel="gallery1" href="http://fancyapps.com/fancybox/demo/1_b.jpg">
        <img src="http://fancyapps.com/fancybox/demo/1_s.jpg" alt=""/>
    </a>

    <!-- IN-GALLERY IMAGES -->
    <div class="hidden">
        <a class="fancybox" rel="gallery1" href="http://fancyapps.com/fancybox/demo/2_b.jpg"></a>
        <a class="fancybox" rel="gallery1" href="http://fancyapps.com/fancybox/demo/3_b.jpg"></a>
    </div>
</li>

<!-- GALLERY 2 -->
<li>
    <!-- THUMB -->
    <a class="fancybox" rel="gallery2" href="http://fancyapps.com/fancybox/demo/4_b.jpg">
        <img src="http://fancyapps.com/fancybox/demo/4_s.jpg" alt=""/>
    </a>

    <!-- IN-GALLERY IMAGES -->
    <div class="hidden">
        <a class="fancybox" rel="gallery2" href="http://fancyapps.com/fancybox/demo/5_b.jpg"></a>
    </div>
</li>

$(".fancybox")
.fancybox({
    helpers : {
        title : {
            type : 'over'
        },
        overlay : {
            css : {
                'background' : 'rgba(0, 0, 0, 0.7)'
            }
        }
    }
}); 

Answer №1

Unfortunately, without making changes to Fancybox's source code or creating a custom plugin, it is not possible to achieve this functionality using their API.

One workaround could be to assign all images a rel value of gallery1. This would allow users to view all images and galleries within Fancybox without needing to close the viewer, although they would not be able to switch between different galleries.

The use of the hidden class would still be applicable in the same manner as before.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The JavaScript function prints the variable using `console.log(var)`, however, it does not assign `var2` to

I've been following a tutorial on implementing push notifications in VueJS from this link. After running the register function on the created hook, I encountered an issue: register() { if ("serviceWorker" in navigator && "PushManager" in window ...

Module 'js' not found

Upon adding a request, I encountered this error message. I attempted npm install js and added var js = require("js") in my app.js file, but unfortunately it did not resolve the issue. My express server is running on localhost. Error: Cannot find module &a ...

Exploring React Native Networking using react-native-router-flux

Hello everyone, I have a quick query. I am looking to assign each Button to a different page. import React, { Component } from 'react'; import { ActivityIndicator, FlatList, Text, View, TouchableOpacity } from 'react-native'; export ...

Guide to incorporating third-party JavaScript files and functions into my Angular web app

I have been trying to integrate external code (HTML, JS, and CSS files) into my Angular web application. Within this external code, the structure of the HTML file is as follows: index.html <html> <header> </header> <body> </bo ...

Troubleshooting alignment problems with a responsive gallery (Bootstrap-gallery & justifyGallery)

Looking to showcase a gallery of images using jquery-justifyGallery and bootstrap-gallery. Want to display 4 images in a row, but running into issues when trying to display 5 images where the last image in the row ends up with a larger width. Bootstrap has ...

Check if the string contains any numerical characters

Is there a way to check if a string contains at least one numerical character without verifying if the entire string is a number? The current code works in the following situations: If there is a single integer, such as "43", it will display the correspon ...

Navigating through an array of images using ng-repeat

I am attempting to iterate through the image array and have each image correspond to a separate li. Despite using the variable "image" as my identifier, I am encountering difficulties looping through the array. The line that I am trying to modify is as fol ...

Using JSON data to populate a select menu in AngularJS using the ng-options directive

UPDATE: I have successfully resolved my issue. Thanks for the assistance, everyone. I am working with an array of JSON objects that are structured like so: [{"id":"id1", "text":"text1"}, {"id":"id2", "text":"text2"},....] My goal is to populate an Angul ...

Application with menu design, similar to the layout of google.com on mobile devices

Have you seen the Android smartphone with Chrome from GOOGLE.COM? Did you notice the pop-up MENU that looks similar to an application? This menu has a "SPRING" effect, and I'm curious how Google achieved this result. I tried using the property "-web ...

How can I create a hyperlink that leads to multiple pages?

I am looking to create a hyperlink that will lead to a random webpage each time it is clicked from a selection of URLs. Can anyone suggest a suitable function to get started on this task? ...

CSS based on conditions for 2 specific divs

Hello, I am working on an HTML page where I need to apply CSS only if certain conditions are met. The div with the id "flipbook-page3-front" will always be present on this HTML page. Sometimes, another div with the id "pagesFlipbook" may also appear on t ...

The placeholder within my input moves up and down when switching the input type from password to text

Currently, I am encountering an issue with the styling of a standard input element in React. Specifically, the placeholder text moves up and down by about 2px when viewed on Chrome, while there are no problems on Safari. How can I go about resolving this i ...

When using the Three.js FBX loader to add objects to the scene, the newly added objects may not be present in the children array

After following the example provided on threejs.org for loading FBX files, I managed to successfully load my model using the function below: this.obj = null; var loader = new THREE.FBXLoader(); var objs = [] function load_init( object ) { mixer = ne ...

Having trouble with my jQuery ajax call - could it be a Firefox issue or a potential XSS vulnerability

Currently, I am facing an issue where Firefox does not provide any response while Internet Explorer functions correctly. My goal is to make an AJAX call to a local script in order to retrieve plain text or some other information. However, for some reason, ...

The Autocomplete feature in Material UI React includes both a "Select All" and a "Select

How can I add Select All and Select None buttons to an Autocomplete component in Material UI React? The goal is for all the options to be checked when Select All is clicked, and for all options to be unchecked when Select None is clicked. <Autocomple ...

"Utilizing jQuery, Ajax, and the powerful REDIRECT_QUERY_STRING feature

Recently, I decided to revamp a small website consisting of three or four pages using a minimalist MVC framework (which might be excessive, but I wanted to experiment). The site is configured with an .htaccess file: RewriteEngine on RewriteCond %{REQUE ...

Tips for adjusting border colors based on the current time

Trying to change the border color based on the opening hours. For example, green border from 10am to 9:29pm, yellow from 9:30pm to 9:44pm, and orange from 9:45pm until closing at 10pm. The issue is that the colors change at incorrect times beyond midnight. ...

Manage YouTube video played within html code

I am working on a page that contains a YouTube video embedded in HTML. I am trying to find a way to stop the video when it is closed using the YouTube API, but so far my attempts have been unsuccessful. I have included SWFObject and jQuery in the code, yet ...

Interested in customizing the hover color of the header links in WordPress?

I'm currently working on customizing the hover color of the links in my WordPress header created with Elementor Page Builder. I tried several CSS solutions by inspecting elements and adding them to the custom CSS section in WordPress, but none seemed ...

Retrieve the following and previous JSON object

Is there a way to retrieve the next object (with Id 120) and the previous object (with Id 122) when currently at the second object with Id 141? I also have control over the JSON format. var articleId = 141; var url = { "Article": [ { ...