1
0
postdoc/app/javascript/controllers/modal_controller.js
2020-12-06 21:05:11 +01:00

38 lines
677 B
JavaScript

import { Controller } from "stimulus"
export default class extends Controller {
static targets = [ "modal" ]
connect() {
}
closeClickedOutside(event) {
if (this.mouseClickDownTarget != this.mouseClickUpTarget) {
return;
}
if (event.srcElement == this.modalTarget) {
this.close();
}
}
close(event) {
this.modalTarget.remove();
}
error() {
this.modalTarget.classList.add("shake");
setTimeout(() => {
this.modalTarget.classList.remove("shake");
}, 1000)
}
trackMouseDown(event) {
this.mouseClickDownTarget = event.target
}
trackMouseUp(event) {
this.mouseClickUpTarget = event.target
}
}