{"id":522,"date":"2023-03-09T22:26:04","date_gmt":"2023-03-09T19:26:04","guid":{"rendered":"https:\/\/notes.profidev.online\/?p=522"},"modified":"2023-03-28T23:52:28","modified_gmt":"2023-03-28T20:52:28","slug":"effekt-nabora-teksta","status":"publish","type":"post","link":"https:\/\/notes.profidev.online\/ru\/effect\/522\/","title":{"rendered":"Typing effect"},"content":{"rendered":"\n<figure class=\"wp-block-video\"><video height=\"306\" style=\"aspect-ratio: 674 \/ 306;\" width=\"674\" controls src=\"https:\/\/notes.profidev.online\/wp-content\/uploads\/2023\/03\/vokoscreenng-2023-03-09_20-17-55.webm\"><\/video><\/figure>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}\">&lt;link href=&quot;https:\/\/fonts.googleapis.com\/css?family=Raleway:200,100,400&quot; rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; \/&gt;\n&lt;h1&gt;\n  &lt;span\n     class=&quot;txt-rotate&quot;\n     data-period=&quot;10&quot;\n     data-rotate='[ &quot;Alpha Romero&quot;, &quot;Aston Martin&quot;, &quot;Toyota&quot;, &quot;Honda&quot;, &quot;Mazda&quot; ]'&gt;&lt;\/span&gt;\n&lt;\/h1&gt;\n\/\/\u0410\u0432\u0442\u043e\u0440: Stephen Scaff. @StephenScaff<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;css&quot;,&quot;mime&quot;:&quot;text\/css&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;CSS&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;css&quot;}\">html,body {\n  font-family: 'Raleway', sans-serif;\n  padding: 3em 2em;\n  font-size: 18px;\n  background: #222;\n  color: #aaa\n}\n\nh1,h2 {\n  font-weight: 200;\n  margin: 0.4em 0;\n}\nh1 { font-size: 3.5em; }\nh2 {\n  color: #888;\n  font-size: 2em;\n}\n\n\/* .txt-rotate &gt; .wrap { border-right: 0.08em solid #666 } *\/\n.cursor {\n  display: inline-block;\n  height: 1em;\n  width: 2px;\n  background: #fff;\n  border-right: 1px solid #fff;\n  animation: cursor 0.3s ease both;\n}\n@keyframes cursor {\n  0% {\n    opacity: 0;\n  }\n  \n  50% {\n    opacity:1;\n  }\n}<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:false,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">    var Typer = (function () {\n    var period = parseInt(period, 10) || 2000;\n    var txt = '';\n    var elements = document.getElementsByClassName('txt-rotate');\n    var delta = 300 - Math.random() * 100\n    var isDeleting = false;\n    var loopNum = 0;\n    return {\n    \/**\n     * Init\n     *\/\n    init: function() {\n      console.log('hi')\n      this.bindEvents();\n    },\n    \n    bindEvents: function() {\n     console.log('hi')\n     for (var i=0; i&lt;elements.length; i++) {\n      var toRotate = elements[i].getAttribute('data-rotate');\n      var period = elements[i].getAttribute('data-period');\n        if (toRotate) {\n          Typer.txtRotate(elements[i], JSON.parse(toRotate), period);\n        }\n      }\n    },\n      \n      txtRotate: function(el, toRotate, period) {\n        this.toRotate = toRotate;\n        this.el = el;\n        this.loopNum = 0;\n        this.period = parseInt(period, 10) || 2000;\n        this.txt = '';\n        Typer.tick();\n        this.isDeleting = false;\n      },\n    \n    tick: function() {\n      var i = this.loopNum % this.toRotate.length;\n      var fullTxt = this.toRotate[i];\n  \n      if (this.isDeleting) {\n        this.txt = fullTxt.substring(0, this.txt.length - 1);\n      } else {\n        this.txt = fullTxt.substring(0, this.txt.length + 1);\n      }\n      this.el.innerHTML = '&lt;span class=&quot;wrap&quot;&gt;'+this.txt+'&lt;span class=&quot;cursor&quot;&gt;&lt;\/span&gt;&lt;\/span&gt;';\n      var that = this;\n      if (this.isDeleting) { delta \/= 2; }\n  \n      if (!this.isDeleting &amp;&amp; this.txt === fullTxt) {\n        delta = this.period;\n        this.isDeleting = true;\n      } else if (this.isDeleting &amp;&amp; this.txt === '') {\n        this.isDeleting = false;\n        this.loopNum++;\n        delta = 500;\n      }\n      \n       setTimeout(function() {\n          that.tick();\n        }, delta);\n      },\n    };\n  })();\n  \n  Typer.init();<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":523,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[40],"class_list":["post-522","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-effect","tag-text"],"_links":{"self":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/comments?post=522"}],"version-history":[{"count":0,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/522\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media\/523"}],"wp:attachment":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media?parent=522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/categories?post=522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/tags?post=522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}