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.

delayable.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _vue = require('vue');
  6. var _vue2 = _interopRequireDefault(_vue);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. /**
  9. * Delayable
  10. *
  11. * @mixin
  12. *
  13. * Changes the open or close delay time for elements
  14. */
  15. exports.default = _vue2.default.extend().extend({
  16. name: 'delayable',
  17. props: {
  18. openDelay: {
  19. type: [Number, String],
  20. default: 0
  21. },
  22. closeDelay: {
  23. type: [Number, String],
  24. default: 0
  25. }
  26. },
  27. data: function data() {
  28. return {
  29. openTimeout: undefined,
  30. closeTimeout: undefined
  31. };
  32. },
  33. methods: {
  34. /**
  35. * Clear any pending delay timers from executing
  36. */
  37. clearDelay: function clearDelay() {
  38. clearTimeout(this.openTimeout);
  39. clearTimeout(this.closeTimeout);
  40. },
  41. /**
  42. * Runs callback after a specified delay
  43. */
  44. runDelay: function runDelay(type, cb) {
  45. var _this = this;
  46. this.clearDelay();
  47. var delay = parseInt(this[type + 'Delay'], 10);
  48. this[type + 'Timeout'] = setTimeout(cb || function () {
  49. _this.isActive = { open: true, close: false }[type];
  50. }, delay);
  51. }
  52. }
  53. });
  54. //# sourceMappingURL=delayable.js.map