0.0.0 • Published 6 years ago

mgn-modal v0.0.0

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

mgn-modal ( Don't Need jQuery )

Execute Modal Window function.

  • Target browser : IE9+
  • For IE9, display Modal Window without transition.

Install

npm i mgn-modal -S

Or Download raw data

↓ download "mgn-modal.js"


Import

import mgnModal from "mgn-modal"

Constructor

new mgnModal(element [, option]);
ArgumentData typeDefaultDescroption
elementString-(Required)Specify target elementex) ".modal"
optionObject-ex) option = { width: 1024, modalSpeed: 200, bgColor: "#FFF", bgOpacity: 0.6, innerBgColor: "#FFF", innerBgPadding: 20, closeBtn: "<img src='close.png'>", addClass: "wrap", fixed: false}
OptionData typeDefaultDescroption
widthNumber768Specify Modal Window width.
modalSpeedNumber200Specify speed when open Modal.
bgColorString"#000"Specify background color.
bgOpacityNumber0.8Specify transparency for background color.
innerBgColorString"none"Specify background color.
innerBgPaddingNumber0Specify padding background.
closeBtnString"×"Specify close button.
addClassString-Add class to the topmost containing element.
fixedboolfalseSet to "true" to make background fixed.

Method

MethodArgumentDescroption
ReInit()-Execute when an element target for Modal is added later.
Open( element )StringSpecify the Modal element want to execute.( ex: ".default_open" )
Close()-Close the open Modal screen.
OpenEnd = function(){};-Execute after opening Modal screen.
CloseEnd = function(){};-Execute after closing Modal screen.

Demo

https://frontend-isobar-jp.github.io/mgn-modal/

import mgnModal from "mgn-modal"

let modal = new mgnModal(".j-modal");
modal.OpenEnd = function( index ){
	console.log(index, "openEnd")
};
modal.CloseEnd = function(){
	console.log("closeEnd")
};

//

mgnModal(
    ".j-modal2",
    {
        width: 768,
        modalSpeed: 200,
        bgColor: "#CCC",
        bgOpacity: 0.9,
        innerBgColor: "#CCC",
        innerBgPadding: 40,
        closeBtn: "Close",
        closeCancel: false,
        addClass: "",
        fixed: true
    }
);