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.

VHover.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Mixins
  2. import Delayable from '../../mixins/delayable';
  3. import Toggleable from '../../mixins/toggleable';
  4. // Utilities
  5. import mixins from '../../util/mixins';
  6. import { consoleWarn } from '../../util/console';
  7. export default mixins(Delayable, Toggleable
  8. /* @vue/component */
  9. ).extend({
  10. name: 'v-hover',
  11. props: {
  12. disabled: {
  13. type: Boolean,
  14. default: false
  15. },
  16. value: {
  17. type: Boolean,
  18. default: undefined
  19. }
  20. },
  21. methods: {
  22. onMouseEnter: function onMouseEnter() {
  23. this.runDelay('open');
  24. },
  25. onMouseLeave: function onMouseLeave() {
  26. this.runDelay('close');
  27. }
  28. },
  29. render: function render() {
  30. if (!this.$scopedSlots.default && this.value === undefined) {
  31. consoleWarn('v-hover is missing a default scopedSlot or bound value', this);
  32. return null;
  33. }
  34. var element = void 0;
  35. if (this.$scopedSlots.default) {
  36. element = this.$scopedSlots.default({ hover: this.isActive });
  37. } else if (this.$slots.default && this.$slots.default.length === 1) {
  38. element = this.$slots.default[0];
  39. }
  40. if (Array.isArray(element) && element.length === 1) {
  41. element = element[0];
  42. }
  43. if (!element || Array.isArray(element) || !element.tag) {
  44. consoleWarn('v-hover should only contain a single element', this);
  45. return element;
  46. }
  47. if (!this.disabled) {
  48. element.data = element.data || {};
  49. this._g(element.data, {
  50. mouseenter: this.onMouseEnter,
  51. mouseleave: this.onMouseLeave
  52. });
  53. }
  54. return element;
  55. }
  56. });
  57. //# sourceMappingURL=VHover.js.map