1.0.1 • Published 1 year ago

@egodesign/modal v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@egodesign/modal

Usage:

Import the EgoModal class into your file and then create as many instances as you need.

import EgoModal from '@egodesign/modal';

const egoModal = new EgoModal({
    element: document.getElementById('egoModal')
});

HTML minimal markup & class names:

<dialog class="modal" id="egoModal">
    <div class="modal__box">
        <button class="modal__close" type="button">Close</button>
        <div class="modal__box__content">
            Modal content.
        </div>
    </div>
</dialog>

Required class names:

ClassDescription
modalThis is the mail element that wraps the whole modal, cinluding the overlay.
modal__boxThis is the box of the modal itself.
modal__contentThis is the context body. When using the injectContent() method the content will be placed inside this element.

Optional class names:

ClassDescription
modal__closeAny element inside the modal which has this class will close the modal on click.

Options:

NameValueRequiredDescription
elementDOM elementThe main dialog DOM element.
lockScrollOnOpenbooleanWheather or not the body scroll should be hidden. Default: true.
animationstringBesides the default fade in and fade out effect, you can optionally add an extra native animation. Available options are rise, sink, grow or shrink.

p

Events:

NameDescription
onOpenPass a function to be called when modal is opened.
onClosePass a function to be called when modal is closed.

Methods:

NameDescription
injectContentAdd content to de modal__content element on the fly. The first parameter should be the HTML string, and it can also recieve a callback function as second parameter.
1.0.1

1 year ago

1.0.0

1 year ago