Forum Discussion
GSAP, x-y transformation in the Modern Player
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...
- larryvanwave-ffCommunity Member
Hi Math, do you know of a way to use Greensock to target the Next button on the player (modern version of the player)?
- MathNotermans-9Community Member
Use a variable. If true go to next page.
- larryvanwave-ffCommunity Member
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?
- MathNotermans-9Community Member
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.
- larryvanwave-ffCommunity Member
- larryvanwave-ffCommunity Member
and the variable would be like the example - var nxtBtn = document.querySelectorAll( "[data-acc-text='next']");
- MathNotermans-9Community Member
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. - larryvanwave-ffCommunity Member
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!!
- MathNotermans-9Community Member
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.
- larryvanwave-ffCommunity Member
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)"});
} - MathNotermans-9Community Member
Probably you should need to add a listener for a touch event.
- MerveSatmazCommunity Member
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
- MathNotermans-9Community Member
Better to share your Storyline sample...as is its hard to check what your doing.