SActivateFeature

This feature allows you to activate some elements depending on triggers like click, mouseover, mouseout, anchor, etc... To be explicit, you can apply this feature on a link tag with the href attribute #something, and on click, the DOM element that has the id "something" will get the "active" class applied.

Platform  
js
   â”‚    Support  
Chromium supported
Firefox supported
Safari supported
Edge supported
Since  2.0.0
   â”‚   
Olivier Bossel
Olivier Bossel
   â”‚   
beta

  Preview

Simple click activation

Click me!
I will be activated on click
 

Loading code example. Please wait...

Grouping

Tab 1 Tab 1 Tab 1
Content #1
Content #2
Content #3
 

Loading code example. Please wait...

Toggle mode

Click me!
I will be toggled on click
 

Loading code example. Please wait...

  Features

  • Take the href attribute as target

  • Allows to group some element for tabs behavior, etc...

  • Support the toggle mode

  • Support the history mode

  • Allows you to save state to restore them on page load

  • Available trigger: click, mouseover, mouseout, anchor and more to come

  • Expand the HTMLTemplateElement that stands as direct child of the dom feature itself AND of the targets

  Import

  Install

  Events

  1. s-activate.activate

    Dispatched from each targets when they are activated

  2. s-activate.unactivate

    Dispatched from each targets when they are unactivated

  Interface

  1. href
    String

    Specify the target element(s) to activate/unactivate

  2. group
    String

    Specify a group id for your element. This is used for things like tabs, etc...

  3. toggle
    false
    Boolean

    Specify if you want to be able to click on the same element to activate/unactivate it.

  4. history
    false
    Boolean

    Specify if you want to store and react to history hash changes

  5. active
    false
    Boolean

    Specify the initial state of your element

  6. activeClass
    active
    String

    Specify the class applied on target(s) when active. Default is "active"

  7. activeAttribute
    active
    String

    Specify the attribute name applied on target(s) when active.

  8. saveState
    false
    Boolean

    Specify if you want to save state in localStorage to restore it on page reload, etc...

  9. activateTimeout
    0
    Number

    Specify a timeout before actiavting the target(s)

  10. unactivateTimeout
    0
    Number

    Specify a timeout before unactivate the target(s)

  11. triggerer
    String

    Specify an element selector that will be used as the triggerer instead of this current element

  12. trigger
    ["click"]
    • click
    • mouseover
    • mouseenter
    • mouseout
    • mouseleave
    • anchor
    Array<String>

    Specify what trigger an activate/unactivate action. Can be "click", "mouseover", "mouseout" ,"anchor", "event:%eventName" "and/or" "cookie:%cookieName.%optionalDotPath". When using the "event:", the listener will be the node itself by default but you can specify the "document" like so "event:%eventName:document". When using "cookie", you can negate the assertion like so "!cookie:myCookie.myValue"

  13. unactivateOn
    Array<String>

    Specify some event(s) catched on the body tag that will unactivate the target(s)

Bugs
are not our friends...

Don't hesitate to declare an issue if something does not works as expected.

Declare my issue on Github Talk about it on Discord

The more we are,
the stronger we become.

Don't hesitate to tell some words to you friends about us. The goal is to became more and more each days to help each others...

Support us on Patreon! Share on Facebook! Make a tweet!

The more we are,
the stronger we become.

Don't be afraid to join us on Discord.

Join us on discord!

We love,
Open source!

All of our codebase can be found on Github. We hope that you may contribute to help us make our tools even better!

Discover our codebase!

Welcome on