Changeset 35784 for main/trunk/model-interfaces-dev
- Timestamp:
- 2021-12-09T16:15:55+13:00 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/Snackbar.vue
r35756 r35784 50 50 51 51 export class SnackController { 52 /** 53 * The internal snack queue. Do not manipulate externally. 54 * @type {Array<{c: String, t: Number}>} 55 */ 52 56 static queue = []; 57 58 /** 59 * The Snackbar Vue component used by this controller. 60 */ 53 61 static bar = null; 62 63 /** 64 * A value defining whether or not a snackbar is active. Do not manipulate externally. 65 */ 54 66 static isActive = false; 55 67 68 /** 69 * Sets the Snackbar Vue component that this controller should use. 70 */ 56 71 static setBar(snackBar) { 57 72 this.bar = snackBar; 58 73 } 59 74 60 static addSnack(content) { 61 this.queue.push(content); 75 /** 76 * Adds a snack to the queue. 77 * @param {String} content The message of the snackbar. 78 * @param {Number} timeoutMS The time in milliseconds for which the snack will be displayed. 79 */ 80 static addSnack(content, timeoutMS = 3000) { 81 this.queue.push({ 82 c: content, 83 t: timeoutMS 84 }); 62 85 63 86 if (!this.isActive) { … … 66 89 } 67 90 91 /** 92 * Do not use this method externally. 93 */ 68 94 static eatSnacks() { 69 95 if (this.isActive || this.queue.length === 0) { … … 72 98 73 99 this.isActive = true; 74 this.bar.setContent(this.queue.shift()); 100 const { c, t } = this.queue.shift(); 101 this.bar.setContent(c, t); 75 102 76 103 setTimeout(function() { 77 104 SnackController.isActive = false; 78 105 SnackController.eatSnacks(); 79 }, 3500);106 }, t + 500); 80 107 } 81 108 }
Note:
See TracChangeset
for help on using the changeset viewer.