{"id":1352,"date":"2023-05-01T11:48:10","date_gmt":"2023-05-01T08:48:10","guid":{"rendered":"https:\/\/notes.profidev.online\/?p=1352"},"modified":"2023-05-01T11:58:17","modified_gmt":"2023-05-01T08:58:17","slug":"toggle","status":"publish","type":"post","link":"https:\/\/notes.profidev.online\/ru\/switch\/1352\/","title":{"rendered":"Toggle"},"content":{"rendered":"<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"498\" height=\"298\" src=\"https:\/\/notes.profidev.online\/wp-content\/uploads\/2023\/05\/peek-2023-05-01-10-45.gif\" alt=\"\" class=\"wp-image-1353\"\/><\/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;label class=&quot;switch&quot;&gt;\n    &lt;input type=&quot;checkbox&quot; hidden&gt;\n    &lt;div class=&quot;switch__wrapper&quot;&gt;\n      &lt;div class=&quot;switch__toggle&quot;&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n  &lt;\/label&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;}\">:root {\n  --displacement: -0.1rem;\n  --tremble: -10deg;\n  --trembleF: 5deg;\n  --iPos: 50%;\n  --bPos: -75%;\n  --fPos: -50%;\n  --time: 430ms;\n}\n\nbody {\n  display: grid;\n  height: 100vh;\n  margin: 0;\n  background: #212121;\n}\n\n.switch {\n  margin: auto;\n}\n.switch__wrapper {\n  position: relative;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  width: 4rem;\n  height: 2rem;\n  border: 2px solid red;\n  border-radius: 99rem;\n  transform-origin: left center;\n  animation: checked__wrapper var(--time) ease-in forwards;\n  mix-blend-mode: lighten;\n}\n.switch__wrapper::before, .switch__wrapper::after {\n  content: &quot;&quot;;\n  position: absolute;\n  width: 100%;\n  height: 100%;\n  border: 2px solid #000;\n  border-radius: inherit;\n  transform-origin: inherit;\n  animation: inherit;\n  mix-blend-mode: inherit;\n}\n.switch__wrapper::before {\n  --tremble: -12deg;\n  --trembleF: -7deg;\n  border-color: lime;\n  animation-delay: 50ms;\n}\n.switch__wrapper::after {\n  --tremble: -8deg;\n  --trembleF: -4deg;\n  border-color: blue;\n  animation-delay: 75ms;\n}\n.switch__toggle {\n  width: 1.5rem;\n  height: 1.5rem;\n  border-radius: 99rem;\n  box-shadow: inset 0 0 0 2px #fff;\n  transform-origin: inherit;\n  animation: checked__toggle var(--time) ease-in forwards;\n}\ninput:active + .switch__wrapper .switch__toggle {\n  width: 1.6rem;\n}\ninput:checked + .switch__wrapper {\n  transform-origin: right center;\n  animation-name: checked__wrapper--r;\n}\ninput:checked + .switch__wrapper .switch__toggle {\n  background: #fff;\n  animation-name: checked__toggle--r;\n}\n\n@keyframes checked__wrapper {\n  0%, 45%, 100% {\n    transform: rotateY(0deg);\n  }\n  48% {\n    transform: translateX(var(--displacement));\n    filter: blur(0);\n  }\n  55% {\n    transform: rotateZ(var(--tremble));\n    filter: blur(1px);\n  }\n  65% {\n    transform: rotateZ(var(--trembleF));\n  }\n}\n@keyframes checked__wrapper--r {\n  0%, 45%, 100% {\n    transform: rotateY(0deg);\n  }\n  48% {\n    transform: translateX(calc(-1 * var(--displacement)));\n    filter: blur(0);\n  }\n  55% {\n    transform: rotateZ(calc(-1 * var(--tremble)));\n    filter: blur(1px);\n  }\n  65% {\n    transform: rotateZ(calc(-1 * var(--trembleF)));\n  }\n}\n@keyframes checked__toggle {\n  0% {\n    background: #fff;\n    transform: translateX(var(--iPos)) scale(1.25, 1);\n  }\n  45% {\n    background: #fff;\n    transform: translateX(var(--bPos)) scale(1, 1);\n  }\n  50% {\n    background: transparent;\n    transform: translateX(var(--bPos)) scale(0.5, 1.1);\n  }\n  65% {\n    transform: translateX(var(--bPos)) scale(1, 1);\n  }\n  100% {\n    transform: translateX(var(--fPos));\n  }\n}\n@keyframes checked__toggle--r {\n  0% {\n    background: transparent;\n    transform: translateX(calc(-1 * var(--iPos))) scale(1.25, 1);\n  }\n  45% {\n    background: transparent;\n    transform: translateX(calc(-1 * var(--bPos))) scale(1, 1);\n  }\n  50% {\n    background: #fff;\n    transform: translateX(calc(-1 * var(--bPos))) scale(0.5, 1.1);\n  }\n  65% {\n    transform: translateX(calc(-1 * var(--bPos))) scale(1, 1);\n  }\n  100% {\n    transform: translateX(calc(-1 * var(--fPos)));\n  }\n}<\/pre><\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1353,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[16],"class_list":["post-1352","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-switch","tag-htmlcss"],"_links":{"self":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/1352","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=1352"}],"version-history":[{"count":2,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/1352\/revisions"}],"predecessor-version":[{"id":1357,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/1352\/revisions\/1357"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media\/1353"}],"wp:attachment":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media?parent=1352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/categories?post=1352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/tags?post=1352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}