当前位置:网站首页>Drag and drop events, dataTransfer, getBoundingClientRect
Drag and drop events, dataTransfer, getBoundingClientRect
2022-07-30 10:40:00 【galloping bell cat】
I'm going to write a lowcode project recently. For someone like me who has only written web projects, it's really nothing.Read the source code of a project, look at the things here and study it, and review the original things by the way.QAQ
First
Never used drag and drop
Drag and drop event
There are three types of objects in drag and drop events.
- Source Object: The object that was dragged and dropped during the process
- Process Objects: Objects passed through in drag and drop
- Destination object: The object that finally arrives
The three objects have different triggering events
Source Object
dragstart: Start drag and drop, the event fires when the movement starts.drag: Triggered when the dragged object is moved during the drag and drop process.dragend: The drag and drop is over, triggered when the entire drag and drop operation ends.
Process Objects
dragenter: The source object enters the scope of the process object, and is triggered when the dragged object enters the process objectdragover: The source object moves within the scope of the process object , triggered when the dragged object moves within the process objectdragleave: The source object leaves the scope of the process object, triggered when the dragged object leaves the target object
Target:
drop: Triggered when the target is dropped.
dataTransfer object
A data transfer object dataTransfer is provided in all drag and drop events, mainly used to transfer data between the source object and the target object.
Method
setData(format, data)
Set the data to be passed in the drag event, the parameter of
formatis the data typeThis method stores data into the object in
dataTransfer, accepts two parameters, the first one indicates the type of data to be stored, there are 4 types:- text/plain
- text/html
- text/xml
- text/uri-list
- If the parameters written are not the above, it is equivalent to creating a new data type.Makes the last item in the
dataTransfer.typeslist to be the new type.
Parameter 2 is the data to be stored
Example:
e.dataTransfer.setData("num",index)
getData(format)
- Get the data passed in the drag event, the
formatparameter is the data type - This method reads data from the
dataTransferobject. The parameter is the data type specified in thesetDatamethod, for example:event.dataTransfer.getData('text/plain')
- Get the data passed in the drag event, the
clearData()
- With parameter: clear the stored data corresponding to this parameter
- No parameters: clear all data
getBoundingClientRect()
TheElement.getBoundingClientRect() method returns the size of the element and its position relative to the viewport (computer screen).
Combined review:
clientX: When the mouse event occurs, the position of the mouse relative to the X-axis of the browser (where the page is displayed on the browser);clientY: The position of the mouse relative to the y-axis of the browser when the mouse event occurs;screenX: The position of the mouse relative to the x-axis of the monitor screen when the mouse event occurs;screenY: When the mouse event occurs, the position of the mouse relative to the y-axis of the display screen;offsetX: When the mouse event occurs, the position of the mouse relative to the x-axis of the event sourceoffsetY: When the mouse event occurs, the position of the mouse relative to the y-axis of the event source\
边栏推荐
- [100个Solidity使用技巧]1、合约重入攻击
- OC-手动引用计数内存管理
- Online target drone prompt.ml
- Scrapy crawler website image crawling
- 论文阅读:SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers
- 606. Create a string from a binary tree (video explanation!!!)
- 第1章 Kali与靶机系统
- 数据库脏读、不可重复读、幻读以及对应的隔离级别
- jmeter接口压力测试-(二)
- nacos实战项目中的配置
猜你喜欢

Flink_CDC construction and simple use

Linux内核设计与实现(十)| 页高速缓存和页回写

神经网络学习笔记4——自动编码器(含稀疏,堆叠)(更新中)

Re17: Read the paper Challenges for Information Extraction from Dialogue in Criminal Law

Alibaba Cloud OSS Object Storage

MFCC转音频,效果不要太逗>V<!
![idea2021+Activiti [the most complete note one (basic use)]](/img/60/55cccf257523bed2c8829361cea97c.png)
idea2021+Activiti [the most complete note one (basic use)]

Online target drone prompt.ml

Day113. Shangyitong: WeChat login QR code, login callback interface
![[Qualcomm][Network] 网络拨号失败和netmgrd服务分析](/img/76/49054ff8c7215eca98cc479ab1d986.png)
[Qualcomm][Network] 网络拨号失败和netmgrd服务分析
随机推荐
这种叫什么手法
105. Construct binary tree from preorder and inorder traversal sequence (video explanation!!)
spark udf accepts and handles null values.
Domino服务器SSL证书安装指南
Meikle Studio - see the actual combat notes of Hongmeng device development 4 - kernel development
从数据流中快速查找中位数
Selected System Design | Design of CAN Bus Controller Based on FPGA (with Code)
In 2022, the top will be accepted cca shut the list
Linux内核设计与实现(十)| 页高速缓存和页回写
第1章 Kali与靶机系统
(BUG record) No module named PIL
Re21:读论文 MSJudge Legal Judgment Prediction with Multi-Stage Case Representation Learning in the Real
[AGC] Growth Service 2 - In-App Message Example
元宇宙改变人类工作模式的四种方式
Baidu promotion assistant encounters duplicate keywords, verification errors, how to delete redundant ones with one click
Container Technology - A Simple Understanding of Kubernetes Objects
PyQt5 - Drawing different types of straight lines
Online target drone prompt.ml
Re16:读论文 ILDC for CJPE: Indian Legal Documents Corpus for Court Judgment Prediction and Explanation
OC - Manual Reference Counting Memory Management