1

我需要实现一个外观与温泉滑动菜单完全相同的菜单,但它是从顶部滑动的。我正在考虑使用温泉手势来拖动菜单,但是温泉指南中提供的手势示例不起作用。我错过了什么吗?

  <ons-gesture-detector>
    <div id="detect-area" style="width: 300px; height: 300px;background-color:blue;">
      Swipe Here
    </div>
  </ons-gesture-detector>

  <script>
    alert("in");
    $(document).on('swipeleft', '#detect-area', function() {
      alert("swipe");
    })
  </script>
4

1 回答 1

3

试试这个,它应该工作。不要忘记先添加jquery。

<ons-gesture-detector style="height: 300px; margin: 50px 50px;">
    <div id="hoge" style="border: 1px solid #ccc; background-color: #f9f9f9; width: 100%; height: 300px; line-height: 300px; text-align: center; color: #999;">
        ...
    </div>
</ons-gesture-detector>

<script>
    var eventName = 
      'drag dragleft dragright dragup dragdown hold release swipe swipeleft swiperight ' +
      'swipeup swipedown tap doubletap touch transform pinch pinchin pinchout rotate';

    $(document).on(eventName, '#hoge', function(event) {
      if (event.type !== 'release') {
        $(this).text(event.type);
      }
    });
 </script>

于 2015-06-05T01:19:22.817 回答