GSAP, x-y transformation in the Modern Player
Mar 12, 2021
As some other users in other posts commented when resizing/scaling your browser a Storyline using GSAP for animation will loose its proper positioning and that ain't fun. Allthough i had that fixed for quite a while i didnot have the time to post about it. Well here is a solution. In the attached Storyline there is a function called 'get_XYPos()'. That function returns an array with the x and y value of the object you are using. In the Storyline there is a GSAP timeline looping a shape to scale up and down. A small rectangle (1 x 1 ) is positioned in the Storyline and used as reference to the correct position. On resizing the browser window, a function is called killing the GSAP timeline tween and then getting the new x/y positions and setting the circle to that new correct position.
Then the looping GSAP timeline resumes and the animation continues...
48 Replies
Timing probably is the main issue. In my setup i count and check whether all scripts are loaded. When that is true i set a variable and when that changes...i know all needed scripts are loaded and i can register and do anything needed. I do think here the scripts never get fully loaded at the moment when registering the plugins. Trying to fix it in your setup now.
Im gonna change it to my approach on loading external scripts... yours should work...but doesnot... lets see if that helps.
There is something really fishy in your setup...as i publish it with your code and my loading setup...it fails too. If i however publish an older version using GSAP Plugins...they work as before. So i will investigate further.
Figured it out. Lines in Storyline are not pure SVG. That was the issue. When using a proper SVG it works fine...as you can see in this sample.
Yes, you solved the issue. I wrestled with this hoping I would figure it out, but needed your expertise. Thank you for your help!
Hi Math, do you know of a way to use Greensock to target the Next button on the player (modern version of the player)?
Use a variable. If true go to next page.
That is a great idea. Do you think it is possible to also make the Next button on the player yoyo fade when the user reaches the end of the timeline?
Sure. Find the selector for it in the console... and when a variable is true... yoyo fade the playerbutton. Oncomplete of that GSAP go to the next page.
Would the selector be the id of the item - like in the example below "next" - do I have to include any parent reference?
and the variable would be like the example - var nxtBtn = document.querySelectorAll( "[data-acc-text='next']");
When using the console, you can test directly in the console whether some code works.
Like this...
Step 1: Get your selector or JS path ( either will do ). Right click any element to get this popups.
Step 2: You now have a line of code like this:
document.querySelector("#next");
Step 3: Use some GSAP animation on it. Like this:
let nextBttn = document.querySelector("#next");
gsap.to(nextBttn, { duration:0.5, autoAlpha:0 });
Step 4: Test it in the console by pasting it inthere. As seen here:
Step5: Press ENTER and you see your code executed. Notice the next button disappearing in 0.5 seconds. And thus this will work when using it in Storyline too.
It worked perfectly! I appreciate you showing me the steps you went through to capture the button id and how to test it, I am not sure if I would have figured this out without your step by step example. Incorporating this into my project. Thank you!!
Knowing the browser console and how to use it is key. Especially because Articulate changes things on updates, and then the only way ( without proper documentation on Articulate side ) to figure out why things wont work anymore is the console.
I have a project that I am working on that the buttons work for Desktop use, but the mobile use - mobile Chrome - the button doesn't work. Is there an extra listener or code that I need to apply?
//== code below ===
submitButton.forEach( item => {
item.addEventListener('mouseover', OverSub_01 );
item.addEventListener('mouseout', OutSub_01 );
item.addEventListener('click', PressSub_01 );
});
function OverSub_01 ( event ) {
gsap.to(submitButton, .5 ,{alpha:.6, ease: "back.out(1)"});
}
function OutSub_01 ( event ) {
gsap.to(submitButton, 1 ,{alpha:1, ease: "back.out(1)"});
}
function PressSub_01 ( event ) {
gsap.to(CorrectAnswer, .5 ,{x:"-2%", ease: "back.out(4)"});
}
Probably you should need to add a listener for a touch event.
Hello Math,
I want to make an animation, but I couldn't make it happen. I couldn't adjust the Y position as I wanted. When I hover over the button, I want it to slide to the top a little and when I move over it, I want it to come back to its place, but it didn't work exactly the way I wanted. Do you have any ideas about this?
https://360.articulate.com/review/content/395de61b-fe88-4577-8c4d-142ab63c5745/review
Better to share your Storyline sample...as is its hard to check what your doing.
This post was removed by the author
This post was removed by the author
Sure.
Funny... but onhover and changing x/y position is offcourse something awkward. The moment your y-value changes enough the hover returns false and thus the action will be stopped and the element returns to its original position. So to achieve what you want, you need to hover a hotspot...and trigger another element.
https://360.articulate.com/review/content/e41012ae-7099-4e3f-8d6f-58fa5edc0e21/review
Fixed in here...
Kind regards,
Math
Thanks for your help, I didn't know about the features you wrote about, I'll look into them. I'm trying to make animations like the buttons here. Thanks again
https://genial.ly/template/true-or-false-quiz/
You dont really need Javascript or GSAP for these. Easy to do with button states.
I am trying to have a graphic item in storyline follow or replace the mouse, but I am running across the situation that the mouse tracking is going off - it seems to be tracking the full screen size and just not the slide window. Is there a fix for this? File that I have been testing is attached, any help is much appreciated.
@James could you share your file? Thank you!