()
| 17 | |
| 18 | export class Lightbox { |
| 19 | constructor() { |
| 20 | this.el = $$el("div", "", { |
| 21 | parent: document.body, |
| 22 | onclick: (e) => { |
| 23 | e.stopImmediatePropagation(); |
| 24 | this.close(); |
| 25 | }, |
| 26 | style: { |
| 27 | display: "none", |
| 28 | opacity: 0, |
| 29 | }, |
| 30 | }); |
| 31 | this.closeBtn = $$el("div", "close", { |
| 32 | parent: this.el, |
| 33 | }); |
| 34 | this.prev = $$el("div", "prev", { |
| 35 | parent: this.el, |
| 36 | onclick: (e) => { |
| 37 | this.update(-1); |
| 38 | e.stopImmediatePropagation(); |
| 39 | }, |
| 40 | }); |
| 41 | this.main = $$el("div", "main", { |
| 42 | parent: this.el, |
| 43 | }); |
| 44 | this.next = $$el("div", "next", { |
| 45 | parent: this.el, |
| 46 | onclick: (e) => { |
| 47 | this.update(1); |
| 48 | e.stopImmediatePropagation(); |
| 49 | }, |
| 50 | }); |
| 51 | this.link = $$el("a", "link", { |
| 52 | parent: this.main, |
| 53 | target: "_blank", |
| 54 | }); |
| 55 | this.spinner = createSpinner(); |
| 56 | this.link.appendChild(this.spinner); |
| 57 | this.img = $$el("img", "img", { |
| 58 | style: { |
| 59 | opacity: 0, |
| 60 | }, |
| 61 | parent: this.link, |
| 62 | onclick: (e) => { |
| 63 | e.stopImmediatePropagation(); |
| 64 | }, |
| 65 | onwheel: (e) => { |
| 66 | if (!(e instanceof WheelEvent) || e.ctrlKey) { |
| 67 | return; |
| 68 | } |
| 69 | const direction = Math.sign(e.deltaY); |
| 70 | this.update(direction); |
| 71 | }, |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | close() { |
| 76 | ani( |
nothing calls this directly
no test coverage detected