Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function updatePhotoContainer(t, e, s, n) {
- const i = this.app.messages.get(this.messageId),
- r = Math.min(.2 * innerWidth, 100),
- a = Math.min(.6 * innerWidth, 380),
- o = Math.min(1.2 * innerHeight, 60),
- c = Math.min(.8 * innerHeight, 700),
- h = e / t;
- let l = Math.min(Math.max(t, r), a),
- u = Math.min(Math.max(l * h, o), c);
- l = u / h,
- this.photoSvg.setAttribute("width", l),
- this.photoSvg.setAttribute("height", u - (n && !n.isRoundMessage ? 2 : 0));
- const d = Math.floor(1e8 * Math.random());
- s && (i.isPost || this.isSelf || i.fwdFrom ? this.photoSvg.innerHTML = `<defs><clipPath id="clip${d}"><rect width="${l}" height="${u}" rx="12" /></clipPath></defs>` : i.isOut ? this.photoSvg.innerHTML = `<defs><clipPath id="clip${d}">\n <use href="#message-tail" transform="translate(${l - 2}, ${u}) scale(-1, -1)"/>\n <rect width="12" height="12" x="${l - 21}" y="${u - 12}"/><rect width="${l - 9}" height="${u}" rx="12" />\n </clipPath></defs>` : this.photoSvg.innerHTML = `<defs><clipPath id="clip${d}">\n <use href="#message-tail" transform="translate(2, ${u}) scale(1, -1)"/>\n <rect width="12" height="12" x="9" y="${u - 12}"/><rect width="${l - 9}" height="${u}" x="9" rx="12" />\n </clipPath></defs>`),
- this.photoImg = document.createElementNS("http://www.w3.org/2000/svg", "image"),
- this.photoImg.setAttribute("width", l),
- this.photoImg.setAttribute("height", u),
- this.photoImg.setAttribute("preserveAspectRatio", "xMinYMin slice"),
- n && n.isRoundMessage ? this.photoImg.setAttributeNS(null, "clip-path", "url(#message-circle)") : s && this.photoImg.setAttributeNS(null, "clip-path", `url(#clip${d})`),
- this.photoSvg.appendChild(this.photoImg),
- n && (this.videoFO = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject"),
- this.videoFO.setAttribute("width", l),
- this.videoFO.setAttribute("height", u),
- this.videoFO.setAttribute("preserveAspectRatio", "xMinYMin slice"),
- this.videoEl = document.createElement("video"),
- this.videoEl.style.width = `${l}px`,
- this.videoEl.style.height = `${u}px`,
- this.videoEl.width = t,
- this.videoEl.height = e,
- this.videoEl.autoplay = !0,
- this.videoEl.muted = !0,
- this.videoEl.loop = !0,
- this.videoFO.appendChild(this.videoEl),
- n.isRoundMessage ? this.videoFO.setAttributeNS(null, "clip-path", "url(#message-circle)") : s && this.videoFO.setAttributeNS(null, "clip-path", `url(#clip${d})`),
- this.photoSvg.appendChild(this.videoFO))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement