Explore the limitless possibilities of using jQuery Superscrollorama with fixed backgrounds

I am looking to achieve a scrolling effect with multiple elements, specifically three pictures in this case.

While it is easy to implement scrolling, my goal is to keep the background fixed during the scroll event and have it move once the scrolling is complete.

HTML:

<div id="infografik">
    <div id="innerWrapper">
        <div class="minerWrapper">
            <img class="miner1" src="<?php bloginfo('template_url'); ?>/images/infografik/00_miners/Girl_Miner.png" alt="girl miner" />
            <img class="miner2" src="<?php bloginfo('template_url'); ?>/images/infografik/00_miners/Head_Miner.png" alt="girl miner" />
            <img class="miner3" src="<?php bloginfo('template_url'); ?>/images/infografik/00_miners/Boy_Miner.png" alt="girl miner" />
        </div>
    </div>
</div>

CSS:

#infografik{
    font-size:100px;
    width:100%;
    background:url('../images/infografik/whole_bkgd_2.jpg')center center no-repeat;
    height:6200px;
    /*position:fixed;*/
}
#innerWrapper{
    width:935px;
    height:100%;
    margin:0 auto;
    background-color:red;
    opacity:0.3;
}
.minerWrapper{
    top:260px;
    position:relative;
}
#scrollwrapper{
    height:6200px;
    position:absolute;
    /*overflow:scroll;*/
}

JQuery:

controller.pin($('#infografik'), 700, {
    anim: (new TimelineLite())
        .append(
            TweenMax.fromTo($('img.startGM'), .45,
                {css:{width: 22}, immediateRender:true},
                {css:{width: 172}})
        ),
    onUnpin: function(){
        $('#infografik').css('position', 'relative');
    }
}, -2000);

I initially tried setting the background to a fixed position, but it kept jumping back to its original position after the scroll event...

I also attempted to use superscrollorama's pin function on the minerWrapper element, but that resulted in the miners remaining static while the background continued to move. I need everything to move during the scroll event.

Regards, Timmi

I need to h

Answer №1

Timotheus, your approach to this issue seems misguided. The pin should be used to set the page in place, rather than changing the background.

It's important to avoid making position changes with the pin as it could lead to unexpected results in the DOM. I suggest starting fresh by removing all positioning.

Based on my understanding, you are attempting to animate three images but I'm not quite following your intent. Would it be possible for you to create a JSFiddle or similar demonstration for better clarity?

Answer №2

To address this issue, we can implement an automatic scroll down function when the webpage is loaded.

Below is the script that achieves this:

function ScrollDown() {
     window.scroll(0, 1); 
}

Check out these example links for reference:

http://codepen.io/subin/pen/dprkkY

We value your input and suggestions on how to improve this further. Please share your thoughts with us.

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

Positioning a Material UI Menu item underneath its parent element using CSS styling

I have created a Material UI dialog that features some text and an Icon with a dropdown menu option. You can check out the demo here: https://codesandbox.io/s/prod-rain-1rwhf?file=/src/App.js My goal is to properly position the Menu component so that it a ...

Formatting HTML Output Using PHP

Looking to format html output sourced from a database using php and facing an issue: Desired Format: ... <li> <div class="row-wrapper"> <div class="some-class-1">ARRAY-ELEMENT-1</div> <div class="some-class-1" ...

Displaying Previously Selected Value in HTML Dropdown Menu

Using a combination of PHP and HTML, I have created an HTML table that is generated using a PHP while loop. The dropdown menu on the page displays all distinct portfolio names from my MySQL database by executing the following code: $query2 = "SELECT DISTI ...

Trouble with ScrollTo animation on div with adjustable offset top feature - seeking assistance

Having trouble navigating to the correct slide when clicking the right button on the navigation menu. Clicking the menu button displays a list of links. Clicking on a link for the first time will take you to the correct slide, but if you try clicking a dif ...

Alternative to Geolocation and GeoIP

Are there any reliable and accurate alternatives to GEOIP and HTML 5 Geolocation that can function effectively on BlackBerry browsers? ...

The v-menu closes before the v-list-item onclick event is detected

I have set up the following menu using vue and vuetify: <div id="app"> <v-app id="inspire"> <div class="text-center"> <v-menu> <template v-slot:activator="{ on }"> ...

Problem with aligning divs in Bootstrap

I am currently facing a challenge when it comes to aligning my div in Bootstrap 3. My goal is to achieve the following: I have experimented with pull and push commands, but it seems like I still need more practice. Code: <div class="container"> ...

Utilizing the GData API for seamless integration with cross-domain ajax requests

I need to retrieve XML data from Google's server using its API. I am unable to modify the response, so how can I make this call work for me: $.ajax({ type: 'POST', url: 'https://www.google.com/accounts/ClientLogin', ...

Adding a .PHP File to Two Separate DIVs

I am using wordpress to create a custom theme. I'm interested in placing all the content from my slider.php file inside a div box on my index.php page. How would I go about doing this? SLIDER.PHP <div class="slider"> // All the image tags wit ...

Position the tables next to each other

I have utilized Bootstrap 4 to create two tables, showcasing specifications and earning statistics separately. Both tables are enclosed within a col-xs-6 class with the intention of aligning one table to the left and the other to the right. However, at pr ...

Display the current index carousel caption from Bootstrap 4 in a separate div

I'm attempting to showcase the text from the carousel in Bootstrap 4 within another container. Currently, I can retrieve the current index and the text individually, but I am struggling to combine them together. Below is my code, would appreciate an ...

division of vertical space

Is there a way to ensure that the column containing bbb + ccc is the same height as the aaa and ddd columns? <html><body> <div style="width:500px;height:500px;background-color:yellow"> <div style="float:left;height:100%;background-co ...

Warning: Package [email protected] needs jquery@^1.11.3 as a peer dependency, however it was not found in the installation

Trying to create a project using react.js and webpack. After running npm install in the project directory, I encountered this warning: npm WARN EPEERINVALID <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ed9f888c8e99c08f82829 ...

Enhance your photographic experience with the JavaScript Camera API on Android (Froyo

I have been attempting to utilize the JavaScript Camera API through the Android browser, as showcased at Google IO on Froyo. Despite having Froyo on my Nexus1, I am encountering difficulties accessing navigator.device and navigator.camera properties, bo ...

What is the best way to format the JQGrid table for better

Is there a way to indent the table in this example and create white space on the side of the rows and header? I want a white margin on the left of everything below "Stackoverflow example". I'm hoping to achieve this using only CSS. Below is the code ...

Exploring the Document Object Model to locate the adjacent sibling of a parent element

If I need to implement an event that hides the section .dependent-box whenever the element with class .radio-click-hide is clicked, what would be the best approach for traversing the elements to achieve this functionality? I have attempted the following co ...

I am looking to implement screen reader capabilities for both the select-2 combo box and bootstrap's datetime-picker. How can I go about doing

On my existing website, I have select-2 combo boxes for drop-down lists and a Bootstrap Calendar widget. While these features work well, they lack accessibility for users with disabilities. In an effort to make the website inclusive for everyone, I am work ...

Adjusting Div Height According to Width using Jquery

In the case of having a class with a width set to 20%, how can I use jQuery to dynamically change the height of the class to match the same width but converted to pixels? ...

Disable a button during an AJAX request

Whenever a button is clicked, the record is saved to the database without refreshing the page using AJAX. I have implemented the AJAX code successfully. Now I need guidance on how to manage the state of the Submit button - enabling/disabling it dynamicall ...

Django form validation issue - cannot proceed as input is missing in required field

Trying to integrate HTML5 date input (start and end dates) into Django forms for querying orders based on user-specified dates at the front-end. Users input start and end dates, which are then passed to my Django model and through an AJAX call. https://i. ...