Jump to content
Search Community

asoelist

Members
  • Posts

    9
  • Joined

  • Last visited

Posts posted by asoelist

  1. 1 hour ago, GreenSock said:

     

     

    I assume you're getting that error because at the time you try to register one of the plugins, the gsap.min.js file hasn't loaded yet. You've got to make sure that loads FIRST because obviously you can't register a plugin with GSAP if GSAP doesn't even exist yet (hasn't loaded). 

     

     

    Perhaps this is the solution to make sure gsap.min.js is loaded first:

    image.thumb.png.a80d33c7a48b07ddb2ef9a95cbfdccbc.png

     

    Thanks @GreenSock and @Rodrigo. It clears up my understanding of registerPlugin.

    • Like 3
  2. Thanks for replying @Rodrigo,

    Loading gsap libraries dynamically allows me to insert gsap when it's needed. Here is my loadScript: 

    image.thumb.png.45467d6cc3cd8ef0fb9c412a26b2f6d8.png

     

    And like you said I appended (and the other 3 libraries)

    "<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>"

    into the document.head. 

     

    But sometimes I got this error from google's developer's tools: 

    image.png.bde566e8636a3eabf73123c376d623e9.png

     

    The offending code is this:

    image.thumb.png.48fd01e32444d6b2f2e0b0ac4ecb24f6.png

     

    Somehow if I don't register this "DrawSVGPlugin" , the program won't run. (other plugins are more "lenient"). But even though I register "DrawSVGPlugin", sometimes if gives the error "gsap is not defined". It complains but the program still runs.

     

    (I don't use webpack because it's another learning curve for me. Although I use the Javascript module feature for code reuse. Somehow I find that webpack don't play nice with my web framework so I leave webpack for the next iteration).

     

    Since I don't use webpack, I don't really have to deal with "tree shaking" issue and register is not compulsory? 

  3. Hey Forum, I have a "back to basic" question. I haven't been paying attention to this detail while practicing gsap. Now I need to ask this question. 

     

    According to gsap documents it is recommended to register plugins so that build tools don't drop them during tree shaking. 

     

    I used gsap.min.js, ScrollTrigger.min.js, Draggable.min.js, and MotionPathPlugin.min.js.

    image.thumb.png.c434120c7a903a6269135362c8f8e7e6.png

     

    So if I want to add one more library say CustomEase.min.js, I need to register this as well:

    image.thumb.png.2514fd2753cda81c6ec9c89da023508a.png

     

    Is that all I have to do?

     

    Thanks!

  4. I tried the fetch and insertAdjacentHTML approach and it worked! 

     

    Saves me time on StackOverflow on finding CORS issues on my web backend. (need tweaking in my settings.py)

     

    and most importantly the ability to dynamically inserting and removing objects on the frontend which is what I want.

     

    Thanks again Cassie. 

    • Like 2
  5. BTW Cassie, I have read briefly the link you posted. 

     

    Basically, the solution is to asynchronously fetch the image and insert the element into html page using js script. This has the effect of injecting/inlining the SVG object into DOM html page. So you don't have to use the JS's contentDocument to manipulate SVG Object. 

     

    I will try it tomorrow. Thanks for the links. 

    • Like 1
  6. 10 minutes ago, Cassie said:

    Hi there! What problem are you trying to solve by using an object? 

    It's not a very common practise. It's best to just add your SVG code inline.

     

     

    If you want to go ahead with this object approach, If you log out 'line1' in your demo, what do you get in return?
     

     

    11 minutes ago, Cassie said:

     

    If you want to go ahead with this object approach, If you log out 'line1' in your demo, what do you get in return?
     

    Thanks Cassie for your prompt reply.

     

    I change the repeat from infinity (-1) to 0  and comment out line 54 on my vscode, I will get 150 lines of error. If the repeat is -1 (infinity), the errors will go on and on.

     

    Somehow the chrome browser cannot read the SVG file because it is not inline. (it is on separate file). 

    Screen Shot 2022-12-26 at 23.14.26 (2).png

  7. Then on line 54 on my chrome browser lies the error. If you comment this line out, you get errors. Please refer to console on chrome browser.

     

    Is it possible to embed SVG in object tag and use Javascript's contentDocument to manipulate the SVG image?

     

    Thanks!

    Screen Shot 2022-12-26 at 22.17.53 (2).png

×
×
  • Create New...