Skip to content

Instantly share code, notes, and snippets.

@Spepe13
Last active March 13, 2023 08:30
Show Gist options
  • Save Spepe13/2e654befeb76b67464f7b05a5fdb48b9 to your computer and use it in GitHub Desktop.
Save Spepe13/2e654befeb76b67464f7b05a5fdb48b9 to your computer and use it in GitHub Desktop.
[GSAP to magento 2] #Magento #GSAP

Add Greensock Gsap library to Magento 2

With cdn

Add below code to the file that you want to develop the animations.main.js or another perhaps animations.js

require([
	'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.1/gsap.min.js',
    'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.1/ScrollTrigger.min.js' 
    ], function (GreenSocks3, St) {
    const gsap = GreenSocks3.gsap;
    const ScrollTrigger = St.ScrollTrigger;

    gsap.registerPlugin(ScrollTrigger);

});

With file for membership plugins

  1. Upload min.js file to app\design\[Theme]\[Theme-name]\web\js
  2. Add below code to require-config.js
    packages: [
        {
            name: 'MorphSVGPlugin',
            location: 'path/MorphSVGPlugin.min.js min.js',
            main: 'MorphSVGPlugin.min.js'
        }
    ],
require([
	'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.1/gsap.min.js'
	'MorphSVGPlugin', ], 
    function (GreenSocks3, Mrph) {
    const gsap = GreenSocks3.gsap;
    const MorphSVGPlugin = Mrph.MorphSVGPlugin;

    gsap.registerPlugin(MorphSVGPlugin);

});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment