当前位置:网站首页>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\
边栏推荐
- [AGC] Growth Service 2 - In-App Message Example
- OC-手动引用计数内存管理
- [Qualcomm][Network] 网络拨号失败和netmgrd服务分析
- PyQt5 - draw sine curve with pixels
- 【AGC】增长服务2-应用内消息示例
- (***Key points***) Flink common memory problems and tuning guide (1)
- SST-Calib: A lidar-visual extrinsic parameter calibration method combining semantics and VO for spatiotemporal synchronization calibration (ITSC 2022)
- Day113. Shangyitong: WeChat login QR code, login callback interface
- 【HMS core】【FAQ】HMS Toolkit典型问题合集1
- 105. Construct binary tree from preorder and inorder traversal sequence (video explanation!!)
猜你喜欢
![[Qualcomm][Network] 网络拨号失败和netmgrd服务分析](/img/76/49054ff8c7215eca98cc479ab1d986.png)
[Qualcomm][Network] 网络拨号失败和netmgrd服务分析

WARN: Establishing SSL connection without server's identity verification is not recommended when connecting to mysql

Adaptive Control - Simulation Experiment 1 Designing Adaptive Laws Using Lyapunov's Stability Theory

系统设计精选 | 基于FPGA的CAN总线控制器的设计(附代码)

flowable工作流所有业务概念

Flask's routing (app.route) detailed

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

【HMS core】【Analytics Kit】【FAQ】如何解决华为分析付费分析中付款金额显示为0的问题?

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

jmeter接口压力测试-(二)
随机推荐
Re21:读论文 MSJudge Legal Judgment Prediction with Multi-Stage Case Representation Learning in the Real
Array of Shell System Learning
Alibaba Cloud OSS Object Storage
(***Key points***) Flink common memory problems and tuning guide (1)
spark udf accepts and handles null values.
Basic operations of sequence table in C language
在机器人行业的专业人士眼里,机器人行业目前的情况如何?
what is this method called
4. yolov5-6.0 ERROR: AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor' solution
【HMS core】【FAQ】HMS Toolkit典型问题合集1
vscode中写markdown格式笔记的配置过程和相关语法
【AGC】增长服务2-应用内消息示例
Quick Start Tutorial for flyway
第1章 Kali与靶机系统
debian10 install djando
梅科尔工作室-看鸿蒙设备开发实战笔记七——网络应用开发
关于verilog的时延研究
4、yolov5-6.0 ERROR: AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘ 解决方案
Selected System Design | Design of CAN Bus Controller Based on FPGA (with Code)
SST-Calib:结合语义和VO进行时空同步校准的lidar-visual外参标定方法(ITSC 2022)