What is the process of integrating a translator navigational bar into Swiper.js?

After spending 2 days researching, I have been unable to find the information I need on a common feature found in many mobile apps and websites. So, I have decided to seek advice from someone else. The feature I am referring to is a "translator" navigation bar, although I'm not sure if that's the official name as web terms can be confusing. Essentially, it is a part of website or app navigation that indicates which section you are on by sliding a small colored bar as you swipe through content pages. This navigation bar can also change colors or fade in and out.

I am attempting to create a translator navigation bar slider that moves as I swipe to the next page of content, while also having the "active" navigation tab fade out as the next one fades in - similar to how the Facebook mobile app functions.

To better understand my goal, I have created a jsfiddle where the blue bar represents the translator bar starting at "Option1" and sliding based on the selected navigation. Additionally, I would like the text of the "Option1" navigation to start blue and gradually fade out to grey as "Option2" begins to fade in blue upon sliding. https://jsfiddle.net/t882j5s8/13/

var mySwiper = $('.swiper-container').swiper();
$('a[data-slide]').click(function(e) {
  e.preventDefault();
  mySwiper.slideTo($(this).data('slide'));
});

If anyone has experience with this feature, knowledge of Swiper or other APIs that offer this functionality, or knows how to implement it, I would greatly appreciate your help. Thank you for your time.

Answer №1

Although not exactly what I intended, this method is the only one I know how to implement at the moment. I am still exploring ways to perform these actions based on precise calculations of my swipe movements (if that makes sense?)

The best solution I could come up with on my own is to base the transforms on specific events like "startSlide," rather than updating in real-time as you touch the screen.

For those interested in trying it out, here is the JFiddle link for reference. However, I remain open to alternative solutions that can enhance my understanding of movement-based techniques.

https://jsfiddle.net/t882j5s8/20/

var mySwiper = $('.swiper-container').swiper({
  onSlideChangeStart: function(swiper) {
    switch (mySwiper.activeIndex) {
      case 0:
        $("#one").css("color", "#4B93D3");
        $("#two").css("color", "#888888");
        $("#three").css("color", "#888888");
        $("#four").css("color", "#888888");
        $("#translator").css("transform", "translateX(0%)");
        break;

      case 1:
        $("#one").css("color", "#888888");
        $("#two").css("color", "#4B93D3");
        $("#three").css("color", "#888888");
        $("#four").css("color", "#888888");
        $("#translator").css("transform", "translateX(100%)");
        break;

      case 2:
        $("#one").css("color", "#888888");
        $("#two").css("color", "#888888");
        $("#three").css("color", "#4B93D3");
        $("#four").css("color", "#888888");
        $("#translator").css("transform", "translateX(200%)");
        break;

      case 3:
        $("#one").css("color", "#888888");
        $("#two").css("color", "#888888");
        $("#three").css("color", "#888888");
        $("#four").css("color", "#4B93D3");
        $("#translator").css("transform", "translateX(300%)");
        break;
    }
  }
})

$('a[data-slide]').click(function(e) {
  e.preventDefault();
  mySwiper.slideTo($(this).data('slide'));
});

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

What is the best way to separate the date and time into individual components?

I have created a dynamic object that shows both the date and time. My goal is to figure out how I can separate the time portion from the date so that I can place it in its own HTML element and style it differently? JavaScript isn't my strong suit, e ...

Switching elements in an array using Vue.js

Within my vue.js web application, I am attempting to switch the positions of two rows in a forum. Below is the code snippet I am using: export default { data() { return { forums: [] } }, met ...

Is it possible to store dat.gui presets for controls that are dynamically added?

I have a dynamic dat.gui interface where I add controls, but the "save settings" feature doesn't seem to recognize them. var mygui = new dat.GUI(); mygui.remember(mygui); // Example of adding a control in the standard way mygui.control1 = 0.0; var c ...

User-generated JSON Object with Date Information

I have created an API using Node.js/Express that receives input from a form including a date option in the request body. Currently, I am sending dates in the format YYYY-mm-dd, and I have also attempted using dd/mm/YYYY. However, when testing in Postman, ...

What is the best way to send a 2D array from JavaScript to PHP?

Currently, I am immersed in a school project that requires the extraction of product data from numerous online retailers by utilizing diverse APIs/AJAX calls. Subsequently, I need to organize this data in PHP, employing an AJAX call for each individual r ...

React is having difficulty locating a specific module

I've been attempting to install the parallax library from https://github.com/wagerfield/parallax/. I have gone through the documentation and even found a sample usage in JavaScript. Planning to integrate it into React, based on the sample code and Rea ...

Showing an element using the PHP echo command by triggering a mouseover event on another element within the same echo statement

I am currently outputting data from a MySQL table using PHP and the "echo" command to display the results. I would like a certain element within the echo to be visible when I hover over another element within that same echo. The issue is that when I use ...

Attempting to route a selector, yet on the second attempt, the entity is successfully transferred

I am currently working on developing a function that will switch the image every half second for 10 iterations. During the final iteration, the image src will be set to the actual value. Everything seems to work fine for the first loop, however, when the s ...

Step-by-step guide to creating a pop-up div that appears on hover and remains visible when clicked

I'm trying to figure out how to make a popup appear when the mouse hovers over it and then stay visible when clicked on. The issue I'm facing is that currently, the popup disappears when the mouse moves away from it. How can I modify the code so ...

Dealing with code issues in Subscription forms using AJAX and JQuery

Currently, I am independently studying jQuery and grappling with the Mailchimp Opt-In form code. Despite various existing queries on this topic, I am curious about why my own implementation, as a beginner in jQuery, is not functioning correctly. My intenti ...

Output JSON data using Javascript

Here is some JSON data I am working with: { "lang": [ { "SECTION_NAME": { "english": "My title" }, "SECTION_NAME_2": { "english": "My title" } } ] } I ...

Asynchronous task during stream processing

Can anyone assist me? I am looking to read a file as a stream and when processing the initial chunk, I need to create a database table in an async manner. To achieve this, I want to develop a duplex/transformer stream that would be responsible for creatin ...

A date picker pops up when the user clicks on an Angular input field of type text

I am looking to edit a dateTime value using Angular/Ionic, but unfortunately there is no dateTime picker available. To work around this issue, I have split the field into separate date and time fields. In order to incorporate placeholder text and format th ...

Understanding the behavior of invoking higher order functions can be quite perplexing

I'm encountering an issue with invoking a function within another function. I can't figure out why I am unable to invoke a function using the following logic: function func1(futurefunc){ futurefunc(); } function func2(){ return 3+3; } func ...

The issue with Node.js router failing to process delete requests

My Node.js router is handling all methods well except for the DELETE method. I can't figure out why the delete request does not reach the router. The AJAX request seems to be functioning correctly. AJAX request: function ajaxHelper(url, onSuccessAr ...

What is the best way to make IE 10 display a pointer instead of an I-bar for a select list?

Is there a way to make IE 10 display a pointer instead of an I-bar when selecting from a list? Despite trying various methods found in similar questions, I have been unable to resolve this issue. The cursor: pointer property works as expected on other br ...

What is the best way to align div elements side by side while using a flex direction of column?

I need help aligning the text input next to the h1 tag, inline, and then displaying it as a flex-direction of column. Currently, all inputs are being set in a line with the h1 on top which is not the intended layout. Here is an illustration: https://i.sst ...

Best practices for customizing v-calender in vue.js

I'm struggling with styling my calendar using the v-calendar Vue plugin. I want to customize the background of the calendar, but my code doesn't seem to be working. Can someone please help me out? Thank you in advance. HTML <v-calendar ...

When hovered over, the submenu quickly adjusts its size within 0.1 seconds

Whenever you hover over the Galerija, a submenu pops up. However, there seems to be an issue where the right side of the submenu twitches or resizes for about 0.1 seconds initially. If anyone has any insight on this problem, I would greatly appreciate it. ...

What is the most effective way for AngularJS controllers to communicate with one another?

As I develop a controller, it must interact with another controller. However, I'm uncertain if this is achievable? HTML: <div data-ng-app="TestApp"> <div data-ng-controller="menuCtrl"> <ul> <li> <a data-ng-clic ...