jquery - Hide / customize cursor during HTML5 drag -


i'd customize mouse cursor during html5 drag operation because it's 1 thing setdragimage representing object being dragged (not in ie) looks pretty awful having standard mouse cursor superimposed. case when 'dragimage' small , there no way control opacity of 'dragimage'.

i have various css cursors specified on drop target these disabled / ignored both chrome , firefox during drag. leaves standard unattractive arrow-and-dotted-box.

here's fiddle: http://jsfiddle.net/mcau/wect6xuy/8/

here's html:

<img draggable id="i" src="http://icons.iconarchive.com/icons/icons8/windows-8/64/diy-paint-bucket-icon.png"/>  <table>     <tr>         <td class="a">copy</td>         <td class="b">none</td>     </tr>     <tr>         <td class="c">move</td>         <td class="d">crosshair</td>     </tr> </table> 

here's css:

td {     padding: 30px;     font-size: 2em;     font-family: arial;     border: 3px solid white;     background-color: #eee;     border-spacing: 10px; }  .a {    cursor: copy;} .b {    cursor: none;} .c {    cursor: move;} .d {    cursor: crosshair;}  img {     cursor: move;     cursor: -moz-grabbing; } 

here's jquery:

var = $('#i');  i.on('dragstart', function(e) {     e.originalevent.datatransfer.setdata('text', 'foo');     e.originalevent.datatransfer.setdragimage(this, this.offsetwidth/2, this.offsetheight/2); });  $('td').on('dragenter, dragover', function(e) {    e.preventdefault();    e.stoppropagation();     return false; });  $('td').on('drop', function(e) {     $(this).append(i);     e.preventdefault(); }); 

is there way hide or change mouse cursor during html5 drag?

just had same problem. found working solution helper.

here's script:

$('#i').draggable({   helper: function(e) {     return '<img id="drag" src="http://icons.iconarchive.com/icons/icons8/windows-8/64/diy-paint-bucket-icon.png">';   } }); 

and has added css...

#drag {cursor: none;} 

see fiddle https://jsfiddle.net/wect6xuy/31/

please note added jquery ui libraries. it's way got running.

hope helps


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -