1.0.1 • Published 12 months ago

c-switcher-js v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

C-Switcher JS

c-switcher allows you to define various modes as attributes and provides functions to easily switch between them.

Table of contents

Quick start

installing

Using npm:

$ npm install c-switcher-js

Once the package is installed, you can import the library using import or require approach:

import {CSW} from 'c-switcher-js';

cdn

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/c-switcher-js@1.0.0/dist/cswitcher.min.js"></script>

Using unpkg CDN:

<script src="https://unpkg.com/c-switcher-js@1.0.0/dist/cswitcher.min.js"></script>

Examples

Switching between custom modes

<nav class="navbar" id="navbar" data-csm-floating="bg-white" data-csm-fixed="bg-transparent"></nav>
CSW.switch({
    element: document.getElementById('navbar'),
    mode: 'fixed', // Switching to 'fixed' mode
    switch_children: false // Enables switching for navbar children elements which have data-csm attributes.
})

After calling switch:

<nav class="navbar bg-transparent" id="navbar" data-csm-floating="bg-white" data-csm-fixed="bg-transparent"></nav>

check out the full example in tests/sticky-header directory

Documents

switch

switching between modes

CSW.switch({
    element: HTMLElement,
    mode: string,
    switch_children: boolean
})
1.0.1

12 months ago

1.0.0

12 months ago