@borngroup/born-toggle v4.0.1
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
| Property | Type | Default | Description | 
|---|---|---|---|
| trigger / triggers | Query StringNodeListHTMLElement | Element with data-toggleattribute | Provide either a query selector, a NodeList, or an HTML element to use as the Trigger. | 
| target | Query String | N/A | REQUIRED. Query selector for the target element. | 
| activeClass | String | toggle--active | Custom class name. | 
| parent | Query String | Closest parentNodeelement of theTrigger. | Selector query for the parent element. | 
| dataAttribute | String | data-toggle | Attribute name to use instead of the default 'data-toggle' to hold specific settings for a Trigger. | 
| event | String | click | Space separated list of events a Triggershould listen to. | 
| auto | Boolean/String/Number(Milliseconds) | false | If set to true, Toggle will fire immediately after document ready. If set to aNumber(milliseconds) value, Toggle will fire afterNumberhas ellapsed. If set to a breakpoint name, Toggle will fire when the breakpoint is matched. | 
| persist | Boolean | false | When true, keeps the Triggeractive after losing focus, clicking on the body, or toggling other triggers. | 
| siblingSelector | Query String | N/A | If persistis set totrue, theTriggerwill unset other triggers that match itssiblingSelectorvalue. | 
| skipSelector | Query String | N/A | If persistis set tofalse, setting aTriggerwill cause all other triggers to unset. Specify a selector to skip matching triggers. | 
| unsetOnHoverOut | Boolean | false | Unsets the Triggerwhen hovering out. | 
| unsetSelf | Boolean | true | Enable or disable the Triggerfrom unsetting itself. | 
| unsetOthers | Boolean | true | Enable or disable the Triggerfrom unsetting all other toggles (except those withpersistset toTRUE) when triggered. | 
| timeout | Integer (milliseconds) | 0 | Unsets the Triggeraftertimeoutmilliseconds. | 
Events
| Event | Arguments | Description | 
|---|---|---|
| beforeSet | trigger: the trigger HTML element. | Fires before the Toggle.set()method is triggered. Must return a truthy value, otherwise theToggle.set()execution will be halted. | 
| afterSet | trigger: the trigger HTML element. | Runs after the Toggle.set()method is triggered. | 
| beforeUnsetAll | trigger: 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 continueToggle.set()execution. | 
| afterUnset | trigger: 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.
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago