![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
gsap-tools
Advanced tools
A simple tool to debug GSAP animations
Managing and debugging Tween and Timeline in GSAP is a hassle, even with the official dev tools. So we created GsapTools, a tool for React1, that makes it all so much easier. Scroll down to know more and go take a look at the website.
—
1. GsapTools only works with React for the moment, but we plan to make it works on other popular front-end library in the future.
yarn add gsap-tools
First, add GsapTools component globally to your application. You only need to do this once.
import GsapTools from 'gsap-tools';
<GsapTools />
Next, register your GSAP animation to be controlled with GsapTools.
Define an id on the Timeline constructor or on the Tween vars object, call the add function to register the timeline, and create a reference to the add function to remove it when the component is unmounted.
import { add } from 'gsap-tools';
componentDidMount() {
this.t = new TimelineLite({ id: 'myTimeline' });
this.disposer = add(this.t);
}
componentWillUnmount() {
this.disposer();
}
That’s the simpler version. Here is an alternative setup.
import { add } from 'gsap-tools';
/*
* With Timeline
*/
componentDidMount() {
// You can define an id on the Timeline's constructor
this.timeline = new TimelineLite({ id: 'myTimeline' });
// Or you can also define an id on the add function itself
this.disposer = add(this.timeline, 'myTimeline');
// Or it will generate an id if you don't specify any
this.disposer = add(this.timeline);
}
componentWillUnmount() {
// Remove the Timeline by using the disposer reference
this.disposer();
}
/*
* With Tween
*/
componentDidMount() {
// You can define an id within the vars object
this.tween = TweenLite.to(this.el, 1, { x: 50, id: 'myTween' });
// Or you can define an id on the add function itself
this.disposer = add(this.tween, 'myTween');
// Or it will generate an id if you don't specify any
this.disposer = add(this.tween);
}
componentWillUnmount() {
// Remove the Tween by using the disposer reference
this.disposer();
}
<GsapTools />
componentisVisible (default = false) Show GsapTools by default. Or not. It’s a free country.
isFixed (default = true) With the draggable feature, GsapTools defaults to position: fixed
on top of everything. But you can pass false
to this prop to position the tool however you like.
onClick (default = undefined) The tool comes with a built-in button to toggle the component.
But if you decide to have your own button to handle this, just pass an onClick
prop to the component
and it will override the built-in function. This is useful if you have a whole dev tools package
and already have a way to enable specific tools.
add()
functionTimeline/Tween (required) The first argument to pass is the animation object. It can be either Tween or Timeline instances.
id (optional) Instead of passing the id to the timeline method constructor you can pass it on the add()
function itself.
We ❤️ GSAP. We ❤️ it so much that we use GSAP for animations on almost all of our projects.
But one thing were struggling with for a long time was debugging big timelines. Most of the time we reload, reload, reload, reload, reload, reload, reload, reload. You get where this is going.
Recently GSAP introduced their dev tools. We tried them but found they didn’t really fit our needs: Setting the tools up with webpack, a real mess; when unmounting a component, removing its timeline after being registered is not possible; and finally, animations are only registered if they are played 2 seconds after the page is loaded, which is a problem if we have an animation playing based on user interaction, or when a waypoint is triggered.
That’s why we decided to make our own tool to address these issues.
If you noticed any issues, have any ideas, or want to open pull requests, just do it. And if you want to know more about who we are and what we do, here’s a link for that.
In source folder:
npm run watch
npm link
In project:
npm link gsap-tools
FAQs
A simple tool to debug GSAP animations
The npm package gsap-tools receives a total of 12 weekly downloads. As such, gsap-tools popularity was classified as not popular.
We found that gsap-tools demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.