[英]Can't use null as the first argument for event.dataTransfer.setDragImage in Google Chrome
http://help.dottoro.com/ljdpgfkx.php http://help.dottoro.com/ljdpgfkx.php
I'm trying to set position of drag image feedback (the image of a dragged element displayed beside the cursor) with 我正在尝试设置拖动图像反馈(光标旁边显示的拖动元素的图像)的位置
event.dataTransfer.setDragImage(null, mouseX, mouseY);
and I got Uncaught TypeError: Failed to execute 'setDragImage' on 'DataTransfer': setDragImage: Invalid first argument . 并且我遇到了TypeError:无法在“ DataTransfer”上执行“ setDragImage”:setDragImage:无效的第一个参数 。
According to http://help.dottoro.com/ljdpgfkx.php . 根据http://help.dottoro.com/ljdpgfkx.php 。 Using null as the first argument should display the default image, but I got the error instead.
使用null作为第一个参数应显示默认图像,但出现错误。
I guess null won't work. 我猜null无效。 To use the default image use 'this' or whatever your particular reference to the DOM element being dragged is.
要使用默认图像,请使用'this'或您对要拖动的DOM元素的特定引用。 Here, for example, I ensure it's centered on the mouse:
例如,在这里,我确保它以鼠标为中心:
event.dataTransfer.setDragImage(this, this.offsetWidth/2, this.offsetHeight/2);
Hope that helps. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.