Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mouse.js 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _vue = require('vue');
  6. var _vue2 = _interopRequireDefault(_vue);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  9. exports.default = _vue2.default.extend({
  10. name: 'mouse',
  11. methods: {
  12. getDefaultMouseEventHandlers: function getDefaultMouseEventHandlers(suffix, getEvent) {
  13. var _getMouseEventHandler;
  14. return this.getMouseEventHandlers((_getMouseEventHandler = {}, _defineProperty(_getMouseEventHandler, 'click' + suffix, { event: 'click' }), _defineProperty(_getMouseEventHandler, 'contextmenu' + suffix, { event: 'contextmenu', prevent: true, result: false }), _defineProperty(_getMouseEventHandler, 'mousedown' + suffix, { event: 'mousedown' }), _defineProperty(_getMouseEventHandler, 'mousemove' + suffix, { event: 'mousemove' }), _defineProperty(_getMouseEventHandler, 'mouseup' + suffix, { event: 'mouseup' }), _defineProperty(_getMouseEventHandler, 'mouseenter' + suffix, { event: 'mouseenter' }), _defineProperty(_getMouseEventHandler, 'mouseleave' + suffix, { event: 'mouseleave' }), _defineProperty(_getMouseEventHandler, 'touchstart' + suffix, { event: 'touchstart' }), _defineProperty(_getMouseEventHandler, 'touchmove' + suffix, { event: 'touchmove' }), _defineProperty(_getMouseEventHandler, 'touchend' + suffix, { event: 'touchend' }), _getMouseEventHandler), getEvent);
  15. },
  16. getMouseEventHandlers: function getMouseEventHandlers(events, getEvent) {
  17. var _this = this;
  18. var on = {};
  19. var _loop = function _loop(event) {
  20. var eventOptions = events[event];
  21. if (!_this.$listeners[event]) return 'continue';
  22. // TODO somehow pull in modifiers
  23. var prefix = eventOptions.passive ? '&' : (eventOptions.once ? '~' : '') + (eventOptions.capture ? '!' : '');
  24. var key = prefix + eventOptions.event;
  25. var handler = function handler(e) {
  26. var mouseEvent = e;
  27. if (eventOptions.button === undefined || mouseEvent.buttons > 0 && mouseEvent.button === eventOptions.button) {
  28. if (eventOptions.prevent) {
  29. e.preventDefault();
  30. }
  31. if (eventOptions.stop) {
  32. e.stopPropagation();
  33. }
  34. _this.$emit(event, getEvent(e));
  35. }
  36. return eventOptions.result;
  37. };
  38. if (key in on) {
  39. if (Array.isArray(on[key])) {
  40. on[key].push(handler);
  41. } else {
  42. on[key] = [on[key], handler];
  43. }
  44. } else {
  45. on[key] = handler;
  46. }
  47. };
  48. for (var event in events) {
  49. var _ret = _loop(event);
  50. if (_ret === 'continue') continue;
  51. }
  52. return on;
  53. }
  54. }
  55. });
  56. //# sourceMappingURL=mouse.js.map