Socket
Book a DemoInstallSign in
Socket

@borngroup/born-toggle

Package Overview
Dependencies
Maintainers
4
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@borngroup/born-toggle

Toggle DOM elements' state and manage content display, interface changes, and more.

latest
Source
npmnpm
Version
4.0.1
Version published
Maintainers
4
Created
Source

Description

Adds the ability to toggle a class when an event is triggered, can be setup to look for a data-toggle attribute to hold the configurations for the trigger. Does not use jQuery.

Options

PropertyTypeDefaultDescription
trigger / triggersQuery String NodeList HTMLElementElement with data-toggle attributeProvide either a query selector, a NodeList, or an HTML element to use as the Trigger.
targetQuery StringN/AREQUIRED. Query selector for the target element.
activeClassStringtoggle--activeCustom class name.
parentQuery StringClosest parentNode element of the Trigger.Selector query for the parent element.
dataAttributeStringdata-toggleAttribute name to use instead of the default 'data-toggle' to hold specific settings for a Trigger.
eventStringclickSpace separated list of events a Trigger should listen to.
autoBoolean/String/Number (Milliseconds)falseIf set to true, Toggle will fire immediately after document ready. If set to a Number (milliseconds) value, Toggle will fire after Number has ellapsed. If set to a breakpoint name, Toggle will fire when the breakpoint is matched.
persistBooleanfalseWhen true, keeps the Trigger active after losing focus, clicking on the body, or toggling other triggers.
siblingSelectorQuery StringN/AIf persist is set to true, the Trigger will unset other triggers that match its siblingSelector value.
skipSelectorQuery StringN/AIf persist is set to false, setting a Trigger will cause all other triggers to unset. Specify a selector to skip matching triggers.
unsetOnHoverOutBooleanfalseUnsets the Trigger when hovering out.
unsetSelfBooleantrueEnable or disable the Trigger from unsetting itself.
unsetOthersBooleantrueEnable or disable the Trigger from unsetting all other toggles (except those with persist set to TRUE) when triggered.
timeoutInteger (milliseconds)0Unsets the Trigger after timeout milliseconds.

Events

EventArgumentsDescription
beforeSettrigger: the trigger HTML element.Fires before the Toggle.set() method is triggered. Must return a truthy value, otherwise the Toggle.set() execution will be halted.
afterSettrigger: the trigger HTML element.Runs after the Toggle.set() method is triggered.
beforeUnsetAlltrigger: the trigger HTML element.Runs inside the Toggle.set() method before unsetting all toggles to their default state. Return false on this callback to prevent unsetting other toggles and continue Toggle.set() execution.
afterUnsettrigger: the trigger HTML element.Runs after the Toggle.unset() method is triggered.

Methods

toggle(): Set or unsets the toggle.

set(): Sets the toggle.

unset(): Unsets the toggle.

Extras

[data-toggle-close]: An element with this attribute inside the toggle's target or parent will act as a close action for the active toggle.

Keywords

element

FAQs

Package last updated on 10 Mar 2021

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