
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-control-js
Advanced tools
ControlJS is a react library allowing you to create animations on components with possibility to trigger them on scroll.
Install ControlJS with npm
npm install react-control-js
import Control from 'react-control-js'
function App() {
return <Control element={<p>Hello World!</p>} x={20} onScroll={true} />
}
Passed as a property to the Control component. Defines element that would be rendered to the DOM and controlled with animations.
<Control element={<div>Hello World</div>} />
| Parameter | Type | Description |
|---|---|---|
element | JSX.Element | Required. Animated element. |
Defines duration of the animation. Takes a number value which is compiled to ms units.
<Control element={<div>Hello World</div>} duration={200} />
| Parameter | Type | Description |
|---|---|---|
duration | number | Optional. Duration of the animation. |
Defines delay of the animation. Takes a number value which is compiled to ms units.
<Control element={<div>Hello World</div>} delay={200} />
| Parameter | Type | Description |
|---|---|---|
delay | number | Optional. Delay of the animation. |
Provides easing for animation and has a default value of cubic-bezier(0, 0, 1, 1). You can pass it four values: ease, ease-in, ease-out, ease-in-out.
<Control element={<div>Hello World</div>} ease='ease-out' />
| Parameter | Type | Description |
|---|---|---|
ease | string | Optional. Easing of the animation. |
Used to animate opacity, if it exists on Control component it will transition element's opacity from the value of 0 to the one passed in the property.
<Control element={<div>Hello World</div>} opacity={0.42} />
| Parameter | Type | Description |
|---|---|---|
opacity | number | Optional. Opacity element would be transformed to. |
X and y are properties passed to the Control component which define the position that controlled element would be transformed to relative to its position in DOM.
You can either pass a number which will work as px unit or a string if you'd need something like percentage value.
<Control element={<div>Hello World</div>} x={-10} />
<Control element={<div>Hello World</div>} x={20} y={'40%'} />
| Parameter | Type | Description |
|---|---|---|
x, y | number / string | Optional. Translating element. |
Rotate defines if controlled element should be rotated. You can pass it a number which will act as a deg unit.
<Control element={<div>Hello World</div>} rotate={90} />
| Parameter | Type | Description |
|---|---|---|
rotate | number | Optional. Rotation of the element. |
Changes background color of animated element.
<Control element={<div>Hello World</div>} backgroundColor={'blue'} />
| Parameter | Type | Description |
|---|---|---|
backgroundColor | string | Optional. Background of the element. |
Changes text color of animated element.
<Control element={<div>Hello World</div>} color='blue' />
| Parameter | Type | Description |
|---|---|---|
color | string | Optional. Text color of the element. |
Boolean value which tells Control if the animation should occur as animated component enters the viewport or directly after its render.
<Control element={<div>Hello World</div>} onScroll={true} />
| Parameter | Type | Description |
|---|---|---|
onScroll | boolean | Optional. Enter viewport animation. |
Related to onScroll, passed as a number which defines at what point of viewport, which element enters, should the animation occur.
<Control element={<div>Hello World</div>} onScroll={true} viewPort={0.4} />
| Parameter | Type | Description |
|---|---|---|
onScroll | boolean | Optional. Enter viewport animation. |
You have an access to Controller component which can wrap multiple Control components giving each of them passed properties. For example you can provide onScroll property only once with respect to all components. Notice you can pass other viewPort values to each of wrapped components and every of them would respect its own value.
Using Controller is recommended if you'd like to perform actions on a group of elements.
import Control, { Controller } from 'react-control-js'
function App() {
return (
<Controller>
<Control element={<p>Hello World!</p>} opacity={1} viewPort={0.2} />
<Control element={<p>Hello World!</p>} opacity={1} viewPort={0.6} />
</Controller>
)
}
| Parameter | Type | Description |
|---|---|---|
Controller | Component | Perform actions on multiple elements |
You can pass className property to Controller component which acts exactly as normal className React property.
import Control, { Controller } from 'react-control-js'
function App() {
return (
<Controller className="flex flex-col">
<Control element={<p>Hello World!</p>} opacity={1} viewPort={0.2} />
<Control element={<p>Hello World!</p>} opacity={1} viewPort={0.6} />
</Controller>
)
}
Stagger is a property for Controller component which defines delay for every component in a group. For example if you pass it a value of 100, each subsequent component will start its animation every 100ms.
import Control, { Controller } from 'react-control-js'
function App() {
return (
<Controller stagger={100}>
<Control element={<p>Hello World!</p>} opacity={1} viewPort={0.2} />
<Control element={<p>Hello World!</p>} opacity={1} viewPort={0.6} />
</Controller>
)
}
You can pass every property that Control component has available except element to the Controller component and it will spread it around all Controls in a wrapped group.
import Control, { Controller } from 'react-control-js'
function App() {
return (
<Controller x={20} y={'-40%'} opacity={1} rotate={180} stagger={300}>
<Control element={<p>Hello World!</p>} />
<Control element={<p>Hello World!</p>} />
</Controller>
)
}
If you'd like to position controlled element absolutely, don't put that style on the element but rather wrap the whole Control component in a div and put the style on it.
function WrongAbsolute() {
return <Control element={<p style={{ position: absolute }}>Hello World!</p>} />
}
function GoodAbsolute() {
return (
<div style={{ position: absolute }}>
<Control element={<p>Hello World!</p>} />
</div>
)
}
FAQs
React library used to animate components
The npm package react-control-js receives a total of 16 weekly downloads. As such, react-control-js popularity was classified as not popular.
We found that react-control-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.