![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
scroll-sensor
Advanced tools
Scroll Sensor simulate scroll bar on a not scrollable dom.It has features of mouse wheel, mouse down move, touch move and scroll inertia.
Scroll Sensor simulate scroll bar on a not scrollable dom.It has features of mouse wheel, mouse down move, touch move and scroll inertia.
You can know user's scroll behavior by listening events.It is very useful in canvas animation and other field.
Here is a Demo.
Scroll Sensor can be installed by npm or yarn.It can be imported by ES6 import grammar,commonJs grammar or including by script tag.
npm install scroll-sensor
import {ScrollSensor} from 'scroll-sensor';
<script src="https://unpkg.com/scroll-sensor/dist/scroll-sensor.min.js"><script>
const scrollSensor = new ScrollSensor({
element: document.querySelector('.some-class'),
});
scrollSensor.on('scroll', event => {
// do some thing by event.scrollTop, event.scrollLeft, event.scrollX, event.scrollY
})
Main class of scroll-sensor.Call it by "new" to create a scroll-sensor instance.
<HTMLElement>
The dom element to create scroll-sensor instance.User's scroll behavior on it will be listened.<OptionsInterface>
Options.See detail of options below.It is optional.<number>
Set the initial [scroll top]<number>
Set the initial scroll left.<number>
These two properties get or set total scroll distance vertically and horizontally.
They like Element.scrollTop and Element.scrollLeft
Reset the options.
<OptionsInterface>
Options.It is optional.Release the resources and no longer emit event.
It should be called when you no longer use this scroll sensor instance.
You can add or remove event listener by methods in "events" lib, such as on(), off(), etc.
This event is emitted when user scroll on the element or inertia scroll.
A event object will pass to the event listener.It has for properties.
<number>
Current scrollSensor.scrollTop/scrollSensor.scrollLeft value.<number>
Pixel distance of this scroll on x-axis and y-axis.Options of Scroll Sensor.It passed by constructor or setOptions method.
<boolean>
true
Whether the mouse wheel/mouse down move/touch move is enable.If it set to false, mouse wheel/mouse down move/touch move on the element will be no effect.
<number>
Scroll speed when mouse wheeling/mouse down moving/touch moving on the x-axis and y-axis.It will multiply the actual moving pixel distance.
If it set to 1, scroll distance will same as the actual moving distance.
<number>
The inertia deceleration after mouse down moving/touch moving.It's unit is pixels/s^2.
Scroll Sensor will auto calculate the end speed of mouse down moving/touch moving.When user end the move, it will keep scroll some distance and slow down with a deceleration until to 0.
If it set to Infinity, there will no inertia.It is suggests set to about 5000.
<number>
Scroll Sensor will auto calculate the end speed of mouse down moving/touch moving used to inertia move.If the end speed greater than this option, the end speed will set to this option.
<number>
The min/max value of scrollTop/scrollLeft.The scrollTop/scrollLeft value can't scroll out of this range.
FAQs
Scroll Sensor simulate scroll bar on a not scrollable dom.It has features of mouse wheel, mouse down move, touch move and scroll inertia.
The npm package scroll-sensor receives a total of 0 weekly downloads. As such, scroll-sensor popularity was classified as not popular.
We found that scroll-sensor 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.