PMX Button:
Intro
Module to add toggling behavior to a button
Getting Started
;;; const emitter = ;const btn = ;const btnNode = document;const targetEl = document;const config = el: btnNode // Required targetEl // Required { // Technically optional but without this the component is pretty useless const isActive = btnNodeclassList; if isActive btnNodeclassList; btnNodeclassList; else btnNodeclassList; btnNodeclassList; } { // Optional. Function that is gonna be executed when the 'deactivate' event // specified bellow is triggered btnNodeclassList; btnNodeclassList; } { // Optional. Function that is gonna be executed when the 'activate' event // specified bellow is triggered btnNodeclassList; btnNodeclassList; } events: // Optional 'activate' 'pmx:activate' // the button will get activated when this event (along the // targetEl) gets triggered 'deactivate' 'pmx:deactivate' // the button will get deactivated when this event (along // the targetEl) gets triggered css: // Optional classes: 'activated' 'is-active' // class to be applied to the button when activated 'deactivated' 'is-inactive' // class to be applied to the button when deactivated ;const shared = emitter;btn;
How to use
Setup
The module is exported as an UMD module so it can be used with AMD, CommonJS, ES Modules and in the browser.
- Install the dependency
Using
Yarn
yarn add pmx-button
or using NPM
npm install install pmx-button --save
- Include the module
CommonJS
const inert = default;
ES2015 modules
;
API
.init(config, shared)
:
Initializes the component.
.stop(config, shared)
Stops the component by removing all added mutations.
Browser Support
- IE 10+
- Chrome
- Firefox
- Safari
Dependencies
This library has been written with some ES2015 features that need to be polyfilled:
- Map
- Object.assign