watchShow.js 596 B

1234567891011121314151617181920212223242526
  1. // eslint-disable-next-line no-undef
  2. export default Behavior({
  3. observers: {
  4. 'show': function (show) {
  5. show && this.changeStatus();
  6. if (!show) this.setData({
  7. status: show
  8. });
  9. }
  10. },
  11. methods: {
  12. changeStatus() {
  13. this.setData({
  14. status: true
  15. });
  16. if (this.data.timer) clearTimeout(this.data.timer);
  17. this.data.timer = setTimeout(() => {
  18. this.setData({
  19. status: false
  20. });
  21. if (this.data.success) this.data.success();
  22. this.data.timer = null;
  23. }, this.properties.duration);
  24. }
  25. }
  26. });