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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-projectile-motion

v1.0.1

Published

抛物运动组件 / projectile motion component

Readme

English | 简体中文

✨ Effect

👀️ Introduce

  • This component is a projectile motion component. Theoretically, the motion trajectory can be from any point on the page to any other point.
  • projectile starts from the center position of the incoming startingDom and ends at the center position of endingDom

🔨 Install

npm install react-projectile-motion

❗Requirements

pubsub-js version 1.x and above react version 16.8.0 and above react-dom version 16.8.0 and above

👻 Demo

https://zhangxunjia.github.io/react-projectile-motion-demo/

✍️ Usage

This component exposes two high-level components for users to use: withProjectileMotionStarter and withProjectileMotion

import { withProjectileMotionStarter, withProjectileMotion } from 'react-projectile-motion';
  • High-order components withProjectileMotionStarter:

The subcomponent obtains the function triggerProjectileMotion(subscription, startingDom) to trigger projectile motion

triggerProjectileMotion(subscription, startingDom):

| parameter | description | type | default value | | ------------ | ------------------------------------------------------------------------- | ----------- | ------ | | subscription | (required)This is the pubsub subscription name. The parameters passed here need to be consistent with props.subscription in withProjectileMotion | string | | | startingDom | (required)DOM of starting position of projectile motion | object(dom) | |

  • High-order components withProjectileMotion:

subcomponent get function setProjectileMotionPorps(props) ,Please note that props are objects, The properties of this object are used to set the properties of the projectile motion.

setProjectileMotionPorps(props) :

| parameter | description | type | default value | | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ---------- | | props.subscription | (required)This is the pubsub subscription name. The parameters passed here need to be consistent with subscription in withProjectileMotionStarter | string | | | props.endingDom | (required)DOM of ending position of projectile motion | object(dom) | | | props.muiltipleProjectile | Whether multiple projectiles are allowed | boolean | true | | props.projectile | projectile(If you want to add className, you need to write the style globally) | ReactNode | | | props.duration | The duration of the projectile motion (Unit: second) | number | 1 | | props.zIndex | The zIndex of projectile | number | 2147483647 | | props.needEndingDomAnimation | Does endingDom need to animate after being hit by a projectile | boolean | true | | props.projectileMovmentEnd | Projectile motion animation end callback | function | | | props.endingDomAnimationEnd | endingDom animation end callback | function | | | props.endingDomAnimationDuration | endingDom animation duration after being hit by a projectile (Unit: second) | number | | | props.endingDomAnimationName | The name of the animation after endingDom is hit by a projectile (animation needs to be global) | string | | | props.additionalTransformValueInAnimate | Supplementary animation transform value, after passing in this value, a new class name will be generated. This class will integrate the other frames except the last frame of the keyframe corresponding to endingDomAnimationName to form a new class, which can then be used by endingDom. You can set values such as rotate scale translate skew. If you set multiple values, please separate them with spaces. (Graphical details) | string | | | props.wrapClassName | The class name of the outer container of the projectile | string | | | props.isInitialYAxisReverse | Is the initial velocity of projectile motion in the opposite direction of the y-axis | boolean | true | | props.projectileTransition | This is the transition attribute of the projectile. If this attribute is passed in, the duration and isInitialYAxisReverse will be invalid. | string | |

⌨️Example:

Starting point of projectile motion:

// Starting point of projectile motion
import React, { useRef } from 'react';
import { withProjectileMotionStarter } from 'react-projectile-motion';

const StartCom = (props) => {
    const startingDom = useRef();
    return (
        <div
            ref={startingDom} 
            onClick={() => {
              props.triggerProjectileMotion(
                {/* This subscriptionName should correspond to the subscriptionName in the ending point of props.setProjectileMotionPorps */}
                'subscriptionName', 
                startingDom.current
              )
            }}
        >
            +
        </div>
    );
};

// Use withProjectileMotionStarter
export default withProjectileMotionStarter(StartCom);

Ending point of projectile motion:

// Ending point of projectile motion
import React, { useRef, useEffect } from 'react';
import { withProjectileMotion } from 'react-projectile-motion';

const EndCom = (props) => {
    const endingDom = useRef();

    useEffect(() => {
        // Note: the parameter received is an object
        props.setProjectileMotionPorps({
            // This subscription should correspond to the subscriptionName in the starting end of props.triggerProjectileMotion.
            subscription: 'subscriptionName',
            endingDom: endingDom.current,
        });
    }, []);

    return (
        <img
            ref={endingDom}
            src={require('./shopCar.png')}
            alt="shopcar"
        />
    );
};

// Use withProjectileMotion
export default withProjectileMotion(EndCom);