Bootstrap mode box to implement relative positioning drag-and-drop, bootstrap Mode

Source: Internet
Author: User

Bootstrap mode box to implement relative positioning drag-and-drop, bootstrap Mode

1. Normal drag and drop operations are implemented by absolute positioning absolute, but the bootstrap modal box uses relative. For the convenience of unified change, the drag and drop effect is implemented based on relative positioning.

$ (". Modal. modal-header "). mousedown (function (e) {var isDrag = false; // you can drag var ev = e | window. event; var ol = $ (this ). offset (). left; // The leftmost distance of the box from the leftmost distance of the window var ot = $ (this ). offset (). top; var l = (this).parent().css ("left"); var t = (this).parent().css ("top"); deltaX = ev. pageX-parseInt (l); // The leftmost distance from the mouse to the box. deltaY = ev. pageY-parseInt (t); isDrag = true; var _ this = $ (this ). parent (); $ (document ). mousemove (function (e) {var ev = e | window. event; if (isDrag) {moveL = ev. pageX-deltaX; moveT = ev. pageY-deltaY; _this.css ({"left": moveL, "top": moveT}) ;}); $ (document ). mouseup (function () {isDrag = false ;});});

Of course, if you don't have a limit, you can take it off if you want to. Oh no, it's drag, drag, or drag. It's not what you think. Okay, it's what you think.

However, I found that there were still some problems after my judgment, and the problem was not solved yet. I will try again later.

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.