开发者

How jQuery Snap To Elements Works?

I was puzzled when I saw jQuery "Snap to element". Does anyone know how can I implement it without jQuery, with just raw javascript.

开发者_开发问答

Thanks


Assuming you've built a drag and drop implementation without jQuery UI to have it snap to another element you need to now do the following:

  • Determine the position and dimensions of the dragging object and other objects to which you want the element to be able to snap to
  • While an object is being dragged you need to determine if the object being dragged is within your arbitrary threshold distance of an object it can snap to at that point you bump the dragged elements left/top to match the left/top/bottom/right position of the "snappable" element
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜