jquery draggable - containment

后端 未结 4 1113
温柔的废话
温柔的废话 2020-12-30 17:11

I have a little project I\'m working on, and have an interesting containment issue using jquery\'s draggable:

Basically, I have two divs - a top & a

4条回答
  •  独厮守ぢ
    2020-12-30 17:33

    Admittedly the documentation is thin - I had to do a lot of testing to figure it out.

    My mistake was in thinking that the containment array defined a boundary within which the draggable element could move, defined as [x, y, width, height], but I've found that the containment array defines the upper left and lower right points that define the boundary defined as [x1, y1, x2, y2] that the contained elements origin can move within.

    This makes sense in that the last two array elements are defined as x2 and y2 (point properties), not w and h (rectangle properties), but the documentation should be more specific as to exactly what these parameters mean in context to the contained element, and within what context (against the contained element's origin) and coordinate system (the contained element's).

提交回复
热议问题