简体   繁体   English

使用鼠标拖拽边缘动画来触发mouseenter / mouseleave事件

[英]Fire mouseenter / mouseleave event with drag en drop in edge animate

I'm trying to make a demo with visual feedback. 我正在尝试通过视觉反馈进行演示。 A draggable element has to be dropped on a droppable element. 必须将可拖动元素拖放到可拖放元素上。 This works perfectly with the inserted jquery and jquery-ui script. 这与插入的jquery和jquery-ui脚本完美配合。

My question: 我的问题:

I want to add a visual feedback by adding a mouseenter and mouseleave on this object (dragenter or dragover isn't supported within edge so thats no option). 我想通过在该对象上添加mouseenter和mouseleave来添加视觉反馈(边缘不支持dragerer或dragover,因此没有选择)。 Because i'm dragging an image the droppable element doesn't fire the mouse events since there is simply a image inbetween them. 因为我正在拖动图像,所以droppable元素不会触发鼠标事件,因为它们之间只是一个图像。

How can I make the droppable object see the mouse and still work when dropped? 如何使可放置对象看到鼠标并在放置后仍能正常工作?

sym.$("pdf_file").draggable({
  opacity: 0.40,
  revert: "invalid",
});


sym.$("droppable_object_01").droppable({
  accept: sym.$("pdf_file"),
  drop: function(){
  sym.play('start_drag_pdf_01');
  }
});

sym.play('mouse_enter').css({
  'opacity': 0.99,
});

sym.play('mouse_leave').css({
  'opacity': 0.00
});

Thanks 谢谢

jQuery-ui's draggables have the over and out events that you can use: jQuery-ui的可拖动对象具有可以使用的overout事件:

sym.$("droppable_object_01").droppable({
    over: function() {
        // Run any code when the draggable is dragged over the droppable
    },
    out: function() {
        // Run any code when the draggable is dragged out of the droppable
    }
});

Here is an example: https://jsfiddle.net/5jtoawp8/ 这是一个示例: https : //jsfiddle.net/5jtoawp8/

More information in the docs . 在文档中有更多信息。

 <script src="jquery-3.1.0.min.js"></script>
 <script type="text/javascript">

    $(function () {
        $("#dvRestrictedArea").mouseenter(function () {
            alert("Mouce Enter into Restricted Area");
        });
        $("#dvRestrictedArea").mouseleave(function () {
            alert("Mouce leave from Restricted Area");
        });
    });

</script>

单击查看“输出”屏幕

代码部分

Thanks... :) 谢谢... :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM