{"id":350457,"date":"2023-07-18T21:00:53","date_gmt":"2023-07-18T21:00:53","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350457"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350457","title":{"rendered":"<span>\u0421\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 typescript \u0438 vue<\/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>\u0422\u0430\u043a-\u0441, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u0433\u0438, \u0432\u0441\u0435\u0445 \u0440\u0430\u0434\u043e\u0441\u0442\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e! \u042d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u0435\u0439\u043a\u0430 \u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u043b\u044f \u0442\u0435\u0445 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0442\u044f\u0442 \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f: touchscreen, \u043c\u044b\u0448\u043a\u0430, \u043b\u0438\u0431\u043e \u0436\u0435 \u0438 \u0442\u043e, \u0438 \u0434\u0440\u0443\u0433\u043e\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0430\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c: desktop, tab, phone<\/p>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0440\u0443\u043c\u043e\u0432, \u044f \u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0433\u043e\u0442\u043e\u0432\u043e\u043c \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \ud83d\ude42<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443: \u043b\u043e\u0433\u0438\u043a\u0430 \u0438 \u043a\u043e\u0434<\/h2>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c, \u043c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u043b \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 touch \u044d\u0442\u043e \u0438\u043b\u0438 \u043d\u0435\u0442. \u0410 \u0434\u0430\u043b\u0435\u0435 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0432\u0441\u0435 \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0442.\u043a. \u043d\u0430 css \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. <\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u0434\u0443. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f (enum) \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><em>InteractionType.ts<\/em> &#8212; enum, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0442\u0438\u043f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f &#8212; \u043c\u044b\u0448\u043a\u0430, \u0442\u0430\u0447, \u043b\u0438\u0431\u043e \u043e\u0431\u0430 \u0441\u0440\u0430\u0437\u0443<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"typescript\">export namespace InteractionType {     export enum State {         Unknown = 'Unknown',         Mouse = 'Mouse',         Touch = 'Touch',         Both =  'Both'     } }<\/code><\/pre>\n<ul>\n<li>\n<p><em>OrientationType.ts<\/em> &#8212; enum, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0442\u0438\u043f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 &#8212; \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c, \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c, \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 css \u044d\u0442\u043e \u043f\u043e\u0440\u0442\u0440\u0435\u0442 \u0438 \u043b\u044d\u043d\u0434\u0441\u043a\u0435\u0439\u043f<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"typescript\">export namespace OrientationType {     export enum State {         Unknown = 'Unknown',         Portrait = 'Portrait',         Landscape = 'Landscape',     } }<\/code><\/pre>\n<ul>\n<li>\n<p><em>DeviceType.ts<\/em> &#8212; enum, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0442\u0438\u043f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 &#8212; \u043f\u043b\u0430\u043d\u0448\u0435\u0442, \u0442\u0435\u043b\u0435\u0444\u043e\u043d, \u043b\u0438\u0431\u043e \u041f\u041a<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"typescript\">export namespace DeviceType {     export enum State {         Unknown = 'Unknown',         Desktop = 'Desktop',         Phone = 'Phone',         Tab = 'Tab'     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e &#8212; \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439. \u0422\u0443\u0442 \u0432\u0441\u0435 \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443, \u043d\u0438\u0447\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e, \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0443 <em>addEventListener<\/em> &#8212; <em>once<\/em>, \u0442.\u043a. \u043d\u0430\u043c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0447\u0442\u043e \u0442\u0430\u043c \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430 \u0442\u0438\u043f, \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0440\u0430\u0437 &#8212; \u0432\u0441\u0435, \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0442\u043c\u0435\u0442\u043a\u0443, \u0447\u0442\u043e \u0435\u0441\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u0447\u0441\u043a\u0440\u0438\u043d \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u043c.<\/p>\n<pre><code class=\"typescript\">public interactionType: InteractionType.State; public orientationType: OrientationType.State; public deviceType: DeviceType.State;  constructor () {     this.interactionType = InteractionType.State.Unknown;     this.orientationType = OrientationType.State.Unknown;     this.deviceType = DeviceType.State.Unknown;      window.addEventListener('touchstart', this.activeTouchState, { once: true });     window.addEventListener('mousemove',  this.activeDeskState, { once: true }); }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438, \u043d\u043e \u0438 \u043f\u0440\u0438 \u0437\u0430\u0445\u043e\u0434\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0447\u0441\u043a\u0440\u0438\u043d\u0430:<\/p>\n<pre><code class=\"typescript\">    public defineTouchscreen (): void {         if (window.PointerEvent &amp;&amp; ('maxTouchPoints' in navigator)) {             \/\/ if Pointer Events are supported, just check maxTouchPoints             if (navigator.maxTouchPoints > 0) {                 this.activeTouchState();             }         } else {             \/\/ no Pointer Events...             if (window.matchMedia &amp;&amp; window.matchMedia(\"(any-pointer:coarse)\").matches) {                 \/\/ check for any-pointer:coarse which mostly means touchscreen                 this.activeTouchState();             } else if (window.TouchEvent || ('ontouchstart' in window)) {                 \/\/ last resort - check for exposed touch events API \/ event handler                 this.activeTouchState();             }         }     }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043b\u044f <em>eventListener&#8217;\u043e\u0432<\/em>:<\/p>\n<pre><code class=\"typescript\">    private activeTouchState (): void {         if (this.interactionType === InteractionType.State.Mouse) {             this.interactionType = InteractionType.State.Both;         } else {             this.interactionType = InteractionType.State.Touch;         }     }      private activeDeskState (): void {         if (this.interactionType === InteractionType.State.Touch) {             this.interactionType = InteractionType.State.Both;         } else {             this.interactionType = InteractionType.State.Mouse;         }     }<\/code><\/pre>\n<p>\u0414\u0443\u043c\u0430\u044e, \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0443\u0442 \u043d\u0435 \u043d\u0430\u0434\u043e &#8212; \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0442\u0443\u0442 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u043d\u043e\u0432\u043e\u0440\u043e\u0447\u0435\u043d\u043d\u044b\u043c \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u043c \u0441 \u0442\u0430\u0447\u043f\u0430\u0434\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u043a\u043b\u0438\u043a\u043d\u0443\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b\u0448\u043a\u043e\u0439, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0442\u0430\u0447\u043f\u0430\u0434. \u0422\u0430\u043a\u0436\u0435 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e &#8212; \u043d\u0430\u0447\u0430\u043b \u0441 \u0442\u0430\u0447\u043f\u0430\u0434\u0430, \u043f\u0435\u0440\u0435\u0448\u0435\u043b \u043d\u0430 \u043c\u044b\u0448\u044c, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0431\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code class=\"typescript\">    public defineDeviceType (): void {         const ua = navigator.userAgent;         if (\/(tablet|ipad|playbook|silk)|(android(?!.*mobi))\/i.test(ua)) {             this.deviceType = DeviceType.State.Tab;             return;         }         if (             \/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)\/.test(                 ua             )         ) {             this.deviceType = DeviceType.State.Phone;             return;         }         this.deviceType = DeviceType.State.Desktop;     };<\/code><\/pre>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u0442\u0443\u0442 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e <em>navigator.userAgent<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code>userAgent = appCodeName\/appVersion number (Platform; Security; OS-or-CPU; Localization; rv: revision-version-number) product\/productSub Application-Name Application-Name-version<\/code><\/pre>\n<p>\u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0445\u043e\u0442\u0438\u043c.<br \/>\u041d\u0443 \u0438 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code class=\"typescript\">    public defineOrientationType (): void {         if (window.matchMedia(\"(orientation: portrait)\").matches) {             this.orientationType = OrientationType.State.Portrait;         } else if (window.matchMedia(\"(orientation: landscape)\").matches) {             this.orientationType = OrientationType.State.Landscape;         }     }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043a\u043e\u0434 \u0433\u043e\u0442\u043e\u0432) \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u043d\u0443\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0438 enum&#8217;\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c computed \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435 \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u0443\u0436\u0435 \u0441\u0430\u043c\u043e\u043c\u0443 \u0442\u044b\u043a\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0434\u0430 \u043a\u0430\u043a \u043f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0421 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 &#8212; \u0432\u0435\u0448\u0430\u0435\u043c computed \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \ud83d\ude42<\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430 \u043c\u043e\u0435\u043c <a href=\"https:\/\/github.com\/Arthur410\/user-device-detecting\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a><\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0436\u0435\u043b\u0430\u044e \u0432\u0441\u0435\u043c \u0443\u0434\u0430\u0447\u0438! \u0414\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438!<\/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\/748890\/\"> https:\/\/habr.com\/ru\/articles\/748890\/<\/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>\u0422\u0430\u043a-\u0441, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u0433\u0438, \u0432\u0441\u0435\u0445 \u0440\u0430\u0434\u043e\u0441\u0442\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e! \u042d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u0435\u0439\u043a\u0430 \u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u043b\u044f \u0442\u0435\u0445 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0442\u044f\u0442 \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0432\u0435\u0431 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f: touchscreen, \u043c\u044b\u0448\u043a\u0430, \u043b\u0438\u0431\u043e \u0436\u0435 \u0438 \u0442\u043e, \u0438 \u0434\u0440\u0443\u0433\u043e\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0430\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c: desktop, tab, phone<\/p>\n<p>\u0417\u0432\u0443\u0447\u0438\u0442, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0432\u043e\u0435\u0433\u043e \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u043e\u0440\u0443\u043c\u043e\u0432, \u044f \u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0433\u043e\u0442\u043e\u0432\u043e\u043c \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \ud83d\ude42<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443: \u043b\u043e\u0433\u0438\u043a\u0430 \u0438 \u043a\u043e\u0434<\/h2>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c, \u043c\u043d\u0435 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u043b \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u0445\u043e\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 touch \u044d\u0442\u043e \u0438\u043b\u0438 \u043d\u0435\u0442. \u0410 \u0434\u0430\u043b\u0435\u0435 \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0432\u0441\u0435 \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0442.\u043a. \u043d\u0430 css \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. <\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043e\u0434\u0443. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f (enum) \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><em>InteractionType.ts<\/em> &#8212; enum, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0442\u0438\u043f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f &#8212; \u043c\u044b\u0448\u043a\u0430, \u0442\u0430\u0447, \u043b\u0438\u0431\u043e \u043e\u0431\u0430 \u0441\u0440\u0430\u0437\u0443<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"typescript\">export namespace InteractionType {     export enum State {         Unknown = 'Unknown',         Mouse = 'Mouse',         Touch = 'Touch',         Both =  'Both'     } }<\/code><\/pre>\n<ul>\n<li>\n<p><em>OrientationType.ts<\/em> &#8212; enum, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0442\u0438\u043f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 &#8212; \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c, \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c, \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 css \u044d\u0442\u043e \u043f\u043e\u0440\u0442\u0440\u0435\u0442 \u0438 \u043b\u044d\u043d\u0434\u0441\u043a\u0435\u0439\u043f<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"typescript\">export namespace OrientationType {     export enum State {         Unknown = 'Unknown',         Portrait = 'Portrait',         Landscape = 'Landscape',     } }<\/code><\/pre>\n<ul>\n<li>\n<p><em>DeviceType.ts<\/em> &#8212; enum, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0442\u0438\u043f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 &#8212; \u043f\u043b\u0430\u043d\u0448\u0435\u0442, \u0442\u0435\u043b\u0435\u0444\u043e\u043d, \u043b\u0438\u0431\u043e \u041f\u041a<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"typescript\">export namespace DeviceType {     export enum State {         Unknown = 'Unknown',         Desktop = 'Desktop',         Phone = 'Phone',         Tab = 'Tab'     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043a \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e &#8212; \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0435\u0439. \u0422\u0443\u0442 \u0432\u0441\u0435 \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0443, \u043d\u0438\u0447\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u0433\u043e, \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0443 <em>addEventListener<\/em> &#8212; <em>once<\/em>, \u0442.\u043a. \u043d\u0430\u043c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0447\u0442\u043e \u0442\u0430\u043c \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430 \u0442\u0438\u043f, \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0440\u0430\u0437 &#8212; \u0432\u0441\u0435, \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0442\u043c\u0435\u0442\u043a\u0443, \u0447\u0442\u043e \u0435\u0441\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u0447\u0441\u043a\u0440\u0438\u043d \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u043c.<\/p>\n<pre><code class=\"typescript\">public interactionType: InteractionType.State; public orientationType: OrientationType.State; public deviceType: DeviceType.State;  constructor () {     this.interactionType = InteractionType.State.Unknown;     this.orientationType = OrientationType.State.Unknown;     this.deviceType = DeviceType.State.Unknown;      window.addEventListener('touchstart', this.activeTouchState, { once: true });     window.addEventListener('mousemove',  this.activeDeskState, { once: true }); }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438, \u043d\u043e \u0438 \u043f\u0440\u0438 \u0437\u0430\u0445\u043e\u0434\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0442\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0447\u0441\u043a\u0440\u0438\u043d\u0430:<\/p>\n<pre><code class=\"typescript\">    public defineTouchscreen (): void {         if (window.PointerEvent &amp;&amp; ('maxTouchPoints' in navigator)) {             \/\/ if Pointer Events are supported, just check maxTouchPoints             if (navigator.maxTouchPoints > 0) {                 this.activeTouchState();             }         } else {             \/\/ no Pointer Events...             if (window.matchMedia &amp;&amp; window.matchMedia(\"(any-pointer:coarse)\").matches) {                 \/\/ check for any-pointer:coarse which mostly means touchscreen                 this.activeTouchState();             } else if (window.TouchEvent || ('ontouchstart' in window)) {                 \/\/ last resort - check for exposed touch events API \/ event handler                 this.activeTouchState();             }         }     }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043b\u044f <em>eventListener&#8217;\u043e\u0432<\/em>:<\/p>\n<pre><code class=\"typescript\">    private activeTouchState (): void {         if (this.interactionType === InteractionType.State.Mouse) {             this.interactionType = InteractionType.State.Both;         } else {             this.interactionType = InteractionType.State.Touch;         }     }      private activeDeskState (): void {         if (this.interactionType === InteractionType.State.Touch) {             this.interactionType = InteractionType.State.Both;         } else {             this.interactionType = InteractionType.State.Mouse;         }     }<\/code><\/pre>\n<p>\u0414\u0443\u043c\u0430\u044e, \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0442\u0443\u0442 \u043d\u0435 \u043d\u0430\u0434\u043e &#8212; \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0442\u0443\u0442 \u0432\u0441\u0435 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u043d\u043e\u0432\u043e\u0440\u043e\u0447\u0435\u043d\u043d\u044b\u043c \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u043e\u043c \u0441 \u0442\u0430\u0447\u043f\u0430\u0434\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u043a\u043b\u0438\u043a\u043d\u0443\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b\u0448\u043a\u043e\u0439, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0442\u0430\u0447\u043f\u0430\u0434. \u0422\u0430\u043a\u0436\u0435 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e &#8212; \u043d\u0430\u0447\u0430\u043b \u0441 \u0442\u0430\u0447\u043f\u0430\u0434\u0430, \u043f\u0435\u0440\u0435\u0448\u0435\u043b \u043d\u0430 \u043c\u044b\u0448\u044c, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0431\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code class=\"typescript\">    public defineDeviceType (): void {         const ua = navigator.userAgent;         if (\/(tablet|ipad|playbook|silk)|(android(?!.*mobi))\/i.test(ua)) {             this.deviceType = DeviceType.State.Tab;             return;         }         if (             \/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)\/.test(                 ua             )         ) {             this.deviceType = DeviceType.State.Phone;             return;         }         this.deviceType = DeviceType.State.Desktop;     };<\/code><\/pre>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u0442\u0443\u0442 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e <em>navigator.userAgent<\/em> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code>userAgent = appCodeName\/appVersion number (Platform; Security; OS-or-CPU; Localization; rv: revision-version-number) product\/productSub Application-Name Application-Name-version<\/code><\/pre>\n<p>\u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0445\u043e\u0442\u0438\u043c.<br \/>\u041d\u0443 \u0438 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code class=\"typescript\">    public defineOrientationType (): void {         if (window.matchMedia(\"(orientation: portrait)\").matches) {             this.orientationType = OrientationType.State.Portrait;         } else if (window.matchMedia(\"(orientation: landscape)\").matches) {             this.orientationType = OrientationType.State.Landscape;         }     }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043a\u043e\u0434 \u0433\u043e\u0442\u043e\u0432) \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u043d\u0443\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0438 enum&#8217;\u044b<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c computed \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435 \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u0443\u0436\u0435 \u0441\u0430\u043c\u043e\u043c\u0443 \u0442\u044b\u043a\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0434\u0430 \u043a\u0430\u043a \u043f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0421 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 &#8212; \u0432\u0435\u0448\u0430\u0435\u043c computed \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \ud83d\ude42<\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430 \u043c\u043e\u0435\u043c <a href=\"https:\/\/github.com\/Arthur410\/user-device-detecting\" rel=\"noopener noreferrer nofollow\">\u0433\u0438\u0442\u0445\u0430\u0431\u0435<\/a><\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0436\u0435\u043b\u0430\u044e \u0432\u0441\u0435\u043c \u0443\u0434\u0430\u0447\u0438! \u0414\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438!<\/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\/748890\/\"> https:\/\/habr.com\/ru\/articles\/748890\/<\/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-350457","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350457","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=350457"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350457\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}