41
Views
9
Comments
How to use javascript to make animation...


Hello. i'm trying to apply js code to make some animation for my screen, but it seems doesn't work, tell me what to do or where i wrong, tks so much, love ^^...

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @Tony Nguyen ,

a few initial remarks, haven't looked at your code yet :

  • there is a warning on your css (orange border) what is it, can it be related ?
  • timing : you are doing some getElementById at the top of that script, but there is no guarantee that those elements are already in the DOM at the time the script gets loaded.

My advice would be to first put the code you are not sure about / unfamiliar with in an action to be triggered by a button, and once you are satisfied it works, work on the timing.

If you need more help, please share an oml.

Dorine

PS : to help yourself understand what's going on, add a console.log of each variable you are setting, right after setting it, that will also help you see if they are set properly.  In your example, it will probably show a lot of undefined's.


2024-05-15 07-07-20
Thinh Du

Thx so much. This is oml file
https://drive.google.com/file/d/1cZNQDgsABd7Q_zqKKjxUJI27kOw7PAfA/view?usp=sharing

2024-05-15 07-07-20
Thinh Du

those issues are in sreen test 1...

2021-09-06 15-09-53
Dorine Boudry
 
MVP

no, attach the oml to the post, no links to google drive, please

2024-05-15 07-07-20
Thinh Du

my oml file is over than 5mb so i can't..up load here...

2021-09-06 15-09-53
Dorine Boudry
 
MVP

why is it that large ?  Have you removed all unused dependencies ?

you could always make a smaller one demonstrating the animation part (so just that sample screen with the sample script).

Dorine

2024-05-15 07-07-20
Thinh Du

it's just 18mb, lady. i just test some screen so it includes some images...

2021-09-06 15-09-53
Dorine Boudry
 
MVP

euhm,

ok, I think that's extremely large for a single module and should probably be looked at fixing, but that's outside the subject of this post.

So, let's wait and see if someone feels like downloading that to their personal environment from your google drive, then...

Dorine

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Tony,

As Dorine already pointed out, one of the main reasons the script didn't work as expected is that the referenced elements in the JS code were not rendered in the DOM at the moment of execution.

To make it work, I have made a few code changes as mentioned below: 

Code Changes:

  • Load the JS script file in the screen's OnReady event handler flow using RequireScript client action.
  • Use the container widget, which is a <div> element, instead of using an HTML element. 
  • Reference the element using a class selector instead of a hardcoded ID value, as the element's ID value is defined at runtime.
  • Made few code changes in the JS script file.

Demo app: Animation_POC

Refer to the attached OML file with the code changes.

I hope this is helpful to you!


Kind regards,

Benjith Sam

NeoLab_AnimationJS.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.