Advertisement
Cool_boy21

Untitled

Jan 20th, 2020
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function updatePhotoContainer(t, e, s, n) {
  2.     const i = this.app.messages.get(this.messageId),
  3.         r = Math.min(.2 * innerWidth, 100),
  4.         a = Math.min(.6 * innerWidth, 380),
  5.         o = Math.min(1.2 * innerHeight, 60),
  6.         c = Math.min(.8 * innerHeight, 700),
  7.         h = e / t;
  8.     let l = Math.min(Math.max(t, r), a),
  9.         u = Math.min(Math.max(l * h, o), c);
  10.     l = u / h,
  11.         this.photoSvg.setAttribute("width", l),
  12.         this.photoSvg.setAttribute("height", u - (n && !n.isRoundMessage ? 2 : 0));
  13.     const d = Math.floor(1e8 * Math.random());
  14.     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>`),
  15.         this.photoImg = document.createElementNS("http://www.w3.org/2000/svg", "image"),
  16.         this.photoImg.setAttribute("width", l),
  17.         this.photoImg.setAttribute("height", u),
  18.         this.photoImg.setAttribute("preserveAspectRatio", "xMinYMin slice"),
  19.         n && n.isRoundMessage ? this.photoImg.setAttributeNS(null, "clip-path", "url(#message-circle)") : s && this.photoImg.setAttributeNS(null, "clip-path", `url(#clip${d})`),
  20.         this.photoSvg.appendChild(this.photoImg),
  21.         n && (this.videoFO = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject"),
  22.             this.videoFO.setAttribute("width", l),
  23.             this.videoFO.setAttribute("height", u),
  24.             this.videoFO.setAttribute("preserveAspectRatio", "xMinYMin slice"),
  25.             this.videoEl = document.createElement("video"),
  26.             this.videoEl.style.width = `${l}px`,
  27.             this.videoEl.style.height = `${u}px`,
  28.             this.videoEl.width = t,
  29.             this.videoEl.height = e,
  30.             this.videoEl.autoplay = !0,
  31.             this.videoEl.muted = !0,
  32.             this.videoEl.loop = !0,
  33.             this.videoFO.appendChild(this.videoEl),
  34.             n.isRoundMessage ? this.videoFO.setAttributeNS(null, "clip-path", "url(#message-circle)") : s && this.videoFO.setAttributeNS(null, "clip-path", `url(#clip${d})`),
  35.             this.photoSvg.appendChild(this.videoFO))
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement