{"id":1756,"date":"2023-12-12T12:46:27","date_gmt":"2023-12-12T09:46:27","guid":{"rendered":"https:\/\/notes.profidev.online\/?p=1756"},"modified":"2023-12-12T12:46:29","modified_gmt":"2023-12-12T09:46:29","slug":"content-menu-animation","status":"publish","type":"post","link":"https:\/\/notes.profidev.online\/ru\/headermenu\/1756\/","title":{"rendered":"Content menu animation"},"content":{"rendered":"<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Content menu animation javascript\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/2G42CKjGs0s?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/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 rel=&quot;stylesheet&quot; href=&quot;https:\/\/use.fontawesome.com\/releases\/v5.5.0\/css\/all.css&quot; integrity=&quot;sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU&quot; crossorigin=&quot;anonymous&quot;&gt;\n  &lt;link href=&quot;https:\/\/fonts.googleapis.com\/css?family=Montserrat:400,700&quot; rel=&quot;stylesheet&quot;&gt;\n \n  &lt;header&gt;\n    &lt;div class=&quot;triangle left&quot;&gt;&lt;h1&gt;This is a title&lt;\/h1&gt;&lt;\/div&gt;\n    &lt;div class=&quot;triangle right&quot;&gt;&lt;h1&gt;This is a title&lt;\/h1&gt;&lt;\/div&gt;\n    &lt;button&gt;&lt;\/button&gt;\n  &lt;\/header&gt;\n  \n  &lt;nav&gt;\n    &lt;ul&gt;\n      &lt;li&gt;Section 1&lt;\/li&gt;\n      &lt;li&gt;Section 2&lt;\/li&gt;\n      &lt;li&gt;Section 3&lt;\/li&gt;\n    &lt;\/ul&gt;\n    &lt;div id=&quot;nav-close&quot;&gt;&lt;i class=&quot;fas fa-times&quot;&gt;&lt;\/i&gt;&lt;\/div&gt;\n  &lt;\/nav&gt;\n  \n  &lt;content&gt;\n    &lt;section&gt;Section 1&lt;\/section&gt;\n    &lt;section&gt;Section 2&lt;\/section&gt;\n    &lt;section&gt;Section 3&lt;\/section&gt;\n  &lt;\/content&gt;\n\n&lt;script src=&quot;https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/jquery\/3.1.1\/jquery.min.js&quot;&gt;&lt;\/script&gt;<\/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;}\">@charset &quot;UTF-8&quot;;\n* {\n  margin: 0;\n  padding: 0;\n  box-sizing: border-box;\n}\n\nbody {\n  min-height: 300vh;\n  background-image: linear-gradient(to top, #09203f 0%, #537895 100%);\n}\n\nheader {\n  position: fixed;\n  width: 100%;\n  height: 100%;\n  top: 0;\n  left: 0;\n  display: flex;\n  flex-direction: column;\n  justify-content: center;\n  align-items: center;\n}\nheader h1, header button {\n  position: relative;\n  z-index: 10;\n}\nheader h1 {\n  text-transform: uppercase;\n  letter-spacing: 1pt;\n  font-size: 3em;\n  color: #fff;\n  font-family: &quot;Montserrat&quot;, sans-serif;\n}\nheader button {\n  font-family: &quot;Font Awesome 5 Free&quot;;\n  font-weight: 900;\n  position: absolute;\n  bottom: 100px;\n  left: calc(50% - 60px);\n  width: 120px;\n  height: 50px;\n  border: 0;\n  box-shadow: 2px 1px 20px 0 rgba(0, 0, 0, 0.5);\n  border-radius: 10px;\n  cursor: pointer;\n  background: #fff;\n  font-size: 1em;\n  color: #09203f;\n  transition: all 0.8s cubic-bezier(0.645, 0.045, 0.355, 1), transform 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955), box-shadow 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955);\n  overflow: hidden;\n}\nheader button:hover {\n  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.5);\n}\nheader button:focus {\n  outline: 0;\n}\nheader button:before, header button:after {\n  font-family: &quot;Font Awesome 5 Free&quot;;\n  transition: all 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);\n  top: 17px;\n  position: absolute;\n}\nheader button:before {\n  content: &quot;\uf067&quot;;\n  opacity: 1;\n  left: 53px;\n}\nheader button:after {\n  content: &quot;\uf0c9&quot;;\n  opacity: 0;\n  left: 0;\n}\nheader .triangle {\n  position: absolute;\n  z-index: 1;\n  top: 0;\n  left: 0;\n  width: 100%;\n  height: 100%;\n  background: linear-gradient(to top, #7F7FD5 0%, #91EAE4 100%);\n  transition: all 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  pointer-events: none;\n}\nheader .triangle.left {\n  clip-path: polygon(0 0, 0% 100%, 101% 100%);\n}\nheader .triangle.right {\n  clip-path: polygon(100% 0, 0 0, 100% 100%);\n}\nheader.open .triangle.left {\n  clip-path: polygon(0 0, 0 100%, 0 100%);\n}\nheader.open .triangle.right {\n  clip-path: polygon(100% 0, 100% 0, 100% 100%);\n}\nheader.open button {\n  left: 40px;\n  bottom: 40px;\n  width: 50px;\n  border-radius: 50%;\n}\nheader.open button:before {\n  opacity: 0;\n  left: 100%;\n}\nheader.open button:after {\n  opacity: 1;\n  left: 18px;\n}\nheader.open button.menu {\n  width: 100%;\n  height: 100%;\n  bottom: 0;\n  left: 0;\n  border-radius: 0;\n}\nheader.open button.menu:after {\n  left: -100%;\n}\n\ncontent section {\n  height: 100vh;\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  font-family: &quot;Montserrat&quot;, sans-serif;\n  font-weight: 700;\n  text-transform: uppercase;\n  font-size: 1em;\n  letter-spacing: 2pt;\n  color: #fff;\n}\n\nnav {\n  position: fixed;\n  width: 100%;\n  height: 100%;\n  top: 0;\n  left: 0;\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  display: none;\n}\nnav ul {\n  list-style: none;\n}\nnav ul li {\n  font-family: &quot;Montserrat&quot;, sans-serif;\n  font-weight: 700;\n  text-transform: uppercase;\n  line-height: 2;\n  letter-spacing: 1pt;\n  font-size: 2em;\n  color: #09203f;\n  animation: fadeDown 0.5s forwards;\n  opacity: 0;\n  cursor: pointer;\n  transform: translateY(-20px);\n  transition: all 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955);\n}\nnav ul li:hover {\n  text-shadow: 2px 1px 40px rgba(0, 0, 0, 1);\n  opacity: 0.8;\n}\nnav ul li:nth-child(1) {\n  animation-delay: 0.8s;\n}\nnav ul li:nth-child(2) {\n  animation-delay: 0.9s;\n}\nnav ul li:nth-child(3) {\n  animation-delay: 1s;\n}\nnav #nav-close {\n  position: fixed;\n  top: 40px;\n  right: 40px;\n  font-size: 1.5em;\n  cursor: pointer;\n  animation: fadeDown 0.5s forwards;\n  animation-delay: 1.1s;\n  opacity: 0;\n  color: #09203f;\n  transform: translateY(-20px);\n}\n@keyframes fadeDown {\n  0% {\n    opacity: 0;\n    transform: translateY(-20px);\n  }\n  100% {\n    opacity: 1;\n    transform: translateY(0);\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;}\">\/\/ function to open\/close nav\nfunction toggleNav(){\n  \/\/ if nav is open, close it\n  if($(&quot;nav&quot;).is(&quot;:visible&quot;)){\n    $(&quot;nav&quot;).fadeOut();\n    $(&quot;button&quot;).removeClass(&quot;menu&quot;);\n  }\n  \/\/ if nav is closed, open it\n  else{\n    $(&quot;button&quot;).addClass(&quot;menu&quot;);\n    $(&quot;nav&quot;).fadeIn().css('display', 'flex');\n  }\n}\n\n\/\/ when clicking + or \u2630 button\n$(&quot;button&quot;).click(function(){\n  \/\/ when clicking \u2630 button, open nav\n  if($(&quot;header&quot;).hasClass(&quot;open&quot;)){\n    toggleNav();\n  }\n  \/\/ when clicking + button, open header\n  else{\n    $(&quot;header&quot;).addClass(&quot;open&quot;);\n  }\n});\n\n\/\/ close nav\n$(&quot;#nav-close&quot;).click(function(){\n  toggleNav();\n});\n\n\/\/ scroll to sections\n$(&quot;nav li&quot;).click(function(){\n  \/\/ get index of clicked li and select according section\n  var index = $(this).index();\n  var target = $(&quot;content section&quot;).eq(index);\n  \n  toggleNav();\n  \n  $('html,body').delay(300).animate({\n    scrollTop: target.offset().top\n  }, 500);\n});<\/pre><\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1757,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[43],"class_list":["post-1756","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-headermenu","tag-menu"],"_links":{"self":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/1756","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=1756"}],"version-history":[{"count":1,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/1756\/revisions"}],"predecessor-version":[{"id":1758,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/1756\/revisions\/1758"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media\/1757"}],"wp:attachment":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media?parent=1756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/categories?post=1756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/tags?post=1756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}