feat(EpisodeOptions): loading icon
This commit is contained in:
31
assets/controllers/loading_icon_controller.js
Normal file
31
assets/controllers/loading_icon_controller.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
/*
|
||||
* The following line makes this controller "lazy": it won't be downloaded until needed
|
||||
* See https://github.com/symfony/stimulus-bridge#lazy-controllers
|
||||
*/
|
||||
/* stimulusFetch: 'lazy' */
|
||||
export default class extends Controller {
|
||||
static values = {
|
||||
total: Number,
|
||||
count: Number,
|
||||
}
|
||||
|
||||
static targets = ['icon']
|
||||
|
||||
connect() {
|
||||
|
||||
}
|
||||
|
||||
toggleIcon() {
|
||||
this.iconTarget.classList.toggle('hidden');
|
||||
}
|
||||
|
||||
increaseCount() {
|
||||
this.countValue += 1;
|
||||
if (this.countValue === this.totalValue) {
|
||||
this.toggleIcon();
|
||||
this.countValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user