Skip to content

Instantly share code, notes, and snippets.

@chadwilken
Created April 12, 2018 02:05
Show Gist options
  • Save chadwilken/630621fe1147b6a1e8011008f5f2e017 to your computer and use it in GitHub Desktop.
Save chadwilken/630621fe1147b6a1e8011008f5f2e017 to your computer and use it in GitHub Desktop.
import { Controller } from 'stimulus';
export default class extends Controller {
static targets = ['message']
connect() {
this.timeout = setTimeout(this.closeFlash, 2500);
}
disconnect() {
clearTimeout(this.timeout);
}
closeFlash = () => {
this.flashBox.fadeOut(300, () => {
this.flashBox.remove();
});
}
get flashBox() {
return $(this.element);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment