暫無描述

ons-gesture-detector.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
  2. import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
  3. import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
  4. import _inherits from 'babel-runtime/helpers/inherits';
  5. /*
  6. Copyright 2013-2015 ASIAL CORPORATION
  7. Licensed under the Apache License, Version 2.0 (the "License");
  8. you may not use this file except in compliance with the License.
  9. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. */
  17. import onsElements from '../ons/elements';
  18. import BaseElement from './base/base-element';
  19. import GestureDetector from '../ons/gesture-detector';
  20. /**
  21. * @element ons-gesture-detector
  22. * @category gesture
  23. * @description
  24. * [en]
  25. * Component to detect finger gestures within the wrapped element. Following gestures are supported:
  26. * - Drag gestures: `drag`, `dragleft`, `dragright`, `dragup`, `dragdown`
  27. * - Hold gestures: `hold`, `release`
  28. * - Swipe gestures: `swipe`, `swipeleft`, `swiperight`, `swipeup`, `swipedown`
  29. * - Tap gestures: `tap`, `doubletap`
  30. * - Pinch gestures: `pinch`, `pinchin`, `pinchout`
  31. * - Other gestures: `touch`, `transform`, `rotate`
  32. * [/en]
  33. * [ja]要素内のジェスチャー操作を検知します。詳しくはガイドを参照してください。[/ja]
  34. * @guide features.html#gesture-detection
  35. * [en]Detecting finger gestures[/en]
  36. * [ja]ジェスチャー操作の検知[/ja]
  37. * @example
  38. * <ons-gesture-detector>
  39. * <div id="detect-area" style="width: 100px; height: 100px;">
  40. * Swipe Here
  41. * </div>
  42. * </ons-gesture-detector>
  43. *
  44. * <script>
  45. * document.addEventListener('swipeleft', function(event) {
  46. * if (event.target.matches('#detect-area')) {
  47. * console.log('Swipe left is detected.');
  48. * }
  49. * });
  50. * </script>
  51. */
  52. var GestureDetectorElement = function (_BaseElement) {
  53. _inherits(GestureDetectorElement, _BaseElement);
  54. function GestureDetectorElement() {
  55. _classCallCheck(this, GestureDetectorElement);
  56. var _this = _possibleConstructorReturn(this, (GestureDetectorElement.__proto__ || _Object$getPrototypeOf(GestureDetectorElement)).call(this));
  57. _this._gestureDetector = new GestureDetector(_this, { passive: true });
  58. return _this;
  59. }
  60. return GestureDetectorElement;
  61. }(BaseElement);
  62. export default GestureDetectorElement;
  63. onsElements.GestureDetector = GestureDetectorElement;
  64. customElements.define('ons-gesture-detector', GestureDetectorElement);