Troubleshooting problems with anchor-targets in Skrollr

I am experimenting with having divs overlap each other as the page is scrolled using Skrollr. Initially, I was able to achieve the desired effect with two divs. However, when trying to incorporate a third div, only the first and last ones seem to work properly. I suspect that my understanding of how the data-anchor-target attribute in Skrollr functions may be incomplete. Below is the HTML code I am working with:

<div id="skrollr-body">
        <div id="q1" data-0="top:0%;">
            Text
        </div>
        <div id="q2" data-anchor-target="#q1" data--200-bottom="top:100%;" data-top-bottom="top:0%;">
            Text2
        </div>
        <div id="q3" data-anchor-target="#q2" data--200-bottom="top:100%;" data-top-bottom="top:0%;">
            Text3
        </div>
    </div>

Here is the corresponding CSS:

body, html {
    height: 100%;
    width: 100%;
    padding: 0;
    margin: 0;
}
#skrollr-body {
    width:100%;
    height:100%;
    position:fixed;
}
#skrollr-body > div {
    overflow:hidden;
    position:absolute;
    height: 100%;
    width: 100%;
}
#q1 {
    background: url(http://2.bp.blogspot.com/-RtoJ2papsoA/UhicT91ixmI/AAAAAAAACeg/2XEhv26ZFJc/s1600/jghjgh.jpg) center center no-repeat;
    background-size: cover;
}
#q2 {
    background: url(http://2.bp.blogspot.com/-RtoJ2papsoA/UhicT91ixmI/AAAAAAAACeg/2XEhv26ZFJc/s1600/jghjgh.jpg) center center no-repeat;
    background-size: cover;
}
#q3 {
    background: url(http://iwritealot.com/wp-content/uploads/2010/02/golden-clouds-wallpaper.jpg) center center no-repeat;
    background-size: cover;
}

You can view the Fiddle here.

If anyone knows what might be causing only the first and last divs to behave correctly instead of all three, please share your insights. Thank you.

Answer №1

Check out this example without anchor-target http://jsfiddle.net/YMYTy/1/

<div id="skrollr-body">
    <div id="q1">
        Content
    </div>
    <div id="q2" data-bottom-top="top:100%;" data-top="top:0%;">
        Content2
    </div>
    <div id="q3" data-bottom-top="top:100%;" data-top="top:0%;">
        Content3
    </div>
</div>

Although it's not exactly as I explained, it still functions properly.

A new feature request has been suggested that will make this process much simpler once implemented https://github.com/Prinzhorn/skrollr/issues/185. This will allow you to use data-100p and data-200p for animations after scrolling one or two times the height of the viewport.

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

Automated system is responsible for flagging and disabling comments

We are facing a puzzling issue at the moment. Our comments form allows users to submit their thoughts on news articles, and each submission is immediately accepted and displayed on the same page. Within each comment, there is a link that enables users to ...

Apply a specific image layout once the drop event occurs

I have a container with 5 image pieces that need to be dropped into another container to complete the image. Once an image is dropped, I want to apply the style "position:absolute" so that it sticks to the previous image in that container. Although I have ...

Javascript code to verify whether the page is currently positioned at the top

How can I use JavaScript to determine if the page is at scroll(0,0)? I have a full-page slider that needs to pause when the page is no longer at the top. The page may not be scrolled manually, as there are internal HTML # links that could load the page d ...

Dynamic JavaScript button control based on time

I am currently working on an app and my goal is to have a feature where the user clicks a button, it will then disappear and only reappear after 24 hours. Here's my progress so far. <div class="buttons"> <p><button onclick="hide(); ...

Creating a sleek full-page container with a navigation bar using TailwindCSS

I am currently utilizing Tailwind CSS and in need of creating a layout that consists of: A sticky navigation bar A full-page section with content centered Other sections with varying heights A footer Below is a simple representation: +------------------- ...

Exploring the Differences in Table Resizing between IE8, IE7, and Chrome when using table-layout:fixed

For my HTML timeline view, I encountered an issue that I'm hoping to resolve: I have a table row with 12 cells representing the 12 months, each with a colspan based on the number of days in that month. Another row in the same table contains the indiv ...

Tips on relocating the input position to the top

Currently, I have a text input that is centered horizontally when typing text. However, I want it to be positioned at the top instead. See the following code: height: 143px; width: 782px; font-family: 'Roboto Mono'; background: #FFFFFF; border ...

Convert CSV into an object with additional attribute

I'm attempting to import data from a CSV file into a d3 tree graph. While I've successfully loaded the JSON version of the data, the d3.csv parser isn't returning the expected string. Some approaches I've tried include: treeData.forEa ...

Access to create permissions for collection "faunaDB" denied due to authorization privileges in FQL query using User Defined

I have a custom user role for security that has a predicate function for creating entries in a collection named formEntryData. When I try to create an entry without the function, it works fine. However, when I use the provided function below, I receive a p ...

What is the best way to send JSON data from a DooPHP Controller?

Currently, I am in the process of setting up an AJAX system and I need to create a controller that returns JSON data. While going through examples, I noticed that all controllers end with a call to the view: $this->renderc( 'interest', $d ...

What is the proper way to insert a line break within a string in HTML code?

Trying to simplify my code, I've turned to using Nunjucks to pass a group of strings to a function that will then display them. This is what it looks like: {% macro DisplayStrings(strings) %} {% for item in strings %} <div>{{ item.strin ...

Leveraging AngularJS services within an Angular service

I am currently in the process of transitioning my AngularJS application to Angular. To facilitate this transition, I plan to create a hybrid application that combines both frameworks until the conversion is complete. However, I have encountered an issue wi ...

communication flow in two directions between server and client

Looking for recommendations on a javascript/nodejs solution that enables bi-directional communication between server and client. The application flow involves the client sending a discovery service to the server, which responds with a challenge. The client ...

Causes for the display of the text within the alt attribute

Recently, I attempted to view an HTML page in text browsers and noticed that the alt attribute value of the img tag was visible. I decided to omit the alt attribute and instead utilized CSS: .headerImg:after, .headerImg::after { conte ...

Incorrect Zooming Behavior in HTML and CSS

Currently, I find myself on a website layout where the banner remains fixed at the top of the page while allowing scrolling for the inner div. However, when I zoom in using the browser (ctrl+'+'), the banner overflows the container without making ...

Basic jQuery Slideshow Counter

I'm having trouble implementing a text-based horizontal slider on my website that scrolls left and right with mouse control. I want to display the current index of each slide along with the total number of slides (e.g. 1/4) and update the index as use ...

Exploring the world of WebSockets and Socket.io

Recently many online games, like , have started using WebSockets to create real-time MMORPGs. I'm curious about how to develop a node.js program that can manage connections from browsers using WebSockets. Here is an example of browser code: <!DOC ...

Ways to retrieve the final appearance of element m in array n

As a beginner in programming, my goal is to access the last position of element m within array n. The following code displays all positions of element m: var n = []; while (true) { let input = prompt("Please enter a number for the ...

How to modify ID data with AngularJS ng-repeat

I am currently searching for a solution to easily modify an ID within a repeated ng-structure. This scenario involves having a customer table with unique customer IDs, which are then utilized in another table related to orders. When I retrieve data from th ...

bootstrap 4 - logo in navbar brand stays the same even when scrolling

I integrated Bootstrap 4 and successfully created a navbar. However, I am encountering a conflict when trying to change the navbar logo upon scrolling down. Despite my efforts, it is not functioning as expected. Does anyone know how to resolve this issue? ...