Hello,
I just downloaded the current version of gsap zip package. I am a Club GreenSock member and the package includes all the bonus plugins.
In my project I want to use MorphSVGPlugin to do some SVG morphing.
My project setup is based on npm/webpack/react.
Normally to use the basic gsap API I just run :
npm install --save gsap
This works fine without any problems.
However as being a part of the paid version of greensock, MorphSVGPlugin is not included in that npm package.
So I decided to just copy/paste MorphSVGPlugin.js from bonus-files-for-npm-users to node_modules/gsap.
Then in my react component I just import MorphSVGPlugin. Unfortunately It doesn't seem to work. Here is the code of my very simple react component:
import React, { Component } from 'react';
import { TweenMax, MorphSVGPlugin, Expo } from 'gsap';
class MainButton extends Component {
componentDidMount() {
TweenMax.to(this.line1, 4, {morphSVG: {shape:this.diag1, shapeIndex:[0]}, ease:Expo.easeOut});
}
render() {
return(
<div className="mainButton">
<div className="linesGroup">
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="30" height="24.04" viewBox="0 0 30 24.04">
<title>Shapes</title>
<path id="line1" ref={path => { this.line1 = path; }} d="M30,2V6H0V2Z"/>
<path id="diag1" ref={path => { this.diag1 = path; }} d="M27,21.21,24.21,24,3,2.83,5.83,0Z" fill="#fff"/>
</svg>
</div>
</div>
)
}
}
export default MainButton;
When I run this in the browser I receive the following message in the Cosnole:
invalid morphSVG tween value: [object Object]
So I am not sure if this is a configuration problem with the packages or maybe It is an incorrect usage of MorphSVGPlugin.
I tested my SVG morphing in Codepen and it works just fine.
So I will be really grateful if someone can explain me how to use the bonus plugins (and particularly MorphSVGPlugin) in a npm/webpack/react project.
Thank you in advance.