This is a browser-specific issue and has nothing to do with the Javascript functionality used. Even if you apply the following class to your element and try to drag it, the drag element will still not be applied to the style.
.myClass { -webkit-transform:rotate(-3deg) skew(5deg); transform:rotate(-3deg) skew(5deg); }
https://jsfiddle.net/gnxccyz7/
However, here is a solution to your problem: just create a child inside your drag and drop element and apply a style to it. It also works on Chrome!
JavaScript:
function drag(ev) { ev.target.className = 'myClass'; ev.dataTransfer.setData("idOfItem", ev.target.id); }
CSS
.myClass span { display:block; background:#f1f1f1; -webkit-box-shadow:box-shadow:2px 2px 1px 1px rgba(144, 144, 144, 0.39); box-shadow:2px 2px 1px 1px rgba(144, 144, 144, 0.39); -webkit-transform:rotate(-3deg) skew(5deg); transform:rotate(-3deg) skew(5deg); }
https://jsfiddle.net/sbh4j9ag/
scooterlord
source share