锁定轴
锁定轴:字符串
返回值:String
在特定拖动期间被锁定移动的轴。
细节
Boolean- 被锁定移动的轴(可以是"x"
或者"y"
)。例如,如果在某个 Draggable 实例上lockAxis
设置为true
的type: "x,y"
,用户开始水平拖动,lockedAxis
将会是"y"
因为在此拖动期间不允许垂直方向的移动。该lockedAxis
属性不会在按下时立即设置——Draggable 必须等待并判断用户首先拖动的方向。如果你希望在轴被锁定时收到通知,可以定义一个onLockAxis
回调函数。
lockedAxis
当你使用的是仅允许沿某一轴拖动的 Draggable 类型(如type: "x"
, type: "y"
, type: "left"
,或者type: "top"
)并且用户通过触摸进行拖动时,在启用了触摸事件的设备上也会填充
Draggable.create("#yourID", {
type: "x,y",
lockAxis: true,
onLockAxis: function () {
console.log("locked axis: " + this.lockedAxis);
},
});