Navigational Scroll Parallax Issues

I have been trying to implement a basic 2 layer parallax effect using ScrollMagic on my index page. The layout consists of a large image with content below it, but I am facing some challenges. Despite going through the documentation and source code multiple times, I can't seem to get it to work. Here is a snippet of the code I am working with:

HTML:

<div class="row zero-padding parallaxParent" id="parallax1">
  <div class="col-xs-12 zero-padding index--background" style="background-image: url('{{ backgroundimage.picture.url }}')">
    <h1>MACRO FOODS</h1>
    <h2>Healthy made easy</h2>
  </div>
</div>

<div class="row zero-padding">
  <div class="col-xs-12 index--title">
    <p> What is Macro Foods?</p>
  </div>
</div>

<div class="row zero-padding index--blockwrap">
  <div class="col-xs-12 col-md-8">
    <p class="index--body">{{ whatismacrofoods.text }}
  </div>
  <div class="col-xs-12 col-md-4">
    <img class="index--image" src="{{ imagesindex1.picture.url }}">
  </div>
</div>

<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/debug.addIndicators.min.js"></script>
<!--Custom-->
<script src="{% static 'scripts/main.js' %}"></script>
<script src="{% static 'scripts/parallax.js' %}"></script>

CSS:

.parallaxParent {
  height: 100vh;
  overflow: hidden;
}

.parrallaxParent > * {
  height: 200%;
  position: relative;
  top: -100%;
}

Parallax.js:

//Parallax Scrollmagic
var controller = new ScrollMagic.Controller({globalSceneOptions: {triggerHook: "onEnter", duration: "200%"}});

new ScrollMagic.Scene({triggerElement: "#parallax1", duration: "120%"})
.setTween("#parallax1 > div", {y: "80%", ease: Linear.easeNone})
.addIndicators()
.addTo(controller);

new ScrollMagic.Scene({triggerElement: "#parallax2"})
.setTween("#parallax2 > div", {y: "80%", ease: Linear.easeNone})
.addIndicators()
.addTo(controller);

new ScrollMagic.Scene({triggerElement: "#parallax3"})
.setTween("#parallax3 > div", {y: "80%", ease: Linear.easeNone})
.addIndicators()
.addTo(controller);

Answer №1

Update following revisions to the original post:

I noticed that your code does not reference TweenMax.js and animation.gsap.js - are they somehow included in other scripts?


Additionally, as per your second comment:

You can include TweenMax.js using this snippet:

<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>

For including animation.gsap.js, use the following code:

<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/plugins/CSSPlugin.min.js"></script>

Alternatively, you may also find it within the "plugins" directory of your "scrollmagic" folder.

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

Error: The function $.cookie() is not defined in Angular2 Typescript

After installing @types/jquery, I updated tsconfig.json to include jquery.cookie in the types section. Visual Studio Code indicates that $.cookie is ready for use, but when I execute my code, an error appears in the console stating that $.cookie() is not ...

A guide to efficiently deleting multiple items using checkboxes and an Ajax request

Could someone assist me in deleting values with a checkbox using an AJAX call? I'm unable to identify the error. Also, this is a template and it already has a built-in "check all" feature so there's no need to modify any built-in code for the ch ...

What happens when there is a 1-second delay in loading CSS on an HTML page?

Lately, I've been working on creating HTML and CSS pages. However, whenever I load a page, I notice that there's always a brief half-second flash of the HTML content without any styling applied. Does anyone have an idea why this is happening and ...

Swap Text/Characters When Hovered Over

I'm looking to add a fun interactive element to my webpage where the letters in certain text rearrange when a user hovers over it. For instance, hovering over "WORK" would display "OWKR" instead. I have a feeling that some JavaScript is needed for thi ...

jQuery menu animation not triggering until second click

I am currently working on implementing a menu that will slide in after clicking the hamburger button (located in the upper right corner). Instead of simply appearing, I wanted to use a jQuery function for a smoother sliding effect. However, I seem to be e ...

Verify with PHP

I am looking to add a simple button on my HTML page that can trigger my PHP script when right-clicked. I have attempted to do this with the code below, but unfortunately, I haven't had much success so far: //My html code <!DOCTYPE html> <hea ...

Loading CSS files conditionally in Angular2's index.html

Currently, my index.html page features a dark theme: <base href="/"> <html> <head> <title>XXX</title> </head> <body> <link rel="stylesheet" type="text/css" href="assets/dark_room.css"> <my-app ...

Show information from a JSON response using Ajax and present it on a jQuery dialog within an MVC3 view

I currently have an ActionResult method within a Controller which retrieves a row of data (such as id, name, city, etc) from the database based on the provided ID [HttpPost] public ActionResult Get(Guid Id) { Ref imp = ReadRepository.G ...

Submitting information via jQuery

https://i.stack.imgur.com/VU5LT.jpg Currently, I am working on integrating an event planner into my HTML form. However, I am facing difficulty in transferring the data ("meetup", "startEvent", "break") from HTML to my database. Using jQuery, I was able to ...

How can I restrict the number of items displayed in each row within a navigation submenu flexbox?

My primary navigation menu has numerous child items, and I want to ensure they remain visually appealing and organized. To achieve this, I am aiming to limit each row of submenu items to only 4. After researching other solutions online, I attempted adding ...

How can I display an HTML document by uploading it and rendering it in VueJs?

I am looking for a way to display HTML documents on the front end of my Vue.js application. My goal is to retrieve the HTML content from my database and render it seamlessly on the user interface. Any suggestions or guidance would be greatly appreciated. ...

"Enhance Your Table Design with Zebra Cells Using CSS in rich:data

How can I achieve a zebra color effect in every other cell of a rich:dataTable using CSS? <rich:dataTable value="#{uploader.files}" var="_data" id="files"> <rich:column> <f:facet name="header"> <h:outputText ...

Is there a way to shift this structure to the right without relying on the float property?

Here's the HTML and CSS I have - .font-size-add-class { background-color: #2f2f2f; color: #f9f7f1; } .font-sizes { text-align: right; display: table; margin-top: 15px; cursor: pointer; } .font-sizes > .small { font-size: 12px; } .font ...

Implementing hashing with resumable.js

Looking for a way to include hashing in resumable.JS by utilizing the "fileAdded" event hook. Any suggestions on how to add hash to each chunk? ...

Using JavaScript to assign one object to another object

I am facing an issue where I am trying to assign the local variable UgcItems to uploadedItems, but when I attempt to return the value, it shows as undefined. If I place the console.log inside the .getJSON function, then I get the expected value. However, t ...

Stop JQuery from executing when an error is caught

Once the document is ready, I have configured: $.ajaxSetup({ "error": function (XMLHttpRequest, textStatus, errorThrown) { if(XMLHttpRequest.status == 403) { display_modal( 'Please login to continue.', &ap ...

What is the best way to define coordinates or set margins for the autoTable component in jsPdf when using React js?

While working with the jsPdf library to create a PDF in React, I am encountering an issue where I am unable to set margins for the autoTable when there are multiple tables on a single page. Below is the code snippet: import React from "react"; ...

Applying toggle() using css to manipulate various elements at once

Is there a way to toggle multiple divs of varying heights, all with the same class? What is the most effective approach to achieve this? http://jsfiddle.net/hS6RH/41/ $('.smallify').on('click', function() { if ($(this).parent(&apo ...

PHP/JSON formatting

My goal is to populate a dropdown menu with entries from MySQL using a technique I found in this particular answer. It's functioning well - when an event is selected, a new dropdown appears with the dates that event is scheduled for. But now, I also ...

Integrate a PHP variable into an HTML/JavaScript statement that was previously transformed from PHP

Incorporated within this PHP variable is a mix of HTML and JavaScript code. My task is to enhance it by adding another PHP variable. Specifically, I have a PHP variable denoted as $user->user_email. How can I seamlessly integrate this variable into th ...