A JavaScript Free Drag class introduction

Source: Internet
Author: User

Basic drag:

1 newDragdrop({
2     target 拖拽元素 HTMLElemnt 必选
3     bridge   指定鼠标按下哪个元素时开始拖拽,实现模态对话框时用到
4     dragable 是否可拖拽   (true)默认
5     dragX true/falsefalse水平方向不可拖拽 (true)默认
6     dragY    true/falsefalse垂直方向不可拖拽 (true)默认
7     area [minX,maxX,minY,maxY] 指定拖拽范围 默认任意拖动
8     callback 拖拽过程中的回调函数
9 });

Drag and drop the most technical content is this paragraph: Earl's Casino

1 if(el.setCapture){ //IE
2     E.on(el, "losecapture", mouseup);
3     el.setCapture();
4     e.cancelBubble = true;
5 }elseif(window.captureEvents){ //标准DOM
6     e.stopPropagation();
7     E.on(window, "blur", mouseup);
8     e.preventDefault();
9 }

This effect does not use jquery, pure native JavaScript implementations, can be referenced below. The drag effect is smooth and natural, with no noticeable fluctuations in CPU performance.

Specific drag and drop can see the source code on this page to get, this is not posted out.

A JavaScript Free Drag class introduction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.