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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 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; }
  2. import Vue from 'vue';
  3. export default Vue.extend({
  4. name: 'mouse',
  5. methods: {
  6. getDefaultMouseEventHandlers: function getDefaultMouseEventHandlers(suffix, getEvent) {
  7. var _getMouseEventHandler;
  8. 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);
  9. },
  10. getMouseEventHandlers: function getMouseEventHandlers(events, getEvent) {
  11. var _this = this;
  12. var on = {};
  13. var _loop = function _loop(event) {
  14. var eventOptions = events[event];
  15. if (!_this.$listeners[event]) return 'continue';
  16. // TODO somehow pull in modifiers
  17. var prefix = eventOptions.passive ? '&' : (eventOptions.once ? '~' : '') + (eventOptions.capture ? '!' : '');
  18. var key = prefix + eventOptions.event;
  19. var handler = function handler(e) {
  20. var mouseEvent = e;
  21. if (eventOptions.button === undefined || mouseEvent.buttons > 0 && mouseEvent.button === eventOptions.button) {
  22. if (eventOptions.prevent) {
  23. e.preventDefault();
  24. }
  25. if (eventOptions.stop) {
  26. e.stopPropagation();
  27. }
  28. _this.$emit(event, getEvent(e));
  29. }
  30. return eventOptions.result;
  31. };
  32. if (key in on) {
  33. if (Array.isArray(on[key])) {
  34. on[key].push(handler);
  35. } else {
  36. on[key] = [on[key], handler];
  37. }
  38. } else {
  39. on[key] = handler;
  40. }
  41. };
  42. for (var event in events) {
  43. var _ret = _loop(event);
  44. if (_ret === 'continue') continue;
  45. }
  46. return on;
  47. }
  48. }
  49. });
  50. //# sourceMappingURL=mouse.js.map