Socket
Socket
Sign inDemoInstall

@switch-company/sticky-focus

Package Overview
Dependencies
0
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @switch-company/sticky-focus

Ensure focused element is not under a sticky element


Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
2
Install size
15.6 kB
Created
Weekly downloads
 

Readme

Source

Switch - sticky focus

Ensure focused element is not under a sticky bar


This plugin is written in ES2015 and available either in uncompiled form in the /lib folder or compiled for ES5 in the /dist folder. If your project uses babel with Webpack or Rollup, you should change the exclusion so this plugin gets compiled or force Webpack or Rollup to fetch the compiled version by using the main entry of the package.json file instead of the module entry.

// .babelrc file or configuration within webpack or rollup
{
  "plugins": [...],
  "exclude": "node_modules/!(@switch-company)/**",
}

Installation

$ npm install @switch-company/sticky-focus

Usage

import stickyFocus from '@switch-company/sticky-focus';

const sticky = new stickyFocus({
  elements,
  padding
});

Parameters

Mandatory parameter

NameTypeDescription
elementsArrayArray of HTMLElement that are the sticky elements

Optional parameter

NameTypeDescription
paddingNumberNumber of pixels to add between the bottom of the sticky element and the top of the focused element

Methods

NameDescription
refresh()Force recalculate the size of the sticky element. Handy if the size changes between breakpoints
restart( elements )Restart listening to the focus events. Pass element if you want to restart the plugin with different elements
stop()Stop listening to the focus events
update( elements )Change the array of elements

Keywords

FAQs

Last updated on 16 Jul 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc