Struggling to use GSAP to control the timeline with my custom functions

I'm attempting to create a greensock animated banner with the ability to switch between different scenes. I've made progress by setting up the timeline for each scene's intro and outro animations using the GreenSock API documentation. However, when I try to add click event handlers, nothing happens – no alerts are triggered.

If you could take a look at my code pen HERE, that would be greatly appreciated.

I've configured a main timeline that plays transitions for each scene in and out, along with pauses after each scene's intro. Additionally, I've labeled the intros and outros for each scene.

$("#NYBtn").click(function() {
alert('Clicked NY!');
tlSlideMain.play(NYSceneIntro);
});

My goal is to have the initial intro animation slide in, and upon clicking the NYBtn, trigger the timeline to play from the label 'NYSceneIntro' as defined in the JavaScript file.

Ideally, I envision having specific functions to animate each Slide depending on which button is clicked:

NYBtn -> NYSlideIntro

NJBtn -> NJSlideIntro

PABtn -> PASlideIntro

...and so on. Am I overlooking something, or is there an issue with my code? Please note that I am fairly new to jQuery and GSAP.

Answer №1

After some investigation, I discovered that the issue was caused by using the incorrect addPause function in my timeline. I have made the necessary changes to the codepen to fix this problem. Now, the transitions are functioning correctly as intended.

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

Adding Bootstrap component via ajax request

I'm facing an issue with injecting a Bootstrap component using ajax. I usually include a select element like this: <select class="selectpicker" data-width="75%"> Most of the HTML code is generated dynamically through javascript, which you can ...

Only the data from the first row will be accepted by jQuery, no other data will be

Encountering a problem with jquery. I have a dynamically created <table>. foreach ($_cards as $_card){ $tabOdd = ""; $statusInd = ""; $counter++; if ($counter % 2 != 0){ $tabOdd = "style='background-color:#eee' ...

Utilizing Ajax for populating a cascading selection menu

Currently, I am in the process of dynamically changing the options in a drop-down list using ajax and jquery by fetching data from a database. With jquery, I can easily clear and add new options to the drop-down. However, my issue arises when attempting to ...

Tips for toggling the visibility of a revolution slider based on current time using JavaScript

Currently, I am integrating the revolution slider into my WordPress website. My goal is to have the slider change according to the standard time of day. For instance, I want slider1 to display in the morning, slider2 at noon, slider3 in the evening, and sl ...

Issue with random pages where global header.php is not showing a specific image

I'm currently revamping a website that was originally developed using codeigniter. The backend is quite chaotic with no clear identifiers for anything. I recently updated the banner in the header.php file, adjusting the style to suit the requirements. ...

Is there a way to position my character at the exact center of my mouse click coordinates instead of the top left corner?

In my game, players can click on a 2D HTML5 canvas to set a point for their character to move to. However, I've noticed that when I click, the character appears in the lower right corner of where my mouse is clicked. After some research, I realized th ...

Achieving Compatibility Between jQuery 3.6.0 and Node.js v12.16.1

Utilizing an online IDE known as Replit, I am working on node.js projects running on the node version: 12.16.1. However, my current challenge lies in attempting to make jQuery 3.6.0 compatible with this particular node.js version. Despite trying various me ...

Fixed Positioning Div to Stay at the Top while Scrolling

Currently, I have successfully implemented the functionality to stick the div to the top once it scrolls down by 320px. However, I am curious if there is an alternative approach to achieving this effect. Below is the code snippet I am using: jQuery(functi ...

Autocomplete alert in jQuery: Get the selected value from the suggestions upon selection

I'm using the jQuery autocomplete plugin for a movie search feature. Each movie has an IMDb ID which is enclosed in a span with the class "imdbID" when parsed by PHP. Here's an example of how it looks: <li>Movie title 1<span class="imdb ...

Yet another inquiry about the inexplicable failure of my jQuery Ajax in Internet Explorer

Just need to double-check if my test code below is correct. I've done some research and it appears that html syntax errors can cause the jquery ajax to not work in Internet Explorer? There are several includes where this code is located, so could the ...

Content editable div causing overflow issues in Internet Explorer

I am having trouble with a content editable div where the text is not wrapping properly. I attempted to use "overflow:scroll" but it only ends up cutting off the text horizontally. https://i.stack.imgur.com/WlMdY.jpg ...

I'm looking for a skilled CSS spinner creator. Can anyone recommend one?

Can anyone recommend a good online application for creating CSS spinners? I've been searching and only found one on David Walsh's blog, but it only has one available. Any suggestions? ...

Tips for increasing the height of a popover when clicked

When a user focuses on the password input, a popover displays information. At the bottom of the popover, there is a link. How can I make the popover expand when the user clicks on this link? I have tried adding an !important class for the height value, us ...

The page background appears to be incomplete in its coloring

As I work on creating a web application for personal use, my goal is to ensure it is mobile-friendly. However, I've encountered an issue where the background of my language page isn't displaying in full blue color as intended. Despite trying diff ...

Concerns arise regarding the implementation of an image slider using HTML and CSS

Hey guys, I've created an image slider, but I'm facing an issue where the first click doesn't trigger a smooth animation. Instead, it jumps to the target without any transition. I want a seamless change of images, but right now it's jus ...

What is the method for incorporating a button on an HTML webpage that triggers a server-side script to execute?

Currently, I have the following: HTML <form action="test.php" method="get"><input type="submit" value="Run me now!"> php <?php shell_exec('sh test.sh'); ?> sh #!/bin/bash sudo systemc ...

Positioning a text field and a button adjacent to each other within the same row

My challenge is to consistently position a textfield and a button side by side. The requirement is for the button to always be on the right side of the screen, while the textfield should take up the remaining width on the left side. I initially tried setti ...

Ways to refine date results using JavaScript

Here is the JavaScript code I have: $(".datepicker").datepicker(); $(".datepicker-to").datepicker({ changeMonth: true, changeYear: true, maxDate: "0D" }); This code ensures that the date selected cannot be beyond the cur ...

Update the chosen option of the <select> element that was generated through PHP if there is a parameter value present in the URL

I'm currently working on a code snippet like this: <select name="id" id="id"> <OPTION VALUE="null">Select<OPTION> <? foreach ($genres as $row){ ?> <OPTION VALUE="<? echo $row->id; ?>"><? echo ...

Developing User-Friendly Websites with Responsive Design

While I was working on my project, I realized that using only pixel values in tables and sidebars was a big mistake. This caused issues because if someone had a different screen resolution, my website would look distorted and unappealing. Could you please ...