Issues with Jquery Div sliding transitions from right to left are not functioning correctly

Creating page transitions in jQuery similar to "http://support.microsoft.com/."

Encountering an issue where after the page transitions are completed, they start from the left instead of the expected right direction. Referencing this fiddle (Working Code) will provide a clearer understanding of the problem. Clicking on "Page 1" from the dropdown menu initiates the transition where the first div slides from right to left (←) smoothly. Subsequently, clicking on the text within the first div reveals the second div sliding in from right to left (←) as well, which is functioning correctly. However, upon clicking the text within the second div and transitioning to the third div, the first and second divs hide to the left while the third div slides in from right to left (←), causing a problem. When clicking back on "page 1" from navigation, the hidden divs reappear from left to right (→) rather than right to left (←). What steps can be taken to resolve this issue?

Code Provided Below

HTML

    <div class="codrops-top clearfix">
        <!-- <a class="codrops-icon codrops-icon-prev" href=""><span>Previous Demo</span></a>
        <span class="right"><a class="codrops-icon codrops-icon-drop" href=""><span>Back to the Codrops Article</span></a></span> -->

    </div>

    <div class="pt-wrapper">
        <div class="pt-trigger-container">
            <div class="navigation right">
                <ul>
                    <li><img src = "menu.png" width = "25">
                        <div style = "margin-left:10px">
                            <ul>
                                <li id = "page1"><a>Page 1</a></li>
                            </ul>
                        </div>
                    </li>
                </ul>
                <div class="clear"></div>
            </div>
        </div>

    </div>

    <div id = "container1" style="left:80%;background:#98bf21;height:100%;width:200px;position:absolute;display:none">
        <ul id = "contaoneritem1">
            <li><a>Content 1</a></li>
            <li><a>Content 2</a></li>
            <li><a>Content 3</a></li>
            <li><a>Content 4</a></li>
            <li><a>Content 5</a></li>
            <li><a>Content 6</a></li>
        </ul>
    </div>


    <div id = "container2" style="left:80%;background:#98bf21;height:100%;width:200px;position:absolute;display:none">
        <ul id = "contaoneritem2">
            <li><a>Content 1.1</a></li>
            <li><a>Content 1.2</a></li>
            <li><a>Content 1.3</a></li>
            <li><a>Content 1.4</a></li>
            <li><a>Content 1.5</a></li>
            <li><a>Content 1.6</a></li>
        </ul>
    </div>


    <div id = "container3" style="left:80%;background:#98bf21;height:100%;width:600px;position:absolute;display:none">
        <ul id = "contaoneritem3">
            <li><a>Content 1.1.1</a></li>
            <li><a>Content 1.2.1</a></li>
            <li><a>Content 1.3.1</a></li>
            <li><a>Content 1.4.1</a></li>
            <li><a>Content 1.5.1</a></li>
            <li><a>Content 1.6.1</a></li>
        </ul>
    </div>

CSS

    body{overflow:hidden}
    .navigation ul{ float:right;}
    .navigation ul li{ float:left; padding:0px 300px 0px 5px;cursor:pointer}
    .navigation ul li a{cursor:pointer}
    .navigation ul li div{ display:none;}
    .navigation ul li:hover div{ display:block; position:absolute;z-index:9999}
    .navigation ul li:hover div ul{ float:none; margin-left:-30px;}
    .navigation ul li:hover div ul li{ float:none; text-align:left; padding:0px; background:#110000; border-bottom:#dddddd solid 1px;}
    .navigation ul li:hover div ul li:hover a{ background:#fff; color:black}
    .navigation ul li:hover div ul li a{ padding:3px 5px; display:block; width:100%;color:white}

JS

    $(document).ready(function(){
      $("#page1").click(function(){
        var div3=$("#container3");  
        div3.animate({left:'120%'},"slow");
      $("#container1").show();
        var div=$("#container1");  
        div.animate({left:'20%'},"slow");
      });
    });

    $(document).ready(function(){
      $("#contaoneritem1").click(function(){
      $("#container2").show();
        var div=$("#container2");  
        div.animate({left:'40%'},"slow");
      });
    });

    $(document).ready(function(){
      $("#contaoneritem2 li a").click(function(){
        var div=$("#container2");  
        var div1=$("#container1");  
        div.animate({left:'-100%'},"slow");
        div1.animate({left:'-100%'},"slow");
        $("#container3").show();
        var div3=$("#container3");  
        div3.animate({left:'20%'},"slow");
      });
    });

Answer №1

You have shifted containers 1 and 2 to the extreme left, causing the content to move from left to right. To correct this, make the following changes:

$(document).ready(function(){
$("#page1").click(function(){
var div3=$("#container3");  
div3.animate({left:'120%'},"slow");
var div2=$("#container2");  
var div1=$("#container1"); 
 div2.css("left", "100%");
 div1.css("left", "80%");
$("#container1").show();
var div=$("#container1");  
div.animate({left:'20%'},"slow");
});
});

Check out the Fiddle DEMO

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

Alignment dilemmas

I'm experimenting with HTML and CSS and have a query concerning the text-align properties. As I work on constructing my personal website, I aim to align text content to start while having it centered in the middle of the page. Currently, I've ma ...

Executing multiple functions with onPress in React Native

When I press onPress using TouchableOpacity, I am attempting to invoke multiple functions. Here's an example: functionOne(){ // perform an action } functionTwo(){ // execute something } <TouchableHighlight onPress{() => this.functionOne()}/& ...

Establish a many-to-many relationship in Prisma where one of the fields is sourced from a separate table

I'm currently working with a Prisma schema that includes products, orders, and a many-to-many relationship between them. My goal is to store the product price in the relation table so that I can capture the price of the product at the time of sale, re ...

Avoid modifying the HTML DOM structure after utilizing the JQuery Load() method

Within an HTML Page, the Ajax Load() function is utilized to load additional HTML files into the current HTML document by targeting a specific element. When clicking on Links, the other HTML pages load correctly. However, despite the code being loaded usin ...

The delete function is not functioning

I need help with implementing a custom Angular directive that includes a delete button to remove itself. When I click the button removeMe, it is not deleting an item from the array. Any suggestions on what might be causing this issue? HTML: <button t ...

Tips for generating a unique user validation hash or token

I have a registration endpoint in my express app where users need to verify their email before account activation. I'm struggling with creating a hash for the verification link. I considered using JWT, but it feels like an overcomplicated solution. Is ...

Implementing a function to specify size limits

As a newcomer to the world of JavaScript, I am facing a particular challenge. My goal is to add a conditional statement in my code that will only execute on screen sizes larger than 768px. $(window).on('scroll', function () { if ($(window ...

Building an Angular module that allows for customizable properties: A step-by-step guide

I am in the process of developing an AngularJS module that will simplify interactions with my product's REST API. Since my product is installed on-premise, each user will need to provide their own URL to access the API. Therefore, it is essential that ...

The dropdown menu appears when the user clicks on an empty area

How can I ensure that the drop-down menu is only activated when the arrow or the name is clicked? I've tried looking at similar questions but haven't found a solution. Currently, clicking anywhere next to "shop" activates the drop-down. Here&apo ...

Use regular expressions to locate all closing HTML tags and all opening HTML tags individually

My JavaScript function is currently filtering strings by removing all HTML tags. However, I have now realized that I need to perform two separate operations: first, replacing all closing tags with <br>, and then removing all opening tags. return Str ...

Creating a Website for Compatibility with NoScript

During my journey of building a nameplate site from the ground up for myself, I have delved into the realms of learning and establishing my online presence. The highlight of my project is a sleek tabbed site that employs AJAX and anchor navigation to seaml ...

Guidance on sharing an image on Twitter using Node.js

Every time I attempt to upload a PNG image to the Twit library in Node, an error arises. My objective is to develop a Twitter bot in Node.js that generates a random RGB colour, creates an image of this colour, and tweets it. Thanks to some assistance prov ...

Unveiling the secrets of extracting element content using JavaScript (with JQuery) from an HTML object

I have written the code below to access the page "JQueryPage.aspx" and retrieve data from it using jQuery: <script type="text/javascript> $.get ( "JQueryPage.aspx", function(data) { alert("Data Loaded: " + data); ...

Creating a dynamic start page for Progressive Web Apps (PWA) involves determining the

Recently, I developed a project called "Progressive Web App" using JavaScript and Visual Studio 2017. One key element of the project is the file "package.appxmanifest", which defines the StartPage. I am curious to know if there is a way to dynamically se ...

Update the fuelux treeview after uploading a file

Currently, I am utilizing the jquery fileupload plugin to facilitate the process of uploading a file and then using the data from said file to populate a fuelux treeview. I have configured an ajax call for handling the file data where the information is fe ...

Unlocking the secrets of integrating Vuex store with JavaScript/TypeScript modules: A comprehensive guide

I am working on a vue application and I have a query. How can I access the store from javascript/typescript modules files using import/export? For example, if I create an auth-module that exports state, actions, mutations: export const auth = { namesp ...

AngularJS allowing multiple ngApps on a single page with their own ngRoute configurations, dynamically loaded and initialized

Seeking advice on lazy loading separate ngApps on one page and bootstrapping them using angular.bootstrap, each with its own unique ngRoute definitions to prevent overlap. I have a functioning plunkr example that appears to be working well, but I am unsur ...

Having difficulty populating a selection box through an ajax request in Django

I am facing an issue with creating cascading select boxes in my project (backend Django), although I believe most of the backend work has been completed. The JavaScript code I'm using is adapted from a solution found on a stackoverflow post. $(docume ...

There are two notable problems with Bootstrap 4 Tooltip. The first is that it appears when a button is clicked, and the second is that it shows up for disabled elements

I am currently experiencing an issue with my tooltip while using Bootstrap 4. In my index.html, I have the following script loaded: $('body').tooltip({ selector: '[data-toggle="tooltip"]', delay: { show: 550, hide: 0 } }); The proble ...

When iPhone images are uploaded, they may appear sideways due to the embedded exif data

When trying to upload images from a mobile device like an iPhone, it's common for the images to appear sideways unless viewed directly in Chrome. It seems that this issue is related to the image exif orientation data, which Chrome can ignore but othe ...