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

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