Coder Social home page Coder Social logo

message's Introduction

Message

弱提示模块,需要promise polyfill demo

npm i @eightfeet/message -S
import Message from '@eightfeet/message';

const myMessage = new Message();

myMessage.create('A message!').then(() => console.log('已经完成弱提示'));

parame

参数 说明 是否必填 备注 类型
id 所创建弱提示的id 不传可自动生成id(message + 时间戳 + 100以内的随机数) String
zIndex message的样式层级关系 默认10000 Number
emBase em单位的基准像素 默认自动计算(emBase = document.clientWidth/24) Number
parentId 所挂载的父级ID用于做局部弱提示 默认挂在body下面,指定父级dom时将挂载在父级dom下,配合css实现局部弱提示 String
directionFrom 入场方向 top,bottom。默认top String
style 定义弱提示样式 {
wrap: 外包裹
main: 弱提示内容
}
Object

options

  1. create: ƒ (content, time, noRemoval) 创建message

    content String 提示内容。

    time Number 提示保留时间

    noRemoval Boolean 关闭弹窗时是否移除message Dom。 false移除,true保留。

  2. hide: ƒ (noRemoval) 隐藏弹窗

    noRemoval Boolean 关闭弹窗时是否移除弹窗Dom。 false移除,true保留。

  3. remove: ƒ () 移除弹窗

    移除,将message从body中移除。

  4. show: ƒ (content) 显示弹窗

    显示页面Message,如果创建的Message是隐藏而不是移除时,调用此方法显示Message。 content String 提示内容。

case

import Modal from '@eightfeet/Message';

const newMessage = new Message({
        directionFrom: 'top', // 底部位置
        style: { 
            wrap: {
                top: 'auto'
            },
            main: {
                backgroundColor: 'red'
            }
        }
    });

    const btn = document.getElementById('exampleBtn');

    btn.onclick = function(){ 
        return newMessage.create('Message', null, true).then(function(){
            document.getElementById('btnShow').onclick = function(){
                return newMessage.show('显示已存在的Message!');
            };
        });
    }
    

message's People

Contributors

eightfeet 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.