Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@springernature/global-expander

Package Overview
Dependencies
Maintainers
11
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@springernature/global-expander

Frontend package for expanding a target when clicking a toggle

  • 0.3.2
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by42.01%
Maintainers
11
Weekly downloads
 
Created
Source

Global Expander

Click a trigger element to toggle the display of a unique target element.

Usage

import {expander} from 'global-expander/js';

expander(options);
<button id="button1" data-expander data-expander-target="#target1">Expander 1</button>
<div id="target1">Target 1</div>

JavaScript

For more flexibility you can use the Expander class directly:

const trigger = document.querySelector('.my-trigger');
const target = document.querySelector('.my-target');

const myExpander = new Expander(trigger, target, options);

myExpander.init();

Options

OptionDefault ValueTypeDescription
TARGET_HIDE_CLASS'u-js-hide'StringHTML class to be toggled on the target
TRIGGER_OPEN_CLASS-StringHTML class to be toggled to the trigger
TRIGGER_OPEN_LABEL-StringText to set on the trigger when open
CLOSE_ON_CLICKOFFtrueBooleanCloses when you click outside of the target
AUTOFOCUSfalseBooleanSet focus on the first tabbable element inside the target (will highlight text if appropriate, e.g. input with value)

The data attribute options are the same, but are lowercase and hyphenated (and strings where the option is a boolean):

  • data-expander-target-hide-class
  • data-expander-trigger-open-class
  • data-expander-trigger-open-label
  • data-expander-close-on-clickoff
  • data-expander-autofocus

Note: data attribute options will take precedence over any options set during initialisation.

Polyfills / Babel plugins required

  • plugin-transform-object-assign

FAQs

Package last updated on 06 Mar 2020

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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc