jQuery UI Draggable issue with containment option -
i'm trying have image inside div
of same width draggable in limit of div. it's difficult explain 1 side of image (top or bottom) can leave div cannot have gap between edge of image , border of div.
to resume image has same width of parent div height bigger part of image hidden.
well here want do: http://jsfiddle.net/maxwell2022/derna/165/
it's working perfectly... because there nothing above div. if there gap between document , div, it's not working anymore. think draggable
taking document reference top of image. start dragging image, image move , stuck top edge top of document:
http://jsfiddle.net/maxwell2022/derna/164/
i don't know how can achieve containment
option. cheers,
maxime
update
another attempt relative positioning no luck: http://jsfiddle.net/maxwell2022/derna/166/
i found solution fix getting top position of parent div using offset()
, add containment boundary. i'm not sure it's best solution looks it's working.
i have difference of 1%
in offset @ top quite annoying: if drag image , make stick top as possible returns 99%
offset instead of 100%
(see result in console).
the bottom 1 correct (0%
). think it's due rounding size i'm not sure. here jsfiddle: http://jsfiddle.net/maxwell2022/derna/167/
if have better idea please, please, let me know.
thanks, maxime
Comments
Post a Comment