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

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