Giter Site home page Giter Site logo

swipe-left's Introduction

swipe-left

左滑菜单组件

效果

Usage

import SwipeLeft from "./SwipeLeft";

const sl = new SwipeLeft();

sl.init(selector(String), Array.<Object>);

demo:

import SwipeLeft from "./SwipeLeft";

//  实例化一个SwipeLeft对象
const sl = new SwipeLeft();

//  配置参数, menus
sl.init(".menus", {
    menus: [{
        "text": "删除",
        "classes": ["on", "test"],
        "css": {
        	"font-size": "14px",
        	"width": "100px",
        	"background-color": "red"
        },
        handler: (e) => {
        	if(confirm("你确定删除此项吗?")) {
        		e.el.parentNode.parentNode.removeChild(e.el.parentNode);
        	}
        }
    }, {
        "text": "新增",
        "classes": "text-calss",
        "css": {
        	"font-size": "14px",
        	"background-color": "green"
        },
        handler: (e) => {
        	alert("即将新增一项");
        }
    }]
});

参数解释

属性名 参数类型 默认值 意义
text String N/A 显示在菜单按钮上的文字
classes Array./String N/A 自定义样式类, 当为数组时,表示同时添加多个样式类
css Object {} 自定义样式
handler Function function() {} 菜单项被轻击之后的函数响应

注:

本项目中的事件依赖于本人的另一项目(Toucher)实现

swipe-left's People

Stargazers

Seeker avatar  avatar LiYuanKun avatar Steve avatar tianleiyiji123 avatar

Watchers

James Cloos avatar Steve 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.