4.0.1 • Published 4 years ago

@borngroup/born-toggle v4.0.1

Weekly downloads
130
License
ISC
Repository
github
Last release
4 years ago

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.

4.0.1

4 years ago

4.0.0

4 years ago

3.7.0

5 years ago

3.6.0

5 years ago

3.5.11

5 years ago

3.5.10

5 years ago

3.5.9

6 years ago

3.5.8

6 years ago

3.5.7

6 years ago

3.5.6

6 years ago

3.5.5

6 years ago

3.5.4

6 years ago

3.5.3

6 years ago

3.5.2

6 years ago

3.5.1

6 years ago

3.5.0

6 years ago

3.4.1

6 years ago

3.4.0

6 years ago

3.3.1

6 years ago

3.3.0

6 years ago

3.2.1

6 years ago

3.2.0

7 years ago

3.1.3

7 years ago

3.1.2

7 years ago

3.1.1

7 years ago

3.1.0

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago