mercredi 7 octobre 2020

How to import from JS and not put in the script

I implemented these 4 scripts in my head in ruby ​​on rails:

<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.0.1/dist/gsap.min.js"></script>

So, ScroolMagic, animation gsap, debug indicators and gspa. But in Ruby on Rails it's better to create a separated folder/file to protect and seperate your js code.

So for gsap it's ok. I did this inside my js.file in my javascript folder:

    import { gsap } from "gsap";

But for the 2 others (debug.addIndicators is not a priority) i don't know how to do, i tried a lots of possibilities like:

 import { ScrollMagicPluginGsap } from "scrollmagic-plugin-gsap";
    import ScrollMagic from 'ScrollMagic';
    import * as ScrollMagic from 'ScrollMagic';

and more... can someone help me please?

Aucun commentaire:

Enregistrer un commentaire