当前位置:网站首页>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\
边栏推荐
- 多线程--线程和线程池的用法
- wsl操作
- what is this method called
- 你真的懂Redis的5种基本数据结构吗?
- JCL learning
- Linux内核设计与实现(十)| 页高速缓存和页回写
- vscode中写markdown格式笔记的配置过程和相关语法
- Flask之路由(app.route)详解
- Re19: Read the paper Paragraph-level Rationale Extraction through Regularization: A case study on European Court
- OC-ARC (Automatic Reference Counting) automatic reference counting
猜你喜欢

Re15: Read the paper LEVEN: A Large-Scale Chinese Legal Event Detection Dataset

shell script

spark udf 接受并处理 null值.

Flink_CDC construction and simple use

(C语言)文件操作

多线程--线程和线程池的用法

再有人问你分布式事务,把这篇扔给他

Alibaba Cloud OSS Object Storage

图像去噪——Neighbor2Neighbor: Self-Supervised Denoising from Single Noisy Images

4、yolov5-6.0 ERROR: AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘ 解决方案
随机推荐
(BUG record) No module named PIL
【C和指针第七章】可变参数列表
神经网络学习笔记4——自动编码器(含稀疏,堆叠)(更新中)
GNOME 新功能:安全启动被禁用时警告用户
JCL 学习
CVTE school recruitment written test questions + summary of knowledge points
[100个Solidity使用技巧]1、合约重入攻击
Matplotlib--plot markers
分页 paging
A new generation of free open source terminal tool, so cool
Array of Shell System Learning
(Text) Frameless button settings
Baidu promotion assistant encounters duplicate keywords, verification errors, how to delete redundant ones with one click
spark udf 接受并处理 null值.
[Qualcomm][Network] 网络拨号失败和netmgrd服务分析
SST-Calib: A lidar-visual extrinsic parameter calibration method combining semantics and VO for spatiotemporal synchronization calibration (ITSC 2022)
Study Notes 11--Direct Construction of Local Trajectories
唯物辩证法-条件论
Meikle Studio - see the actual combat notes of Hongmeng device development 4 - kernel development
Scrapy crawler website image crawling