1.4.0 • Published 6 years ago

@inotom/switcher v1.4.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

@inotom/switcher

Change layer element height by handle element click.

Demo

Demo

Install

npm

npm install -D @inotom/switcher

Usage

Browser

<script src="switcher.min.js"></script>
<script>
  Switcher.switcher();
</script>

ES module

import { switcher } from '@inotom/switcher';

window.addEventListener('load', () => {
  switcher();
});

HTML

Set a same string key to data-switcher-handle and data-switcher-layer attributes.

The is-active attribute of these elements are toggled , when clicking *[data-switcher-handle] element.

The is-active attribute of these elements are removed, when clicking *[data-switcher-close] element.

<div>
  <a data-switcher-handle="SOME_KEY" href="#">Handle</a>
</div>
<div data-switcher-layer="SOME_KEY">
  Content
</div>

Overwrite changeHeight option for each elemetns, by data-switcher-change-height data attribute.

<div>
  <a data-switcher-handle="SOME_KEY" href="#">Handle</a>
</div>
<div data-switcher-layer="SOME_KEY" data-switcher-change-height="true">
  Content
</div>
<script src="switcher.min.js"></script>
<script>
  Switcher.switcher({
    changeHeight: false,
  });
</script>

Options

nametypedefaultsdescription
changeHeightBooleantrueChange layer element height value
activeAttributeStringis-activeActive handle/layer element attribute name

Example options

switcher({
  changeHeight: false,
  activeAttribute: 'is-custom-active',
});

License

MIT

Author

inotom

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.0.2

6 years ago