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.

util.js 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getOffset = getOffset;
  6. exports.getContainer = getContainer;
  7. // Return target's cumulative offset from the top
  8. function getOffset(target) {
  9. if (typeof target === 'number') {
  10. return target;
  11. }
  12. var el = $(target);
  13. if (!el) {
  14. throw typeof target === 'string' ? new Error('Target element "' + target + '" not found.') : new TypeError('Target must be a Number/Selector/HTMLElement/VueComponent, received ' + type(target) + ' instead.');
  15. }
  16. var totalOffset = 0;
  17. while (el) {
  18. totalOffset += el.offsetTop;
  19. el = el.offsetParent;
  20. }
  21. return totalOffset;
  22. }
  23. function getContainer(container) {
  24. var el = $(container);
  25. if (el) return el;
  26. throw typeof container === 'string' ? new Error('Container element "' + container + '" not found.') : new TypeError('Container must be a Selector/HTMLElement/VueComponent, received ' + type(container) + ' instead.');
  27. }
  28. function type(el) {
  29. return el == null ? el : el.constructor.name;
  30. }
  31. function $(el) {
  32. if (typeof el === 'string') {
  33. return document.querySelector(el);
  34. } else if (el && el._isVue) {
  35. return el.$el;
  36. } else if (el instanceof HTMLElement) {
  37. return el;
  38. } else {
  39. return null;
  40. }
  41. }
  42. //# sourceMappingURL=util.js.map