{"id":359919,"date":"2024-05-21T00:42:33","date_gmt":"2024-05-21T00:42:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=359919"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=359919","title":{"rendered":"<span>\u0423\u0440\u043e\u043a\u0438 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043f\u0430\u0440\u0441\u0438\u043b dom \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u0434\u043b\u044f \u043d\u0438\u0445 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443. \u0420\u0430\u0437\u0431\u0435\u0440\u0443 \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e. \u0421\u043f\u043e\u0439\u043b\u0435\u0440, \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e. <\/p>\n<p>\u0417\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u043d\u0430 \u0447\u0451\u043c \u044f \u0441\u043f\u043e\u0442\u043a\u043d\u0443\u043b\u0441\u044f, \u043f\u043e\u043a\u0430 \u044d\u0442\u043e \u043f\u0438\u0441\u0430\u043b. \u041f\u0440\u043e \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0431\u043b\u043e\u043a\u0430. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d61\/791\/dce\/d61791dce0a61d6a470380b5e55c6398.png\" width=\"951\" height=\"80\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d61\/791\/dce\/d61791dce0a61d6a470380b5e55c6398.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u044d\u043f\u043e\u043f\u0435\u044e. \u0412\u043e\u0442 \u0432\u0432\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f: <a href=\"https:\/\/habr.com\/ru\/articles\/773310\/\" rel=\"noopener noreferrer nofollow\">\u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0430\u0440\u0441\u0435\u0440 web \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \/ \u0425\u0430\u0431\u0440 (habr.com)<\/a>  <\/p>\n<h2>\u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (PageManager)<\/h2>\n<p>\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c addEventListener \u0438 \u0434\u0430\u0432\u0430\u0442\u044c \u0435\u043c\u0443 \u0431\u0435\u0441\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u0434 \u2014 \u0443\u0436\u0430\u0441\u043d\u0430\u044f \u0437\u0430\u0442\u0435\u044f. \u0420\u0430\u0441\u0447\u0451\u0442\u044b \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0438 \u0438\u0445 \u043c\u043d\u043e\u0433\u043e. <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u0439\u0442\u0438 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e, \u0430 \u0435\u0441\u043b\u0438 \u044d\u0432\u0435\u043d\u0442\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0448\u0443\u044e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044c.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0438\u043d\u044f\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c activeBlock \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c event \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0431\u043b\u043e\u043a\u0430. <\/p>\n<pre><code class=\"javascript\">if (!this.sameBlock(currentBlock, this.#activeBlock)) {   ... }<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 PageManager&#8217;\u0430. \u0421\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u041e\u043d \u0436\u0435 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443 \u0431\u043b\u043e\u043a\u043e\u0432?<\/p>\n<pre><code>const highlighting = new BlockHighlighting(this.#activeBlock); highlighting.draw();<\/code><\/pre>\n<p>\u041e\u0431\u044a\u044f\u0441\u043d\u044e. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u0430 \u043d\u0435 \u0431\u043b\u043e\u043a\u0443, \u0430 \u0441\u043b\u043e\u0432\u0430\u043c. \u041f\u0440\u0438\u0447\u0451\u043c \u043d\u0435 \u0432\u0441\u0435\u043c, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0442\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u041d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u044f \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u044e \u0431\u043b\u043e\u043a? <\/p>\n<p>\u0414\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \ud83d\ude42 <\/p>\n<p>\u0420\u0430\u043d\u0435\u0435 \u044f \u0443\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0431\u043b\u043e\u043a \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438. <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1f3\/cd0\/d87\/1f3cd0d87242a6c2df5e0a6df8973c19.png\" width=\"457\" height=\"411\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1f3\/cd0\/d87\/1f3cd0d87242a6c2df5e0a6df8973c19.png\"\/><\/figure>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u0447\u0435\u0441\u0442\u043d\u043e, \u0432 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043d\u0430\u0447\u0430\u043b \u0432 \u043d\u0438\u0445 \u043f\u0443\u0442\u0430\u0442\u044c\u0441\u044f \u0438 \u0442\u0435\u0440\u044f\u0442\u044c\u0441\u044f. \u0422\u043e\u0433\u0434\u0430 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e &#8212; \u043d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435. \u0412\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u044d\u0442\u0438 \u0431\u043b\u043e\u043a\u0438 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f, \u0442\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441? <\/p>\n<p>\u0418\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"javascript\">export class PageManager {      \/\/ element \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043d     #activeBlock;      run = () => {         \/\/\u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0443\u0442 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443         addEventListener(\"mousemove\", this.#onmousemove);     }      #onmousemove = (event) => {         \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u0431\u043b\u043e\u043a\u0430 \u0438 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 dom element          const currentBlock = this.#whereWeAre(event);         \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043f\u0430\u0440\u0441\u0438\u043c \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435, \u0441\u0436\u0438\u0440\u0430\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u044b         if (!this.#sameBlock(currentBlock, this.#activeBlock)) {             \/\/ \u0420\u0430\u0437 \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0431\u043b\u043e\u043a\u0435, \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0431\u043b\u043e\u043a             this.#activeBlock = currentBlock;             \/\/ \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0440\u0438\u0441\u0443\u0435\u043c \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442             const highlighting = new BlockHighlighting(this.#activeBlock);             highlighting.draw();         }     }      #sameBlock = (currentFocusBlock, activeBlock) => {         \/\/ \u041f\u0440\u043e\u0432\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u044d\u0442\u043e \u0443 \u043d\u0430\u0441 \u043d\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a + \u0441\u0430\u043c\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \"sameBlock\"         return (currentFocusBlock &amp;&amp; activeBlock) &amp;&amp; currentFocusBlock.getRef() === activeBlock.getRef();     }      #whereWeAre = (event) => {         \/\/ FocusBlock \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0434\u0430\u043b\u044c\u0448\u0435.          return new FocusBlock(event);     } }<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5e9\/d48\/bd1\/5e9d48bd1894927087cd6e0798abd2a7.png\" width=\"956\" height=\"97\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5e9\/d48\/bd1\/5e9d48bd1894927087cd6e0798abd2a7.png\"\/><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u044b\u0448\u0435, \u0431\u043b\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0443\u0436\u0435 \u0432\u0437\u044f\u0442 \u0432 \u0444\u043e\u043a\u0443\u0441. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0432\u0438\u0442\u044c \u044d\u0432\u0435\u043d\u0442\u0438\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u041f\u0440\u043e \u044d\u0442\u043e \u043a\u0430\u043a \u043d\u0438 \u0431\u0443\u0434\u044c \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445. <\/p>\n<h2>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0431\u043b\u043e\u043a\u043e\u0432<\/h2>\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b. \u0422\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0435\u043c\u0430, \u0432\u0441\u0451 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e. \u0411\u0435\u0440\u0438 offsetLeft, offsetTop \u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u0431\u0435 \u0441\u0447\u0430\u0441\u0442\u044c\u0435, \u043d\u043e \u043d\u0435\u0442.<\/p>\n<p>\u041d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u043d\u0435 \u0432\u0435\u0437\u0434\u0435. \u0412\u043e\u0442 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0440\u0435\u0439\u0441\u043a\u0438\u0439 naver: <\/p>\n<pre><code>        const x = this.#ref.offsetLeft;         const y = this.#ref.offsetTop;         this.#position = {x, y}<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5c9\/c4d\/478\/5c9c4d47880df59ba054bd46198f6222.png\" alt=\"\" title=\"\" width=\"847\" height=\"776\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5c9\/c4d\/478\/5c9c4d47880df59ba054bd46198f6222.png\"\/><\/figure>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043b &#8212; \u043c\u044b \u0442\u0435\u0440\u044f\u0435\u043c offset \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439. \u0418 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u0440\u0430\u0432. \u0427\u0430\u0441\u0442\u0438\u0447\u043d\u043e.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0439\u0434\u0451\u0442\u0441\u044f \u043f\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0443:<\/p>\n<pre><code>        let parent = this.#ref.offsetParent;         while (parent &amp;&amp; parent.offsetParent) {             parent = parent.offsetParent;             this.#position.x += parent.offsetLeft;             this.#position.y += parent.offsetTop;         }<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ee\/628\/1ad\/1ee6281ad9a8c7998ec5e9f702995fd0.png\" width=\"905\" height=\"694\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ee\/628\/1ad\/1ee6281ad9a8c7998ec5e9f702995fd0.png\"\/><\/figure>\n<p>\u041c\u043c\u043c&#8230; \u041f\u043e\u0447\u0442\u0438 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0415\u0441\u0442\u044c \u0435\u0449\u0451 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438. <\/p>\n<p>\u041f\u0440\u043e\u0431\u0443\u044e \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c padding, margin&#8230; \u0412\u0438\u0436\u0443 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043d\u0443\u043b\u0438 \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u0438.<\/p>\n<ul>\n<li>\n<p>padding-top: 0px<\/p>\n<\/li>\n<li>\n<p>margin-top: 0px<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043d\u0438\u043c\u0430\u044e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 vw, wh \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u044b, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a \u0441\u0435\u0431\u0435. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438 \u0438 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043e\u0442\u043c\u0435\u0442\u0430\u044e. \u0418\u0434\u0443 \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. <\/p>\n<p>\u0418 \u043e\u043d\u043e \u0435\u0441\u0442\u044c! getBoundingClientRect:<\/p>\n<pre><code>        const x = this.#rect.x + window.scrollX;         const y = this.#rect.y + window.scrollY;         this.#position = {x, y}<\/code><\/pre>\n<p>\u042d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u044f \u0443\u0436\u0435 \u043f\u0438\u0448\u0443 \u0441 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043e\u0447\u043a\u043e\u0439 \ud83d\ude42<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/466\/0fe\/2f4\/4660fe2f4db6f0394bc74de1e4fbe4ff.png\" width=\"966\" height=\"213\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/466\/0fe\/2f4\/4660fe2f4db6f0394bc74de1e4fbe4ff.png\"\/><\/figure>\n<p>\u0418 \u043d\u0430 naver \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a70\/5aa\/653\/a705aa653e6db6906c78e50f624669dc.png\" width=\"724\" height=\"631\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a70\/5aa\/653\/a705aa653e6db6906c78e50f624669dc.png\"\/><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"javascript\">export class FocusBlock {      #ref;     #size;     #position;      #rect;      constructor(event) {         this.#ref = event.target;         this.#rect = this.#ref.getBoundingClientRect();         this.#setupSize();         this.#setupPosition();     }      #setupPosition = () => {         const x = this.#rect.x + window.scrollX;         const y = this.#rect.y + window.scrollY;         this.#position = {x, y}     }      #setupSize = () => {         const width = this.#rect.width;         const height = this.#rect.height;         this.#size = {width, height}     }      getRef = () => {         return this.#ref;     }      getSize = () => {         return this.#size;     }      getPosition = () => {         return this.#position;     } <\/code><\/pre>\n<h2>\u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0438 (BlockHighlighting)<\/h2>\n<p>\u041d\u0443 \u0438 \u043d\u0430 \u0434\u043e\u0431\u0438\u0432\u043e\u0447\u043a\u0443. \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u0431\u043b\u043e\u043a\u0430. \u0420\u0430\u0437\u0431\u0435\u0440\u0443 \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043f\u0430\u0440\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u043a \u0442\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e. <\/p>\n<p>\u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u044f \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 dom element \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>static draw;<\/code> \u0421\u0442\u0430\u0442\u0438\u043a\u0430 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0442\u043e\u0447\u043d\u043e \u0431\u044b\u043b \u043e\u0434\u0438\u043d. \u041d\u0430\u043f\u043b\u043e\u0434\u0438\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u043b\u0438\u0448\u043d\u0438\u0445 div \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 &#8212; \u043e\u0447\u0435\u043d\u044c \u0442\u0430\u043a \u0441\u0435\u0431\u0435 \u0438\u0434\u0435\u044f. <\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u0435\u0439\u0447\u0430\u0441 \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u0443\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0441\u043b\u043e\u0432. \u0422\u0435\u043c\u0430 \u043c\u043d\u0435 \u043d\u0430 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c. \u0412\u0438\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c \u0432 PageManager. <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<pre><code class=\"javascript\">if (BlockHighlighting.draw) {     window.document.body.removeChild(BlockHighlighting.draw); }<\/code><\/pre>\n<p>\u0423\u0434\u0430\u043b\u044f\u0435\u043c draw \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u0431\u043b\u043e\u043a\u0430. \u0422\u043e \u0431\u0438\u0448\u044c, \u043a\u043e\u0433\u0434\u0430 \u0431\u043b\u043e\u043a \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438 block. \u0410 \u0432\u043e\u0442 \u0437\u0430\u0447\u0435\u043c:<\/p>\n<pre><code class=\"javascript\">BlockHighlighting.draw.style.left = `${this.#block.getPosition().x}px`; BlockHighlighting.draw.style.top = `${this.#block.getPosition().y}px`; BlockHighlighting.draw.style.width = `${this.#block.getSize().width}px`; BlockHighlighting.draw.style.height = `${this.#block.getSize().height}px`;<\/code><\/pre>\n<p>\u0412\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u043c\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0448\u0430\u0433\u0435, \u0442\u0443\u0442 \u043d\u0430\u043c \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430\u0448 \u043d\u043e\u0432\u0435\u043d\u044c\u043a\u0438\u0439 div. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d, \u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043c\u044b \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u043c. \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430 naver.<\/p>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446:<\/p>\n<pre><code>BlockHighlighting.draw.style.pointerEvents = \"none\";<\/code><\/pre>\n<p>\u041c\u044b \u0436\u0435 \u043d\u0435 \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 EventListener \u0441\u043b\u043e\u0432\u0438\u043b \u0431\u044d\u0434 \u0442\u0440\u0438\u043f \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043f\u0441\u0435\u0432\u0434\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430? \u0422\u0430\u043a \u0432\u043e\u0442, \u043c\u044b \u0435\u0433\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c. \u041f\u0430\u0440\u0441\u0438\u0442\u044c draw &#8212; \u043d\u0435 \u0431\u0443\u0434\u0435\u043c. \u041d\u0443 \u0438 \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u0448\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u043f\u0440\u0435\u0433\u0440\u0430\u0436\u0434\u0430\u044f \u0435\u043c\u0443 \u043f\u0443\u0442\u044c \u0434\u043e \u0437\u0430\u0432\u0435\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u0447\u0435\u043a \u0438 \u043a\u043d\u043e\u043f\u043e\u0447\u0435\u043a. <\/p>\n<p>\u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"javascript\">export class BlockHighlighting {      static draw;     #block;      constructor(block) {         this.#block = block;     }      draw = () => {         if (BlockHighlighting.draw) {             window.document.body.removeChild(BlockHighlighting.draw);         }         BlockHighlighting.draw = window.document.createElement(\"div\");         BlockHighlighting.draw.style.left = `${this.#block.getPosition().x}px`;         BlockHighlighting.draw.style.top = `${this.#block.getPosition().y}px`;         BlockHighlighting.draw.style.width = `${this.#block.getSize().width}px`;         BlockHighlighting.draw.style.height = `${this.#block.getSize().height}px`;         BlockHighlighting.draw.style.position = \"absolute\";         BlockHighlighting.draw.style.background = \"red\";         BlockHighlighting.draw.style.zIndex = \"1000\";         BlockHighlighting.draw.style.opacity = \"0.25\";         BlockHighlighting.draw.style.pointerEvents = \"none\";         window.document.body.appendChild(BlockHighlighting.draw);     } }<\/code><\/pre>\n<p>\u042f \u043e\u0431\u0435\u0449\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441\u043b\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u0421\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u0430 \u043f\u043e\u0434\u0432\u043e\u0434\u043e\u0447\u043a\u0430. \u0421\u0430\u043c \u043a\u043e\u0434 \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0441\u043b\u043e\u0432 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0433\u0440\u044f\u0437\u043d\u044b\u0439 \u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0431\u043b\u043e\u043a\u043e\u0432 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u043d\u0435 \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0441\u043b\u043e\u0432\u0430 \u0432 \u0444\u043e\u043a\u0443\u0441\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0447\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0441\u044e\u0434\u0430. <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0451. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0442\u0443\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043e\u0447\u043a\u0430 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/773330\/\"> https:\/\/habr.com\/ru\/articles\/773330\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u043f\u0430\u0440\u0441\u0438\u043b dom \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u0434\u043b\u044f \u043d\u0438\u0445 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443. \u0420\u0430\u0437\u0431\u0435\u0440\u0443 \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0438 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d\u043e. \u0421\u043f\u043e\u0439\u043b\u0435\u0440, \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e. <\/p>\n<p>\u0417\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u043d\u0430 \u0447\u0451\u043c \u044f \u0441\u043f\u043e\u0442\u043a\u043d\u0443\u043b\u0441\u044f, \u043f\u043e\u043a\u0430 \u044d\u0442\u043e \u043f\u0438\u0441\u0430\u043b. \u041f\u0440\u043e \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0431\u043b\u043e\u043a\u0430. <\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e \u044d\u043f\u043e\u043f\u0435\u044e. \u0412\u043e\u0442 \u0432\u0432\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f: <a href=\"https:\/\/habr.com\/ru\/articles\/773310\/\" rel=\"noopener noreferrer nofollow\">\u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u0430\u0440\u0441\u0435\u0440 web \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \/ \u0425\u0430\u0431\u0440 (habr.com)<\/a>  <\/p>\n<h2>\u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (PageManager)<\/h2>\n<p>\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c addEventListener \u0438 \u0434\u0430\u0432\u0430\u0442\u044c \u0435\u043c\u0443 \u0431\u0435\u0441\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u0434 \u2014 \u0443\u0436\u0430\u0441\u043d\u0430\u044f \u0437\u0430\u0442\u0435\u044f. \u0420\u0430\u0441\u0447\u0451\u0442\u044b \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0438 \u0438\u0445 \u043c\u043d\u043e\u0433\u043e. <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u0439\u0442\u0438 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e, \u0430 \u0435\u0441\u043b\u0438 \u044d\u0432\u0435\u043d\u0442\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0448\u0443\u044e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044c.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0440\u0438\u043d\u044f\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c activeBlock \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c event \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0431\u043b\u043e\u043a\u0430. <\/p>\n<pre><code class=\"javascript\">if (!this.sameBlock(currentBlock, this.#activeBlock)) {   ... }<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 PageManager&#8217;\u0430. \u0421\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u041e\u043d \u0436\u0435 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443 \u0431\u043b\u043e\u043a\u043e\u0432?<\/p>\n<pre><code>const highlighting = new BlockHighlighting(this.#activeBlock); highlighting.draw();<\/code><\/pre>\n<p>\u041e\u0431\u044a\u044f\u0441\u043d\u044e. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u0430 \u043d\u0435 \u0431\u043b\u043e\u043a\u0443, \u0430 \u0441\u043b\u043e\u0432\u0430\u043c. \u041f\u0440\u0438\u0447\u0451\u043c \u043d\u0435 \u0432\u0441\u0435\u043c, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0442\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c. \u041d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u044f \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u044e \u0431\u043b\u043e\u043a? <\/p>\n<p>\u0414\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \ud83d\ude42 <\/p>\n<p>\u0420\u0430\u043d\u0435\u0435 \u044f \u0443\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0431\u043b\u043e\u043a \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438. <\/p>\n<figure class=\"\"><\/figure>\n<p>\u0418 \u0435\u0441\u043b\u0438 \u0447\u0435\u0441\u0442\u043d\u043e, \u0432 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043d\u0430\u0447\u0430\u043b \u0432 \u043d\u0438\u0445 \u043f\u0443\u0442\u0430\u0442\u044c\u0441\u044f \u0438 \u0442\u0435\u0440\u044f\u0442\u044c\u0441\u044f. \u0422\u043e\u0433\u0434\u0430 \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e &#8212; \u043d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435. \u0412\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u044d\u0442\u0438 \u0431\u043b\u043e\u043a\u0438 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f, \u0442\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441? <\/p>\n<p>\u0418\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"javascript\">export class PageManager {      \/\/ element \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043d     #activeBlock;      run = () => {         \/\/\u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0443\u0442 \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443         addEventListener(\"mousemove\", this.#onmousemove);     }      #onmousemove = (event) => {         \/\/ \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u0431\u043b\u043e\u043a\u0430 \u0438 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 dom element          const currentBlock = this.#whereWeAre(event);         \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043f\u0430\u0440\u0441\u0438\u043c \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435, \u0441\u0436\u0438\u0440\u0430\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u044b         if (!this.#sameBlock(currentBlock, this.#activeBlock)) {             \/\/ \u0420\u0430\u0437 \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0431\u043b\u043e\u043a\u0435, \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0431\u043b\u043e\u043a             this.#activeBlock = currentBlock;             \/\/ \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0440\u0438\u0441\u0443\u0435\u043c \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442             const highlighting = new BlockHighlighting(this.#activeBlock);             highlighting.draw();         }     }      #sameBlock = (currentFocusBlock, activeBlock) => {         \/\/ \u041f\u0440\u043e\u0432\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u044d\u0442\u043e \u0443 \u043d\u0430\u0441 \u043d\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a + \u0441\u0430\u043c\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \"sameBlock\"         return (currentFocusBlock &amp;&amp; activeBlock) &amp;&amp; currentFocusBlock.getRef() === activeBlock.getRef();     }      #whereWeAre = (event) => {         \/\/ FocusBlock \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0434\u0430\u043b\u044c\u0448\u0435.          return new FocusBlock(event);     } }<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u044b\u0448\u0435, \u0431\u043b\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0443\u0436\u0435 \u0432\u0437\u044f\u0442 \u0432 \u0444\u043e\u043a\u0443\u0441. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0432\u0438\u0442\u044c \u044d\u0432\u0435\u043d\u0442\u0438\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u041f\u0440\u043e \u044d\u0442\u043e \u043a\u0430\u043a \u043d\u0438 \u0431\u0443\u0434\u044c \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445. <\/p>\n<h2>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0431\u043b\u043e\u043a\u043e\u0432<\/h2>\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b. \u0422\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0435\u043c\u0430, \u0432\u0441\u0451 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e. \u0411\u0435\u0440\u0438 offsetLeft, offsetTop \u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u0431\u0435 \u0441\u0447\u0430\u0441\u0442\u044c\u0435, \u043d\u043e \u043d\u0435\u0442.<\/p>\n<p>\u041d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u043e \u043d\u0435 \u0432\u0435\u0437\u0434\u0435. \u0412\u043e\u0442 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0440\u0435\u0439\u0441\u043a\u0438\u0439 naver: <\/p>\n<pre><code>        const x = this.#ref.offsetLeft;         const y = this.#ref.offsetTop;         this.#position = {x, y}<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043b &#8212; \u043c\u044b \u0442\u0435\u0440\u044f\u0435\u043c offset \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439. \u0418 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043f\u0440\u0430\u0432. \u0427\u0430\u0441\u0442\u0438\u0447\u043d\u043e.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0439\u0434\u0451\u0442\u0441\u044f \u043f\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0443:<\/p>\n<pre><code>        let parent = this.#ref.offsetParent;         while (parent &amp;&amp; parent.offsetParent) {             parent = parent.offsetParent;             this.#position.x += parent.offsetLeft;             this.#position.y += parent.offsetTop;         }<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u041c\u043c\u043c&#8230; \u041f\u043e\u0447\u0442\u0438 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0415\u0441\u0442\u044c \u0435\u0449\u0451 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438. <\/p>\n<p>\u041f\u0440\u043e\u0431\u0443\u044e \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c padding, margin&#8230; \u0412\u0438\u0436\u0443 \u044d\u0442\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u043d\u0443\u043b\u0438 \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u0438.<\/p>\n<ul>\n<li>\n<p>padding-top: 0px<\/p>\n<\/li>\n<li>\n<p>margin-top: 0px<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043d\u0438\u043c\u0430\u044e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 vw, wh \u0438\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u044b, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a \u0441\u0435\u0431\u0435. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u0438 \u0438 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043e\u0442\u043c\u0435\u0442\u0430\u044e. \u0418\u0434\u0443 \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. <\/p>\n<p>\u0418 \u043e\u043d\u043e \u0435\u0441\u0442\u044c! getBoundingClientRect:<\/p>\n<pre><code>        const x = this.#rect.x + window.scrollX;         const y = this.#rect.y + window.scrollY;         this.#position = {x, y}<\/code><\/pre>\n<p>\u042d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u044f \u0443\u0436\u0435 \u043f\u0438\u0448\u0443 \u0441 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043e\u0447\u043a\u043e\u0439 \ud83d\ude42<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0418 \u043d\u0430 naver \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"javascript\">export class FocusBlock {      #ref;     #size;     #position;      #rect;      constructor(event) {         this.#ref = event.target;         this.#rect = this.#ref.getBoundingClientRect();         this.#setupSize();         this.#setupPosition();     }      #setupPosition = () => {         const x = this.#rect.x + window.scrollX;         const y = this.#rect.y + window.scrollY;         this.#position = {x, y}     }      #setupSize = () => {         const width = this.#rect.width;         const height = this.#rect.height;         this.#size = {width, height}     }      getRef = () => {         return this.#ref;     }      getSize = () => {         return this.#size;     }      getPosition = () => {         return this.#position;     } <\/code><\/pre>\n<h2>\u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0438 (BlockHighlighting)<\/h2>\n<p>\u041d\u0443 \u0438 \u043d\u0430 \u0434\u043e\u0431\u0438\u0432\u043e\u0447\u043a\u0443. \u041e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u0431\u043b\u043e\u043a\u0430. \u0420\u0430\u0437\u0431\u0435\u0440\u0443 \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043f\u0430\u0440\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u0442\u043a \u0442\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e. <\/p>\n<p>\u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u044f \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 dom element \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>static draw;<\/code> \u0421\u0442\u0430\u0442\u0438\u043a\u0430 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0442\u043e\u0447\u043d\u043e \u0431\u044b\u043b \u043e\u0434\u0438\u043d. \u041d\u0430\u043f\u043b\u043e\u0434\u0438\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u043b\u0438\u0448\u043d\u0438\u0445 div \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 &#8212; \u043e\u0447\u0435\u043d\u044c \u0442\u0430\u043a \u0441\u0435\u0431\u0435 \u0438\u0434\u0435\u044f. <\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u0435\u0439\u0447\u0430\u0441 \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u0443\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0441\u043b\u043e\u0432. \u0422\u0435\u043c\u0430 \u043c\u043d\u0435 \u043d\u0430 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c. \u0412\u0438\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c \u0432 PageManager. <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<pre><code class=\"javascript\">if (BlockHighlighting.draw) {     window.document.body.removeChild(BlockHighlighting.draw); }<\/code><\/pre>\n<p>\u0423\u0434\u0430\u043b\u044f\u0435\u043c draw \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0435 \u0431\u043b\u043e\u043a\u0430. \u0422\u043e \u0431\u0438\u0448\u044c, \u043a\u043e\u0433\u0434\u0430 \u0431\u043b\u043e\u043a \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438 block. \u0410 \u0432\u043e\u0442 \u0437\u0430\u0447\u0435\u043c:<\/p>\n<pre><code class=\"javascript\">BlockHighlighting.draw.style.left = `${this.#block.getPosition().x}px`; BlockHighlighting.draw.style.top = `${this.#block.getPosition().y}px`; BlockHighlighting.draw.style.width = `${this.#block.getSize().width}px`; BlockHighlighting.draw.style.height = `${this.#block.getSize().height}px`;<\/code><\/pre>\n<p>\u0412\u0441\u0451 \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u043c\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u043d\u0430 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0448\u0430\u0433\u0435, \u0442\u0443\u0442 \u043d\u0430\u043c \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430\u0448 \u043d\u043e\u0432\u0435\u043d\u044c\u043a\u0438\u0439 div. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d, \u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043c\u044b \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u043c. \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0430 naver.<\/p>\n<p>\u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446:<\/p>\n<pre><code>BlockHighlighting.draw.style.pointerEvents = \"none\";<\/code><\/pre>\n<p>\u041c\u044b \u0436\u0435 \u043d\u0435 \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 EventListener \u0441\u043b\u043e\u0432\u0438\u043b \u0431\u044d\u0434 \u0442\u0440\u0438\u043f \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043f\u0441\u0435\u0432\u0434\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430? \u0422\u0430\u043a \u0432\u043e\u0442, \u043c\u044b \u0435\u0433\u043e \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u043c. \u041f\u0430\u0440\u0441\u0438\u0442\u044c draw &#8212; \u043d\u0435 \u0431\u0443\u0434\u0435\u043c. \u041d\u0443 \u0438 \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u043e\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u0448\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u043f\u0440\u0435\u0433\u0440\u0430\u0436\u0434\u0430\u044f \u0435\u043c\u0443 \u043f\u0443\u0442\u044c \u0434\u043e \u0437\u0430\u0432\u0435\u0442\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u0447\u0435\u043a \u0438 \u043a\u043d\u043e\u043f\u043e\u0447\u0435\u043a. <\/p>\n<p>\u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"javascript\">export class BlockHighlighting {      static draw;     #block;      constructor(block) {         this.#block = block;     }      draw = () => {         if (BlockHighlighting.draw) {             window.document.body.removeChild(BlockHighlighting.draw);         }         BlockHighlighting.draw = window.document.createElement(\"div\");         BlockHighlighting.draw.style.left = `${this.#block.getPosition().x}px`;         BlockHighlighting.draw.style.top = `${this.#block.getPosition().y}px`;         BlockHighlighting.draw.style.width = `${this.#block.getSize().width}px`;         BlockHighlighting.draw.style.height = `${this.#block.getSize().height}px`;         BlockHighlighting.draw.style.position = \"absolute\";         BlockHighlighting.draw.style.background = \"red\";         BlockHighlighting.draw.style.zIndex = \"1000\";         BlockHighlighting.draw.style.opacity = \"0.25\";         BlockHighlighting.draw.style.pointerEvents = \"none\";         window.document.body.appendChild(BlockHighlighting.draw);     } }<\/code><\/pre>\n<p>\u042f \u043e\u0431\u0435\u0449\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u044e \u043f\u0440\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441\u043b\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u0421\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u0430 \u043f\u043e\u0434\u0432\u043e\u0434\u043e\u0447\u043a\u0430. \u0421\u0430\u043c \u043a\u043e\u0434 \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u0441\u043b\u043e\u0432 \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0433\u0440\u044f\u0437\u043d\u044b\u0439 \u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0431\u043b\u043e\u043a\u043e\u0432 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u043d\u0435 \u0441 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0441\u043b\u043e\u0432\u0430 \u0432 \u0444\u043e\u043a\u0443\u0441\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0447\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0441\u044e\u0434\u0430. <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0451. \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0442\u0443\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043e\u0447\u043a\u0430 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/773330\/\"> https:\/\/habr.com\/ru\/articles\/773330\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-359919","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/359919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=359919"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/359919\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=359919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=359919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=359919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}