npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zilahir/gsap-tools

v1.0.14

Published

A simple tool to debug GSAP animations

Downloads

2

Readme

logo banner about

GsapTools

npm version

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.

Installation

yarn add gsap-tools

Features

  • Play/pause
  • Loop
  • Rewind
  • In/out markers
  • Timescale
  • Draggable UI
  • Updated animations
  • Timeline details

How to use it

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();
}

Examples

  • The GsapTools’ website use the tool itself, you can see it in action here: AppLayout.js and Hero.js.
  • There is also more examples with Tween and Timeline also here.

Shortcuts

  • space Play/pause
  • L Toggle loop
  • H Toggle UI
  • E Expand Timeline
  • R Reset in/out markers
  • Rewind
  • Speed up
  • Slow down

References

<GsapTools /> component

  • isVisible (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() function

  • Timeline/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.

But, why?

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.

You to the rescue

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.

Development

In source folder:

npm run watch
npm link

In project:

npm link gsap-tools