jQueryUI Draggable:将可拖动性限制到单个轴吗? [英] jQueryUI Draggable: Constrain draggability to a single axis?

查看:112
本文介绍了jQueryUI Draggable:将可拖动性限制到单个轴吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拖动对象时,用户可以在x和y轴上拖动.我想将可拖动性限制为仅x轴.我应该怎么做呢?

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?

谢谢!

推荐答案

查看 axis 选项:

限制拖动到水平(x)或垂直(y)轴.可能的值:'x','y'."

"Constrains dragging to either the horizontal (x) or vertical (y) axis. Possible values: 'x', 'y'."

示例:

// 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');

这篇关于jQueryUI Draggable:将可拖动性限制到单个轴吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆