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.

menu-position.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. /**
  6. * Menu position
  7. *
  8. * @mixin
  9. *
  10. * Used for calculating an automatic position (used for VSelect)
  11. * Will position the VMenu content properly over the VSelect
  12. */
  13. /* @vue/component */
  14. exports.default = {
  15. data: function data() {
  16. return {
  17. calculatedTopAuto: 0
  18. };
  19. },
  20. methods: {
  21. calcScrollPosition: function calcScrollPosition() {
  22. var $el = this.$refs.content;
  23. var activeTile = $el.querySelector('.v-list__tile--active');
  24. var maxScrollTop = $el.scrollHeight - $el.offsetHeight;
  25. return activeTile ? Math.min(maxScrollTop, Math.max(0, activeTile.offsetTop - $el.offsetHeight / 2 + activeTile.offsetHeight / 2)) : $el.scrollTop;
  26. },
  27. calcLeftAuto: function calcLeftAuto() {
  28. if (this.isAttached) return 0;
  29. return parseInt(this.dimensions.activator.left - this.defaultOffset * 2);
  30. },
  31. calcTopAuto: function calcTopAuto() {
  32. var $el = this.$refs.content;
  33. var activeTile = $el.querySelector('.v-list__tile--active');
  34. if (!activeTile) {
  35. this.selectedIndex = null;
  36. }
  37. if (this.offsetY || !activeTile) {
  38. return this.computedTop;
  39. }
  40. this.selectedIndex = Array.from(this.tiles).indexOf(activeTile);
  41. var tileDistanceFromMenuTop = activeTile.offsetTop - this.calcScrollPosition();
  42. var firstTileOffsetTop = $el.querySelector('.v-list__tile').offsetTop;
  43. return this.computedTop - tileDistanceFromMenuTop - firstTileOffsetTop;
  44. }
  45. }
  46. };
  47. //# sourceMappingURL=menu-position.js.map