Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
stimulus-use
Advanced tools
A collection of composable behaviors for your Stimulus Controllers
npm
npm i stimulus-use
yarn
yarn add stimulus-use
We got you covered 👉 stimulus-use.github.io/stimulus-use
This set of mixins is built around the Observer APIs
and custom events to enhance your controllers with new behaviors.
Mixin | Description | NEW Callbacks |
---|---|---|
useClickOutside | Tracks the clicks outside of the element and adds a new lifecyle callback clickOutside. | clickOutside |
useHover | Tracks the user's mouse movements over an element and adds mouseEnter and mouseLeave callbacks to your controller. | mouseEnter mouseLeave |
useIdle | Tracks if the user is idle on your page and adds away and back callbacks to your controller. | away back |
useIntersection | Tracks the element's intersection and adds appear, disappear callbacks to your controller. | appear disappear |
useMutation | Tracks mutations on an element, its attributes and/or subtree. Adds a mutate callback to your controller. | mutate |
useResize | Tracks the element's size and adds a new lifecyle callback resize. | resize |
useVisibility | Tracks the page visibility and adds visible, invisible callbacks to your controller. | visible invisible |
useWindowResize | Tracks the size of the window object and adds a new lifecyle callback windowResize. | windowResize |
A set of mixin to optimize performances.
Mixin | Description |
---|---|
useDebounce | Adds the ability to specify an array "debounces" of functions to debounce. |
useMemo | Memoize expensive getters by mixing in useMemo and adding a static memos array. |
useThrottle | Adds the ability to specify an array "throttles" of functions to throttle. |
A set of mixin and controllers to build animations.
Mixin | Description |
---|---|
useTransition | Mixin or controller to apply classes to various stages of an element's transition. |
Mixin | Description |
---|---|
useApplication, ApplicationController | supercharged controller for your application. |
useDispatch | Adds a dispatch helper function to emit custom events. Useful to communicate between different controllers. |
useMeta | Adds getters to easily access meta values. |
Stimulus-use can be used in two ways: composing with mixins or extending built-in controllers
Composing with mixins
This is the prefered approach as it bring the most flexibility. Simply import a mixin and apply it in the connect
or initialize
to adds new behaviors to you controller. You can combine several mixins within the same controller.
import { Controller } from 'stimulus'
import { useIntersection, useResize } from 'stimulus-use'
export default class extends Controller {
connect() {
useIntersection(this)
useResize(this)
}
appear(entry) {
// triggered when the element appears within the viewport
}
resize({ height, width }) {
// trigered when the element is resized
}
}
Extending built-in controllers
You can create your Stimulus controller from a pre-built Stimulus-use controller which offers the new behavior you're looking for. This method works perfectly when you only need a single behavior for your controller.
import { IntersectionController } from 'stimulus-use'
export default class extends IntersectionController {
appear(entry) {
// triggered when the element appears within the viewport
}
}
Made with :heart: by @adrienpoly and all these wonderful contributors (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Continuous integration and cross browser testing is generously provided Sauce Labs.
FAQs
A collection of standard controllers and utilities for Stimulus
The npm package stimulus-use receives a total of 72,168 weekly downloads. As such, stimulus-use popularity was classified as popular.
We found that stimulus-use demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.