SoFunction
Updated on 2025-04-07

The element drag function implemented in javascript is hosted as the browser

The element drag function implemented in javascript is hosted as the browser

Updated: July 21, 2014 16:59:36 Submission: whsnow
This article mainly introduces element dragging implemented by javascript, passing references to corresponding element objects into functions
//The host is the browser//Pass the reference to the corresponding element object into the functionfunction candrag(drager) { 
   = function (down) { 
    var offx =  
    var offy = ; 
    var offxl =  - offx; 
    var offyl =  - offy; 
     = 0;//Added condition attribute for window to resolve conflicts with click     = function (move) { 
       =  - offxl + "px"; 
       =  - offyl + "px"; 
       = "move"; 
      condition = ( - ) + ( - ); 
    } 
  } 
   = function () { 
     = null; 
     = "auto"; 
  } 
} 
/*For the resolution of the contradiction between click, it is necessary to judge the condition
 *For example: 
 candrag(dragger);
  = function () {
   if (!condition) {
      = "red";
   }
 }
 * Where d01 is a child element of dragger
 */ 
  • drag

Related Articles

  • Some data processing methods that may be commonly used in JS

    This article mainly introduces some data processing methods that may be commonly used in JS. Writing a lot of knowledge can deepen your own memory. The article gives detailed example code, which has certain reference learning value for everyone to learn or use JS. If you need it, you can refer to it.
    2021-09-09
  • uni-app PC widescreen adaptation solution detailed illustrations

    Now uni-app finally officially supports PC widescreen. The following article mainly introduces relevant information about the PC widescreen adaptation solution of uni-app. The article introduces the example code in detail. Friends who need it can refer to it.
    2023-03-03
  • Brief analysis of vue two-way binding

    This article mainly introduces relevant information about vue two-way binding, which has certain reference value. Interested friends can refer to it.
    2017-03-03
  • JavaScript setting amount style conversion retains two decimal places sample code

    This article introduces you to setting the amount style of JavaScript, that is, retaining two decimal places. There is a good tutorial below. Friends who need it can learn about it.
    2013-12-12
  • JavaScript implements dynamic form generation

    This article mainly discusses in-depth with you how to use JavaScript to implement a dynamic form generator. The sample code in the article is explained in detail. If you need it, please refer to it.
    2024-01-01
  • Javascript implements the method of image loading from blur to clear display

    This article mainly introduces the method of using Javascript to achieve image loading from blur to clear display. It is easy to understand. Friends who need it can refer to it.
    2016-06-06
  • How to elegantly cancel JavaScript asynchronous tasks

    This article mainly introduces how to elegantly cancel JavaScript asynchronous tasks. The article introduces the example code in detail, which has certain reference learning value for everyone's learning or work. Friends who need it, please learn with the editor below.
    2020-03-03
  • JS+JSP uses img tag call to realize the number of static page access statistics

    This article mainly introduces the method of JS+JSP to realize the number of static page access statistics through img tag calls. Based on JavaScript, the function of stating the number of accesses is realized through reading and writing to TXT text files. Friends who need it can refer to it
    2015-12-12
  • How to perform local debugging of WeChat official account development

    This article mainly introduces how to carry out local debugging methods for WeChat official account development. The editor thinks it is quite good. Now I will share it with you and give you a reference. Let's take a look with the editor
    2019-06-06
  • WeChat applet uses npm to support tricks

    This article mainly introduces the use of npm support for WeChat applets to hit the pit. The editor thinks it is quite good. Now I will share it with you and give you a reference. Let's take a look with the editor
    2018-11-11

Latest Comments