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.

index.js 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  6. exports.default = goTo;
  7. var _easingPatterns = require('./easing-patterns');
  8. var easingPatterns = _interopRequireWildcard(_easingPatterns);
  9. var _util = require('./util');
  10. var _vue = require('vue');
  11. var _vue2 = _interopRequireDefault(_vue);
  12. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  14. function goTo(_target) {
  15. var _settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  16. var settings = _extends({
  17. container: document.scrollingElement || document.body || document.documentElement,
  18. duration: 500,
  19. offset: 0,
  20. easing: 'easeInOutCubic',
  21. appOffset: true
  22. }, _settings);
  23. var container = (0, _util.getContainer)(settings.container);
  24. if (settings.appOffset) {
  25. var isDrawer = container.classList.contains('v-navigation-drawer');
  26. var isClipped = container.classList.contains('v-navigation-drawer--clipped');
  27. settings.offset += _vue2.default.prototype.$vuetify.application.bar;
  28. if (!isDrawer || isClipped) settings.offset += _vue2.default.prototype.$vuetify.application.top;
  29. }
  30. var startTime = performance.now();
  31. var targetLocation = (0, _util.getOffset)(_target) - settings.offset;
  32. var startLocation = container.scrollTop;
  33. if (targetLocation === startLocation) return Promise.resolve(targetLocation);
  34. var ease = typeof settings.easing === 'function' ? settings.easing : easingPatterns[settings.easing];
  35. if (!ease) throw new TypeError('Easing function "' + settings.easing + '" not found.');
  36. // tslint:disable-next-line:promise-must-complete
  37. return new Promise(function (resolve) {
  38. return requestAnimationFrame(function step(currentTime) {
  39. var timeElapsed = currentTime - startTime;
  40. var progress = Math.abs(settings.duration ? Math.min(timeElapsed / settings.duration, 1) : 1);
  41. container.scrollTop = Math.floor(startLocation + (targetLocation - startLocation) * ease(progress));
  42. if (progress === 1 || container.clientHeight + container.scrollTop === container.scrollHeight) {
  43. return resolve(targetLocation);
  44. }
  45. requestAnimationFrame(step);
  46. });
  47. });
  48. }
  49. //# sourceMappingURL=index.js.map