Giter Club home page Giter Club logo

modly-js's Introduction

Modly.js

Dependency-free, lightweight and responsive modal window library

Build Status

Installation

Install Modly.js as a NPM dependency or grab the latest version from the CDN.

NPM:

# yarn
yarn add modly-js --dev

# npm
npm i modly-js --save-dev

CDN:

<script src="https://cdn.jsdelivr.net/npm/modly-js"></script>

Usage

A new Modly will pop up as soon as you instanciate it:

new Modly()

The above is the most basic version that is allowed (without any options).

The constructor also supports passing an options object:

new Modly({ content: "Hi there from modly!" });

Options:

animation.enabled - (true, false) Defines, if the Modly should be shown with or without an animation. animation.duration - (duration in ms) Defines the duration of the animation (only relevant, if animation.enabled is set to true).

className - (string) Additional custom class name(s) which will be added to the Modly wrapper.

closeButton.enabled - (true, false) Defines if the close button should be shown or hidden.

content - (string, HTMLElement) If a string will be passed, that's going to be the content, otherwise you can i.e. use document.querySelector() to grab the HTML element you want to set as content.

overlay.enabled - (true, false) Defines, if the wrapping overlay should be enabled (background color and will dispose the Modly instance on click) or disabled (no background color and won't dispose the Modly instance on click).

position - (top-left, top, top-right, right, bottom-right, bottom, bottom-left, left, center) Defines where to position the Modly. If the content of the Modly is bigger than the current screen size, it'll be positioned vertically to the top.

sizes.width - (number in px) Sets the maximum width of the Modly.

theme - (light) Defines the theme for the Modly. Currently, only light is implemented.

Default options

For each of the options above, there's a pre-defined default value, which will be used, if not overridden in the options:

const defaults = {
  animation: {
    enabled: true,
    duration: 300
  },
  className: "",
  closeButton: {
    enabled: true
  },
  content: "",
  overlay: {
    enabled: true
  },
  position: "center",
  sizes: {
    width: 900
  },
  theme: "light"
};

modly-js's People

Contributors

ivansieder avatar sergejusk307 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.