当前位置:网站首页>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\
边栏推荐
- 自适应控制——仿真实验一 用李雅普诺夫稳定性理论设计自适应规律
- vscode中写markdown格式笔记的配置过程和相关语法
- MySQL |子查询
- Domino Server SSL Certificate Installation Guide
- Re15: Read the paper LEVEN: A Large-Scale Chinese Legal Event Detection Dataset
- Container Technology - A Simple Understanding of Kubernetes Objects
- If someone asks you about distributed transactions again, throw this to him
- Re19:读论文 Paragraph-level Rationale Extraction through Regularization: A case study on European Court
- Day113. Shangyitong: WeChat login QR code, login callback interface
- flyway的快速入门教程
猜你喜欢

JCL learning

idea2021+Activiti【最完整笔记一(基础使用)】

你真的懂Redis的5种基本数据结构吗?

Redis Desktop Manager 2022.4.2 发布
![[Deep Learning] (Problem Record) <What do I get by calculating the gradient of a variable> - Linear Regression - Small Batch Stochastic Gradient Descent](/img/28/834aac16859fd26ab69de30f5fed55.png)
[Deep Learning] (Problem Record)
- Linear Regression - Small Batch Stochastic Gradient Descent 
PyQt5 - draw text on window

flyway的快速入门教程

【C和指针第七章】可变参数列表

EViews 12.0 software installation package download and installation tutorial

死锁的理解
随机推荐
Meikle Studio-Look at Hongmeng Device Development Practical Notes 7-Network Application Development
The thread pool method opens the thread -- the difference between submit() and execute()
Basic operations of sequence table in C language
4、yolov5-6.0 ERROR: AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘ 解决方案
Security思想项目总结
Re15:读论文 LEVEN: A Large-Scale Chinese Legal Event Detection Dataset
软考 系统架构设计师 简明教程 | 系统运行与软件维护
Flink_CDC搭建及简单使用
Re16: Read the paper ILDC for CJPE: Indian Legal Documents Corpus for Court Judgment Prediction and Explanation
图像去噪——Neighbor2Neighbor: Self-Supervised Denoising from Single Noisy Images
线程池方式开启线程--submit()和execute()的区别
Online target drone prompt.ml
Scrapy crawler website image crawling
Some commands of kubernetes
软考 系统架构设计师 简明教程 | 案例分析 | 需求分析
Js array operating mobile for encapsulation
CVTE school recruitment written test questions + summary of knowledge points
Re18: Read the paper GCI Everything Has a Cause: Leveraging Causal Inference in Legal Text Analysis
what is this method called
SST-Calib:结合语义和VO进行时空同步校准的lidar-visual外参标定方法(ITSC 2022)