Code Monkey home page Code Monkey logo

jquery-drag's Introduction

jquery-drag


spm version

jQuery 鼠标拖拽插件


Install

$ spm install jquery-drag --save

Usage

It is very easy to use this module.

// require jquery
var $ = require('jquery');

// extend jquery.fn
require('jquery-drag')($);

// use
$('#demo').drag();

Api

Options

$.fn.drag.defaults = {
    // 鼠标操作区域选择器,默认为this
    // 参数为选择器字符串
    handle: null,

    // 鼠标拖拽时,移动的目标,即从handle开始查找最近匹配的祖先元素
    // 默认为this
    // 参数为选择器字符串
    drag: null,

    // 拖拽轴向,x:水平,y:垂直,xy:所有
    axis: 'xy',

    // 鼠标形状,为空时将不会自动设置
    cursor: 'move',

    // 拖拽对象的最小位置,格式为{left: 10, top: 10}
    min: null,

    // 拖拽对象的最大位置,格式为{left: 1000, top: 1000}
    max: null,

    // 拖拽时的层级值
    zIndex: 9999,

    // 拖拽开始前回调
    // this: drag element
    // arg0: event
    // arg1: instance
    ondragbefore: $.noop,


    // 拖拽开始后回调
    // this: drag element
    // arg0: event
    // arg1: instance
    ondragstart: $.noop,

    // 拖拽中回调
    // this: drag element
    // arg0: event
    // arg1: instance
    ondrag: $.noop,

    // 拖拽结束后回调
    // this: drag element
    // arg0: event
    // arg1: instance
    ondragend: $.noop
};

Functions

options

// get options
$('#demo').drag('options');

// set options
$('#demo').drag('options', 'zIndex', 9999);
$('#demo').drag('options', {
    axis: 'x',
    cursor: 'auto'
});

Demo

http://spmjs.io/docs/jquery-drag/examples/index.html

History

http://spmjs.io/docs/jquery-drag/history.html

jquery-drag's People

Contributors

cloudcome avatar

Watchers

 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.