【问题标题】:jQueryUI Draggable: Constrain draggability to a single axis?jQuery UI Draggable:将成药性约束到单轴?
【发布时间】:2010-07-21 03:52:06
【问题描述】:

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

谢谢!

【问题讨论】:

    标签: javascript jquery jquery-ui jquery-ui-draggable


    【解决方案1】:

    查看axis 选项:

    “限制拖动到水平 (x) 或垂直 (y) 轴。可能的值:'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');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-03
      • 1970-01-01
      • 2011-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多