jquery div Layer Drag effect

Source: Internet
Author: User
 
 
 
$ (function () {
var _move=false;//move tag
var _x,_y;//the relative position of the mouse off the upper-left corner of the control
$ (". Drag"). MouseDown (function (e) {
_move=true;
_x=e.pagex-parseint ($ (". Drag"). CSS Tutorial ("left");
_y=e.pagey-parseint ($ (". Drag"). CSS ("top");
$ (". Drag"). Fadeto (20, 0.5);//Click to start dragging and transparent display
});
$ (document). MouseMove (function (e) {
if (_move) {
var x=e.pagex-_x;//) calculates the absolute position of the control's upper-left corner based on the mouse position
var y= e.pagey-_y;
$ (". Drag"). css ({top:y,left:x});//Control new location
}
}). MouseUp (function () {
_move=false;
$ (". Drag"). Fadeto ("Fast", 1);//Stop moving after releasing the mouse and revert to opaque});

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.