Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jQuery Ajax Slide effect

Featured Replies

I have a content box with a nav which updates via xhr/ajax. When a link is clicked it displays a loading icon and loads the new content and. It's working fine, However i want old content to slide out to the left, and new content to slide in via the right. Whenever i try to do this via the animate function theirs a little lag which seperates the old and new content.

 

Anyone know the best approach to do this? The only thing i can think of is this kind of process.

 

Link clicked > Create replica content are to the right > Load content into new area > Content loaded > Slide Both content areas right > Destroy Old content area.

 

It just seems kind of long winded, is their a better approach i can take?

  • Author

Yeah but doing that creates a lag between the two animations. I need them to run together.

 

Currently i'm just using a fade,

 


updateHandler: {
           "#content": 

           	function (a) {
               $(this).animate({
                   opacity: '0'
               },


               function () {
                   $(this).html(a).animate({
                       opacity: '1'
                   })
               })
           }

 

 

But like above, it's going to: Fade out > Load content > Fade In

 

If i animate it as a slide effect it'll Slide out > Load Content > Slide In

 

I want it to Load Content > Slide old content out & slide new content in (together).

 

I just don't know the easiest way of doing this.

 

EDIT: I'm using the jQuery.ajax() function.

  • 4 weeks later...
  • Author

Didn't see you'd replied...

 

You could also try adding a function in the beforeSend callback too - although in the past I've had problems trying to get that to work in IE6 for some reason :(

 

I'll look into that, thanks. IE6 isn't a support issue for me :)

 

Don't know how well it'll work, we've updated the animation method, to run through a specified set of components and animate them individual (you should watch the cpu usage burst at this point).

 

$('.tab' + number + ' .animate_me').each(function(i){
var speed = 450;
var this_css_left = jQuery(this).css("left");
var pos_left = parseInt(this_css_left.replace(/px/g, ""));
var adjust_left = pos_left + ((i+1) * 35);
$(this).animate({left:adjust_left},speed,"linear").animate({left:pos_left},300);
});

It creates a pretty cool effect though. Projects on hold atm (or indefinitely) though :(

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.