Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8458665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:08:27+00:00 2026-06-10T13:08:27+00:00

I have a JavaScript-driven parallax slider, adapted from this tutorial ( http://tympanus.net/codrops/2011/01/03/parallax-slider/ ), and

  • 0

I have a JavaScript-driven parallax slider, adapted from this tutorial (http://tympanus.net/codrops/2011/01/03/parallax-slider/), and a small script which fades the slider image out after scrolling past a certain point.

Here is the script:

    $(document).ready(function() {

        $(window).scroll(function () {
            var $slider = $('.pxs_slider');
            var sTop = $('body').scrollTop();
            var sTop_ff = $('html').scrollTop();
            var opacity = 1;

            if(sTop < 40) {
                opacity = 1;
                if(sTop_ff < 40) {
                    opacity = 1;
                } else {
                    opacity = 0;
                }
            } else  {
                opacity = 0;
            }

            $slider.css('opacity', opacity);
        });
  });

It all works fine, but scrolling becomes significantly sluggish during this transition. However, I’ve found it only really has this issue in Chrome of all browsers. There is no performance hit in Firefox.

Is there a more efficient approach to this effect I could try?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:08:29+00:00Added an answer on June 10, 2026 at 1:08 pm

    Cache $('.pxs_slider') so it’s not queried every time the scrollbar moves is the big one:

    $(document).ready(function() {
        var $slider = $('.pxs_slider');
    
        $(window).scroll(function() {
            var sTop = $('body').scrollTop();
            var sTop_ff = $('html').scrollTop();
            var opacity = 1;
    
            if(sTop < 40) {
                opacity = 1;
                if(sTop_ff < 40) {
                    opacity = 1;
                } else {
                    opacity = 0;
                }
            } else  {
                opacity = 0;
            }
    
            $slider.css('opacity', opacity);
        });
    });
    

    Also, $(window).scrollTop(), I believe, is the correct way:

    $(document).ready(function() {
        var $slider = $('.pxs_slider');
    
        $(window).scroll(function() {
            $slider.css('opacity', $(window).scrollTop() < 40 ? 1 : 0);
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have javascript code some thing like this -- var count=3; var pl=new Array(count);
I have Javascript function defined in the main index.html file. One part of this
I have javascript code embedded inside a html template file. When I load this
Here is jsFiddle for better understanding: http://jsfiddle.net/BzYcZ/ I have some div that have scrollbars.
I have a small javascript that changes the title of a input-field to it's
I have JavaScript application, where I use client-side templates (underscore.js, Backbone.js). Data for initial
I have Javascript that opens another window and registers a click handler for all
I have JavaScript that is doing activity periodically. When the user is not looking
I have JavaScript code which copies the value of input file and paste it
I have javascript string variable with var sttr=We prefer questions that can be answered

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.