attempting to utilize staggerTo function in GSAP

Struggling to animate my images with greensock so they start from bottom: 0, have opacity 1, and stagger in. My code seems valid but I must be missing something after looking at it for so long.

I suspect the find() function is not returning what I expect since I don't see an object containing all the img elements.

Here's what my console is showing:

[prevObject: jQuery.fn.init[0], context: document]

This is my Script:

$(document).ready(function(){
    var mainText = $('ul.images li').find('img');
    console.log(mainText);
    var tween = TweenMax.staggerTo(mainText, 0.75, {
        opacity: '0',
        bottom: '300px',
        left: '50%'
    }, 0.3);
});

Here is my HTML:

<ul class="images">
    <li class="image brain"><img src="img/science/brain.svg" class="img brain" alt="cell-watermark-bg"></li>
    <li class="image mitochondria"><img src="img/science/mitochondria.svg" class="img mitochondria" alt="cell-watermark-bg"></li>
    <li class="image microscope"><img src="img/science/microscope.svg" class="img microscope" alt="cell-watermark-bg"></li>
    <li class="image scientist"><img src="img/science/scientist.svg" class="img scientist" alt="cell-watermark-bg"></li>
    <li class="image beaker"><img src="img/science/beaker.svg" class="img beaker" alt="cell-watermark-bg"></li>
    <li class="image beaker-2"><img src="img/science/beaker-2.svg" class="img beaker-2" alt="cell-watermark-bg"></li>
    <li class="image atom"><img src="img/science/atom.svg" class="img atom" alt="cell-watermark-bg"></li>
    <li class="image dropper"><img src="img/science/dropper.svg" class="img dropper" alt="cell-watermark-bg"></li>
    <li class="image dna"><img src="img/science/dna.svg" class="img dna" alt="cell-watermark-bg"></li>
</ul>

My CSS (SCSS):

ul.images {
    position: relative;
    .image {
        position: relative;
        width: 100%;
        .img {
            position: absolute;
            height: 50px;
            opacity: 1;
            -webkit-transition: background-color 0.2s ease;
            -moz-transition: background-color 0.2s ease;
            -o-transition: background-color 0.2s ease;
            transition: background-color 0.2s ease;
            &.dna {
                bottom: -40px;
                left: -30%;
            }
            // Rest of the image styles...
        }
    }
}

Answer №1

The issue stemmed from a mistake in your scss file. The ul.images{...} section was not properly closed. I made the necessary correction, and it appears that the animation is now working correctly based on your description.

For reference, you can view the updated code on Codepen here.

Please note that I have included a one-second timeout for your js to allow elements to be placed on the stage before the animation begins.

It's interesting that your sass compiler did not flag this error for you initially.

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

Unexpected error occurred when attempting to fetch the jQuery value of the radio button: "Unrecognized expression syntax error"

I am facing an issue while trying to extract the value of a radio button using $("input[@name=login]"); I keep getting an "Uncaught Syntax error, unrecognized expression" message. To view the problem, visit http://jsfiddle.net/fwnUm/. Below is the complet ...

The importance of precision in a written text

When it comes to being specific, I usually pride myself on my skills. However, there's one particular challenge that I can't seem to crack. Here's the scenario: Imagine you have a list structured like this: <ul class="dates"> < ...

Adjust all children's height to match that of the tallest child

My nearly completed jQuery slideshow is working well except for one issue - the height of the slideshow remains fixed at the height of the first displayed slide, causing problems. View the issue here: . I have tried different jQuery solutions from StackOve ...

The frozen first column in a CSS table does not have consistent height with the rest of the row

Having trouble with freezing the first column of a table and aligning the height of the first cell with the rest of the row? Check out the issue in the image below: https://i.sstatic.net/v5xHU.png For a live example, you can also visit this jsfiddle link ...

Validation of custom fields for shipping carriers on the checkout page of a WooComerce store

I have successfully customized the shipping method section by adding two custom input fields and making them conditionally required. These fields only appear and become mandatory when a specific radio button is checked, thanks to my jQuery code that handle ...

Using Javascript's document.write function to modify the content of a PHP page

Here is a Javascript function that capitalizes the first letter of a string: function capitalizeFL(string) { return string.charAt(0).toUpperCase() + string.slice(1); } In a file named statuswindow.php, there are PHP scripts that use this function to ...

"Exploring the Dynamic Duo of AngularJS ngAnimate and animate.css

I've been working on getting my animation to function correctly with AngularJS and animate.css. In order to achieve this, I set up the SASS in the following way: .slide-animate { &.ng-enter, &.ng-leave{ } &.ng-enter { ...

Bootstrap: Utilizing a full width grid system with columns contained within a container

Looking to design a unique layout that spans the full width of the page, featuring a blue half on the left and a red half on the right. Next, I would like to insert text into the layout, but within a container element. Is this doable? UPDATE: Notice that ...

Injecting Ajax-loaded content into an HTML modal

Hey there! I'm currently working on a project involving the IMDb API. The idea is that when you click on a film title, a popup should appear with some details about the movie. I've made some progress, but I'm stuck on how to transfer the mov ...

Adding style using CSS to a dynamically generated table row in Vue.js

Currently, I am working with a table that dynamically generates rows using v-for: <table> <tr><th class='name'>Name</th><th>Surname</th></tr> <tr v-for='data in datas'><td class=&a ...

Change the button icon to something new when you hover over it

Below is the liquid code I am working with: <a href="{{ section.settings.button_link }}" class="btn--rounded"> {% include 'icon-btn--rounded' %} <div class="link-label">{{ section.settings.button_ ...

Incorporating Angular into the script code of the extension content

I am looking to customize text fields on a website using a chrome-extension. However, the website is built with Angular, so I need to modify the text fields using Angular code. To incorporate Angular in my extension's scope, I am attempting to declar ...

Sending AJAX data by clicking a link in Laravel 5

I am new to working with ajax and Laravel 5 I am facing some issues with passing data when clicking on a link. Let me explain what I am trying to achieve. Here is my HTML code: //this is the div that I want to append with data for each <div id="warun ...

"Render Failure" JavaScript and CSS files

I'm encountering a peculiar issue while attempting to load certain JS and CSS files. Within my ASP.NET MVC Web Project, I have an Index.html file where I've specified the loading of script files. It's worth noting that I have modified the U ...

What methods does YepNope.js offer for assigning dynamic names to scripts?

Currently, I am utilizing YepNope.js to handle the loading of my css and javascript files. My query is regarding whether there is a method to assign variable names to these scripts during the initial process. For example: yepnope({ test : Modernizr.cs ...

Unequal spacing between the edges of two background images

I am attempting to create two distinct "layers" of background on my webpage by encapsulating the content within a div element. Strangely, the background set for the div is being clipped before it reaches the edge of the screen, while the one designated as ...

Tips for using JavaScript to consume a complex type returned by a WebMethod on the client side

I am new to Webmethods and Services and I find myself in a bit of a predicament here. The webmethod I have returns an instance of the StatusViewModel class. [WebMethod()] public static StatusViewModel GetTime1() { Debug.Write("Timer") ...

Having difficulty creating JSON data following retrieval of rows by alias in MySQL

I am encountering an issue while trying to fetch rows from two tables using a JOIN and aliases. The problem arises when I attempt to convert the fetched rows into JSON data and assign them to a JSON array. Below is the code snippet: $personal = $db->p ...

What steps should be followed to construct a window identical to the one depicted in the attached image using HTML and CSS?

Check out this link to see the window style I'm trying to recreate using HTML, CSS, and Javascript. No Jquery needed. Thank you in advance. ...

Is there a way to automatically insert page numbers into every internal link on an HTML page?

When in print mode, I want to display links like this: <a href="#targetPage">link</a> but I'd prefer them to appear as: <a href="#targetPage">link (page 11)</a> (assuming the target page is on page 11 in the print preview). ...