Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

92
Views
Adding a smooth transition when loading content on a SPA app

I am trying to implement a smooth transition every time I load content inside the div container of a Single Page application. I'm not using Reactjs, just an onclick function to load the content inside my div #main-content with a Get request.

For reference, this is what the onclick function looks like inside the index file: <a class="" id="home-top-nav" href="#" onclick="$pf.homeHtml()">

This is what the content request would look like in js (invoking an IIFE: global.$pf = pf):

pf.homeHtml = function () {
   $ajaxUtils.sendGetRequest(homeHtml, function (responseText) 
     {document.querySelector("#main-content").innerHTML = responseText;
     }, false);
};

In this case the responseText is the parsed html snippet inside that gets inserted in the main-content with an ajax request. There are many other snippets that load whenever I click and request another page (about, contact, and so on).

I've tried to use Swup with no success.

What can I do to simply add a fade out effect to the content unloading and a fade-in effect to the new content loading inside the #main-content rather than having a hard transition between them?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!