Jquery UI Draggable: Align helper to mouse position

With jQuery I have a draggable element. It's a div with a size of 200 x 40. Of course the user can start dragging this div by clicking at variuos positions in the div. What I want is when the startdrag event happens, the helper (clone) div will always be aligned to the cursor the same way, no matter where in the div the user started dragging. So after the mousedown the helper's top and left values need to be the same as the mouses x and y. I've tried this using this coffeescript code: onStartDrag: ( e, ui ) => ui.helper.css left: e.clientX top: e.clientY console.log( e ) But it doesn't work and my guess is that this is happening because the values I put in are directly overwritten by the draggable plugin because of mouse movement.. Any ideas?
You should set a jsfiddle to let us see whats going on

以上就是Jquery UI Draggable: Align helper to mouse position的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准