使用触摸式打孔与JQuery UI手风琴可排序无法正常使用触摸

时间:2016-05-15 17:08:58

标签: javascript jquery html jquery-ui jquery-ui-touch-punch

我刚刚使用JQuery UI创建了一个可排序的Accordion,并使用touchpunch来启用触摸设备对这些部分进行排序。 拖放工作正常,但我注意到"触摸延伸"并不总是有效,我必须触摸几次以使该部分延伸。

有没有人知道修复此问题?

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script>
    <div id="accordion">
      <div class="group">
        <h3>Section 1</h3>
        <div>
          <p>Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p>
        </div>
      </div>
      <div class="group">
        <h3>Section 2</h3>
        <div>
          <p>Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p>
        </div>
      </div>
      <div class="group">
        <h3>Section 3</h3>
        <div>
          <p>Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p>
          <ul>
            <li>List item one</li>
            <li>List item two</li>
            <li>List item three</li>
          </ul>
        </div>
      </div>
      <div class="group">
        <h3>Section 4</h3>
        <div>
          <p>Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p><p>Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p>
        </div>
      </div>
    </div>


    <script>

    $(function() {
        $( "#accordion" )
          .accordion({
            header: "> div > h3"
          })
          .sortable({
            axis: "y",
            handle: "h3",
            stop: function( event, ui ) {
              // IE doesn't register the blur when sorting
              // so trigger focusout handlers to remove .ui-state-focus
              ui.item.children( "h3" ).triggerHandler( "focusout" );

              // Refresh accordion to handle new order
              $( this ).accordion( "refresh" );
            }
          });
      });
    </script>

以下是jsfiddle

1 个答案:

答案 0 :(得分:0)

雅问题是可排序是在鼠标按下或点击或其他东西时触发,而touchpunch正在覆盖defualt动作。没有通过代码,我只是做了一个“hack”,我将排序句柄与h3元素分开。

第1步: 设置一些样式,使图标位于正确的位置

.dragme {
    float:right;
    margin-top:10px;
}

第2步: 将该图标放入并使其漂亮

<h3>Section 3<span class='dragme  ui-accordion-icons ui-icon ui-icon-triangle-2-n-s'></h3>

第3步:更改可排序的句柄,以便漂亮的图标移动内容

 .sortable({
            axis: "y",
            handle: ".dragme"});