index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { __awaiter, __generator } from "tslib";
  2. import { Component, triggerEvent, triggerEventOnly } from '../_util/simply';
  3. import { GuideTourDefaultProps } from './props';
  4. import mixinValue from '../mixins/value';
  5. Component(GuideTourDefaultProps, {
  6. onNext: function () {
  7. return __awaiter(this, void 0, void 0, function () {
  8. var currentValue, newCurrent;
  9. return __generator(this, function (_a) {
  10. currentValue = this.getValue();
  11. newCurrent = currentValue + 1;
  12. if (!this.isControlled()) {
  13. this.update(newCurrent);
  14. }
  15. triggerEvent(this, 'change', newCurrent);
  16. return [2 /*return*/];
  17. });
  18. });
  19. },
  20. onPrev: function () {
  21. return __awaiter(this, void 0, void 0, function () {
  22. var currentValue, newCurrent;
  23. return __generator(this, function (_a) {
  24. currentValue = this.getValue();
  25. newCurrent = currentValue - 1;
  26. if (!this.isControlled()) {
  27. this.update(newCurrent);
  28. }
  29. triggerEvent(this, 'change', newCurrent);
  30. return [2 /*return*/];
  31. });
  32. });
  33. },
  34. onCancel: function () {
  35. triggerEventOnly(this, 'cancel');
  36. },
  37. onSwiperChange: function (e) {
  38. return __awaiter(this, void 0, void 0, function () {
  39. var current;
  40. return __generator(this, function (_a) {
  41. current = e.detail.current;
  42. if (!this.isControlled()) {
  43. this.update(current);
  44. }
  45. triggerEvent(this, 'change', current);
  46. return [2 /*return*/];
  47. });
  48. });
  49. },
  50. }, undefined, [
  51. mixinValue({
  52. valueKey: 'current',
  53. defaultValueKey: 'defaultCurrent',
  54. }),
  55. ]);