onsen-ui 手势不起作用

onsen-ui gestures not working

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

  <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>

试试这个,应该可以。不要忘记先加上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>