admin管理员组文章数量:1278653
When dragging an object, the user can drag in the x and y axes. I want to constrain the draggability to only the x-axis. How should I go about doing this?
Thank you!
When dragging an object, the user can drag in the x and y axes. I want to constrain the draggability to only the x-axis. How should I go about doing this?
Thank you!
Share Improve this question edited Nov 8, 2014 at 4:49 rgajrawala 2,1881 gold badge24 silver badges38 bronze badges asked Jul 21, 2010 at 3:52 milanmilan 1431 silver badge6 bronze badges1 Answer
Reset to default 12Check out the axis option:
"Constrains dragging to either the horizontal (x) or vertical (y) axis. Possible values: 'x', 'y'."
Examples:
// Initialize a draggable with the axis option specified.
$( ".selector" ).draggable({ axis: 'x' });
// Get the axis option, after initialization.
var axis = $('.selector').draggable('option', 'axis');
// Set the axis option, after initialization.
$('.selector').draggable('option', 'axis', 'x');
本文标签: javascriptjQueryUI Draggable Constrain draggability to a single axisStack Overflow
版权声明:本文标题:javascript - jQueryUI Draggable: Constrain draggability to a single axis? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741248917a2365423.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论