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

frog-troll

v1.0.1

Published

A frog entered your screen hunting down your mouse pointer

Downloads

11

Readme

A frog entered your screen hunting down your mouse pointer...

Frog Troll

A personal trigonometic experiment resulted to this hideous creature.

By adding it to your app, you can append to any element the FrogTroll component.
This will add a frog to your screen that jumps arround it's parent component boundaries when the mouse pointers comes uncomfortably close to it.
It turns it's head staring always to the mouse pointer's direction and if the pointer stays still for some time (defined by you), the frog opens its mouth warning about the coming tongue hit.
If the mouse pointer doesn't get the warning, it will meet the inevitable end as the frog will launch its tongue and make it dissapear from the screen.

Usage

Requirements:

You just need a React app. The oldest working version of React is 16.3 where useEffect was introduced.

Installation and Integration:

To install the Frog Troll run npm i --save frog-troll

To integrate to your app add import {FrogTroll} from 'frog-troll' at the top of the component you want to have it.
Then inside the component where you want the Frog Troll to live add <FrogTroll options={yourOptions}/>.

|Field|Type|Default Value|Description| |-----|----|-------|-----------| |fontSize|Integer|16 if screen width  <  1024px19 if screen width >= 1024px20 if screen width >= 1280px|Defines the font size used in the parent component| |size|Integer|5|Defines the size of the frog troll in the units given| |units|String|'em'|Can be 'em' or 'px', defines the units used for the size of the frog troll| |navbarHeight|Integer|0|The size in pixels of the navbar if there is one*| |startingPosition|Object|{ x:0, y:0 }|The starting position inside the parent element in the units given in units, giving only positive values. With { x:0, y:0 } being the top left corner of the parent element| |timeToOpenMouth|Integer|2000|Time in milliseconds from the moment that mouse pointer stops moving to the moment frog troll opens its mouth| |timeToAttack|Integer|1000|Time in milliseconds from the moment that frog troll opens its mouth to the moment it launches its tongue|

Geometry

The frog troll feels uncomfortable when the pointer tries to touch it so it jumps to a random (x,y) point within the boundaries of the parent element.
Most of the magic happens in the jump() function where the orbit of the frog troll's jump is calculated.
The un-natural convention has been made that the jump follows always a perfect circle and based on this theory, we have eight cases of jumps. Considering that the starting position of the frog troll is (0,0), depending on the spot of the final position the eight cases are shown below.

  • In cases a and h, the center of the frog troll's orbit circle will be on Xaxis (Case 1).
  • In cases f and c, the center of the frog troll's orbit circle will be on Yaxis (Case 4).
  • In cases g and b, the center of the frog troll's orbit circle will be on the line passing from final positionpoint and being parallel to Yaxis (Case 3).
  • In cases e and d, the center of the frog troll's orbit circle will be on the line passing from final positionpoint and being parallel to Xaxis (Case 2).