HTML animation effect on subpage with a URL modification [LATEST UPDATE]

Can you smoothly load a new subpage in the background, update the URL, and fade it in while an animation is playing on the previous page?

Check out this example (jsFiddle) to see a simple animation:

$(document).ready(function() {
    'use strict';
    $('.r').on('click', function() {
        var preWidth = $('.l').width(),
            menuWidth = $('.r').width();
        $('.l').animate({
            left: '-' + preWidth
        }, 2000, 'easeOutQuad');
        $('.r').animate({
            left: menuWidth
        }, 2000, 'easeOutQuad', function() {
            $('.page').css({
                visibility: 'hidden'
            });
        });
    });
});

Imagine it like a sliding door. Here's how it should function:

  1. Click on the right div.
  2. The two divs slide outward.
  3. In the background, the new page fades in as the sliding animation plays.
  4. The new page becomes fully visible and the URL changes accordingly.

I hope that explanation makes sense. I appreciate any help! Have a wonderful day.

UPDATE:

Initially, I encountered an issue with my browser's back button not working correctly when trying to load the first page "loader.html" with the animation. As a workaround, I utilized an if statement to monitor a variable's state. Is there a more efficient way to handle this situation?

window.addEventListener('popstate', function(f){
        var bprsd = f.state;
        if(bprsd == null){
            bprsd = "loader.html";
        }
        if(bprsd = "loader.html" || " "){
            bprsd = null;
            location.reload();
        }
    });

You can explore the test site here

Answer №1

A response that is a mix of both affirmative and negative.

Indeed, it is achievable but not within your current framework. To accomplish this, you must load the alternate page using $.load:

var website="example.html";
$(document).on("click",function(){
  //perform fadeout
  $(document.body).load(website);
   history.pushState({},"MySite",website);
  //complete the process with fadein
  });

site="newexample.html";

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

Web page layout featuring fields set aside for completion with underlined formatting

As I work on an HTML document, I encounter a challenge with styling fields that need to be dynamically filled and underlined. Here is what I am aiming to achieve: "Applicant's Last Name:_________bar_____________ First Name:_________foo_____________" ...

Responsive Bar Chart using jQuery Mobile and ChartJS that appears on the screen only after resizing

I have been experimenting with adding a responsive bar chart using Chart.js in one of my JQM projects. Here is what I have accomplished so far: http://jsfiddle.net/mauriciorcruz/1pajh3zb/3/ The Chart needs to be displayed on Page Two and it should be res ...

Utilizing variable values in Google Charts with AngularJS

Hello everyone, I am attempting to display a chart using data obtained from an API. The output of the API is in the form of List<String> and not in JSON format. Here is the snippet of my JS file: google.load('visualization', '1', ...

Exploring Fetch API with Promise.all

I have successfully implemented a functionality that fetches data from two URLs and performs an action only when both requests are successful. However, I am curious if there is a more efficient and succinct way to achieve the same result. Helper functions ...

How to Identify CanActivate in Angular 2 Deprecated Routing?

One issue I am facing involves a component that has been decorated with @CanActivate. @Component({ // ... }) @CanActivate(() => false) export class UserManagementComponent { // ... } My dilemma lies in the fact that I want to disable or hide t ...

Styling Text with Shadow Effects in Mobile Web Browsers

I'm attempting to apply a text-stroke effect using text-shadow like this: .text-stroke { text-shadow: -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white, 1px 1px 0 white; } Unfortunately, it's not rendering correctly on mobile versions of Fi ...

Is there a way to link the datepicker of one calendar to automatically sync with another under specific circumstances?

I have implemented two datepicker fields on a single page: Start Date and End Date. $("#orders-start-date").datepicker({ dateFormat: "yy-mm-dd", maxDate: new Date(), onSelect: function(date, el) { $this.trigger("orders:filter", date, $ ...

Automate web page interactions using Python Selenium to duplicate a class

Is there a method to duplicate a class? view image description here Upon examining the data-sitekey, I aim to replicate everything following it, namely 6Ld_LMAUAAAAAOIqLSy5XY9-DUKLkAgiDpqtTJ9b. Is this feasible? ...

Material UI button text not receiving props

Within my application, I have a situation where I utilize data attributes on buttons to gather specific contextual information in the modal that is triggered by clicking the button. This functionality depends on accessing the data attributes through e.targ ...

Creating a custom Chrome extension with the ability to modify the pop-up window instead of the web page

Is there a way to modify the content inside my extension's pop-up without affecting the web page being viewed by the user? Also, how can I ensure that my dropdown list functions correctly? I have two dropdown lists where selecting an option from the ...

How can the "Search within page" feature locate words that are divided between different elements?

I need to present text in groups of a specific length while still being able to search for text that spans multiple groups on the page. Additionally, I want to include a character above each group. My current approach is as follows: body { marg ...

Why isn't the CSS pseudo ::before functioning properly on an Icon element?

I am encountering an issue with displaying a vertical line to icons in my HTML code. The structure of the HTML is as follows: Below is the HTML code snippet: <div class="newsTimePeriod item-One"> <h3>News</h3> ...

Move the items downwards to occupy any empty space vertically

Just a quick overview of the code I'm working with (I am using Material UI in React). This container is meant to hold chat messages exclusively. const ChatContainer = ({ chatMessages }) => { const classes = useStyles(); return ( <Paper ...

Tips for showcasing individual row information in a popup window with Angular 9

Here is the code snippet for utilizing the open dialog method in the component: import { Component, OnInit } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { AuthService } from '../_services/auth.se ...

Retrieve the user's information using their email address

I am attempting to retrieve "Registered user information" on my email address using the "mail()" function. The mail() function is functioning correctly and successfully sending the email to the specified email address, however, it is unable to retrieve the ...

Customizing text appearance with innerHTML in JavaScript: A guide to styling

Below is the code I have for a header: <div id="title-text"> The Cuttlefisher Paradise </div> <div id="choices"> <ul> <li id="home"><a href="#">Home</a></li> <li id="contact">&l ...

Algorithm that continuously increases a given date by 3 months until it surpasses or matches the specified creation date

I am currently working with QuickBase, a platform that involves HTML. My goal is to develop a code that can take a [fixed date] (always in the past) and increment it by 3 months until the MM/YYYY exceeds or equals the MM/YYYY of the [creation date]. Once t ...

Guide on retrieving HTML content from a URL and showing it in a div

I'm trying to retrieve the content of a URL and display it within a DIV element, but I'm struggling to achieve the desired result. Below is the code I'm using: index.js fetch('https://github.com/') .then(res => res.text()) ...

How to change the focus on a Material UI input field

I am facing an issue with resetting/clearing an input field using a button click: Take a look at the code here for reference. const searchInput = useRef(null); const clearInput = () => { searchInput.current.value = ''; searchInput ...

Cannot upload pictures using pixi.js PIXI.Texture.from()

I'm currently developing a web game using React with PixiJS. I am trying to incorporate images from my local directory into Pixi.js. For reference, I found this helpful website: Here are the snippets of code that I have used: import * as PIXI from & ...