Socket
Book a DemoInstallSign in
Socket

@antonio-goncalves/hover-on-scroll

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antonio-goncalves/hover-on-scroll

![Sample video](static/sample.gif)

1.0.0
latest
npmnpm
Version published
Maintainers
1
Created
Source

HoverOnScroll

Sample video

HoverOnScroll is a JavaScript library that adds support to hover effects while scrolling the window or a container, it was developed to overcome the limitation of browsers to apply the css :hover effect during scroll

Sample

The sample available on the dev folder could be run following those steps

npm install
npm run start

Properties

import HoverOnScroll from "@antonio-goncalves/hover-on-scroll";

const hoverOnScroll = new HoverOnScroll([elementToHover1,elementToHover2],options)

function destroy(){
    hoverOnScroll.destroy()
}

ElementToHover

First parameter of HoverOnScroll constructor

NameTypeis OptionalDescription
elementClassstringnoClass of the element where the "hoverClass" must be applied when hovering
hoverClassstringnoClass which will be applied to the element to enable the hover effect

Options

Second parameter of HoverOnScroll constructor, this parameter is optional

NameTypeis OptionalDescription
mouseOffsetnumberyesMinimum Y value to be considered when listening the mouse position, this could be useful to allow the hover effect behind navbars
initialMousePosition{x:Number, y:Number}yesInitial mouse position
scrollingElementsElement[] (DOM)yesElements where the onScroll event will be attached, useful for containers with scroll
touchBehaviourTouchBehaviouryesOptions specific for touch devices

TouchBehaviour

Those options are only relevant for touch devices.

NameTypeis OptionalDescription
scrollWhenTouchbooleanyesSet to true, to scroll to the element on touch
offsetWhenScrollNumberyesvertical offset for the behaviour described on the previous option, is useful to place the content below a navbar

FAQs

Package last updated on 24 May 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.