jquery drag image

前端 未结 5 394
感动是毒
感动是毒 2021-01-11 19:17

i want to make a draggable image in jquery. first of all my experience with jquery is 0. having said that let me describe what i want to achieve. i have fixed width/height

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-11 20:03

    to limit to a region for this example, containment is not much of a help. I have implemented this for vertical only scroll, needs enhancement for horizontal limit:

    stop: function(event, ui) {
        var helper = ui.helper, pos = ui.position;
        var h = -(helper.outerHeight() - $(helper).parent().outerHeight());
        if (pos.top >= 0) {
            helper.animate({ top: 0 });
        } else if (pos.top <= h) {
            helper.animate({ top: h });
        }
    }
    

提交回复
热议问题