Managing the scrolling direction horizontally with waypoints.js

As I work on creating a custom wizard form with waypoints, I've encountered an interesting issue that has left me puzzled.

In my sample CODEPEN, you can see two pages of the wizard process to better understand the problem.

Upon clicking the forward action button (search on the first page of the wizard), the waypoints slide from the right and reveal the next page or screen. This function also works when using the backward action button. However, the initial horizontal scrollbar presents an unexpected challenge as it allows users to scroll to the next screen by dragging the scrollbar. Although I tried setting overflow-x, it did not resolve the issue. The curious part is that once I click on the search button and the waypoint slides, the scrollbar disappears, providing the desired effect. Why does this happen?

I aimed to replicate the real environment in the CODEPEN to identify any conflicts with other elements rather than isolating the problem.

Here is some relevant code:

HTML:

<div id="content" class="content">
    <div class="row page">
       <!-- Content for the first page -->
    </div>

    <div class="row page2">
       <!-- Content for the second page -->
    </div>
</div>

CSS:

.page, .page2 {
    position: absolute;
    top: 20px;
    left: 10px;
    width: 100%;
    -webkit-transition: -webkit-transform 0.8s;
    transition: -webkit-transform 0.8s;
    transition: transform 0.8s;
    transition: transform 0.8s, -webkit-transform 0.8s
}

.page {
    -webkit-transform: translateX(0%);
    transform: translateX(0%)
}

.show-page2 .page {
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%)
}

.page2 {
    -webkit-transform: translateX(100%);
    transform: translateX(100%)
}

.show-page2 .page2 {
    -webkit-transform: translateX(0%);
    transform: translateX(0%)
}

JS:

(function () {

    var body = $('#content'),
        nav = $('.btn-waypoint'),
        panels = $('#content');

    nav.on('click', function (e) {
        e.preventDefault();
        var dest = $(this).data('panel-link');
        body
            .removeClass(function (index, css) {
                return (css.match(/\bshow-\S+/g) || []).join(' ');
            })
             .addClass('show-' + dest);
    });

}());

The solution I attempted involved hiding page2 on page load to eliminate the scrollbar, then displaying it upon button click. While this approach almost resolved the issue, there was a slight visual glitch between the waypoint sliding effect and the CSS fade effect. Here is the corresponding code:

JS

$( document ).ready(function() {
    $('.page2').css('display', 'none');
    $('[data-panel-link]').on('click', function(){
        $('.page2').css('display', 'block');

    });
});

You can access my CODEPEN here.

I appreciate any assistance provided!

Answer â„–1

The main issue here appears to be the positioning of the elements causing a horizontal scrollbar to appear. By using position:absolute and transform: translateX(-100%), the divs are being forced into a side-by-side layout, resulting in the unwanted scrollbar. Disabling mousewheel scrolling temporarily removes the scrollbar but also affects vertical scrolling.

Instead of continuing to struggle with this setup, a more effective solution is to use a different transition that achieves the desired effect without necessitating a side-by-side layout. A fade transition can serve as a suitable alternative:

To implement this, simply replace the existing CSS effects with the following code snippet:

.page, .page2{
    position: absolute;
    width: 100%;
    transition: opacity 1s ease-in-out;
    -moz-transition: opacity 1s ease-in-out;
    -webkit-transition: opacity 1s ease-in-out;
}

.page {
    opacity: 1;
}

.show-page2 .page {
    opacity: 0;
}

.page2{
    opacity: 0;
}

.show-page2 .page2{
    opacity: 1;
}

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

"Embed" three.js within SmartMS

Is it possible to incorporate this simple three.js example into Smart Mobile Studio without extensive wrapping? I attempted to copy the window.onload content into an asm section but was unsuccessful. <!DOCTYPE html> <html> <head> <t ...

Issues arising from the interaction of one DIV with another DIV

I'm having trouble positioning a menu (height = 100%) next to the logo. Essentially, when the image controls the height of the DIV (container), it seems logical that adding another DIV (menu) with height: 100% inside that DIV (container) should resul ...

In search of a highly efficient webservices tutorial that provides comprehensive instructions, yielding successful outcomes

I've reached a point of extreme frustration where I just want to break things, metaphorically speaking, of course. For the past week, I've been trying to learn how to create a web service using C# (whether it's WCF or ASMX, I don't rea ...

Utilize jQuery to enable click functionality for an entire div within AJAX-loaded content

I have a custom-built website using Wordpress and the posts are loading dynamically. Here is an example of the code I added to the php file for single post: HTML <article> <div class="blog-item-holder"> <div class="featured-ima ...

Tips for passing an array from AJAX to Controller in asp.net:

I'm currently working on sending an array from an AJAX POST request to my controller. Here's what I have: var selected = []; $('.unitsCheckBox:checked').each(function () { selected.push($(this).val()); }); data = { Units: sele ...

Tips for animating a div twice within the success function

Here is the current AJAX script I have implemented: $.ajax({ type: 'post', url: 'action.php', success: function () { $(".success").show().delay(300).fadeOut(); $(".success ...

remove a section from the main body

body { display: flex; justify-content: center; align-items: center; background: #0e1538; } <canvas id="spaceholder" width="804" height="604"></canvas> </div> <div class="MenĂ¼Center"> <canvas id="canvas" width="800" ...

Immerse yourself in a world of virtual reality with the cutting-edge VR Vide

Currently, I am in the process of developing a virtual panoramic tour that features various panoramas linked together with hotspots. Each panorama contains a video hotspot that plays a video. However, I have encountered an issue where every time a new sce ...

Get the hash value after a specific character using Javascript

I'm currently working on a website with ajax functionality where pages load when clicking on navigation buttons. However, I encounter issues when reloading the page as it defaults back to loading main.html, regardless of the URL. The hash being used i ...

What is the most stylish method for merging a removeCartItem function with an addCartItem function?

Is there a way to combine these functions into a more concise and elegant piece of code? While the current setup works fine, it feels redundant to have two large functions that essentially do the same thing. const modifyCartItem = (cartItems, productToMo ...

Enhance mix-blend mode or filtering effects in SCSS using an SVG component in VueJS

I am currently developing a fixed navbar at the top of a webpage with several SVGs inside anchor tags. I want the SVGs to appear black when displayed over lighter colored divs (other Vue components) and white when displayed over darker colored ones. The ba ...

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 ...

Achieving full-width container on mobile devices with Bootstrap

Despite my efforts in the CSS file, I am still struggling to get the container to take up the full width on mobile devices. Here is my CSS code: @media (max-device-width: 1024px) { .col-sm-2{ width: 100%; } .container { margin: 0 auto; width: ...

A Sinon spy allows for the use of two distinct callback signatures

const sinon = require('sinon') function testCallbacks (useFunction) { useFunction(function (req, res) { return true }) useFunction(function (err, req, res, next) { return false }) } testCallbacks() I am looking for a method ...

Exploring a collection of objects housed in a json document

Currently, I'm looking to retrieve a collection of objects using JavaScript from a JSON file that resides on my website. While I could easily embed the array of objects directly into my JavaScript code, I am interested in understanding how to work wit ...

What is the most effective method to include JSON data containing various IDs at the end within an $http.get() request in AngularJS?

I'm facing a challenge with displaying JSON items that have an array of different ids at the end of the URL (/api/messages/:messageId). For instance, accessing /api/messages/12345 would return {"subject":"subject12345","body":"body12345","id":"12345"} ...

Expanding the `div` element to visually occupy the entire vertical space

I'm facing a design challenge with my webpage layout. I have a fixed header and footer, but I need the content section to dynamically adjust its height between the two. The goal is to fill the remaining vertical space with a background-image in the co ...

Issues with changing background colors using Jquery animate

I am attempting to create a fading background color effect when a button is clicked. Currently, I can change the background color using this code: $("#" + lblqty).css("background","#e9f1ff"); However, when I try to use the animate function as shown below ...

I am facing an issue with Angular 14 and Webpack 5, where certain unnecessary nodejs modules seem to be hindering me from successfully serving

I have recently started working on a cutting-edge Angular 14 application. My current node version is v14.20.0, and npm version is 8.17.0. Despite my best efforts, I seem to be facing an issue with multiple nodejs dependencies being included in my project ...

I'm struggling to make background-image display properly in my CSS code

In my quest to enhance the appearance of my website, I've been grappling with getting the background-image property to cooperate in CSS for the past three days. It's frustrating because I've successfully implemented this feature before, but ...