{"id":285,"date":"2023-03-07T18:43:01","date_gmt":"2023-03-07T15:43:01","guid":{"rendered":"https:\/\/notes.profidev.online\/?p=285"},"modified":"2023-03-28T23:44:56","modified_gmt":"2023-03-28T20:44:56","slug":"slajder-vertikalnyj","status":"publish","type":"post","link":"https:\/\/notes.profidev.online\/ru\/slider\/285\/","title":{"rendered":"Vertical slider"},"content":{"rendered":"\n<figure class=\"wp-block-video\"><video height=\"830\" style=\"aspect-ratio: 1437 \/ 830;\" width=\"1437\" controls src=\"https:\/\/notes.profidev.online\/wp-content\/uploads\/2023\/03\/vokoscreenng-2023-03-07_16-37-45.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;div class=&quot;menu&quot;&gt;\n  &lt;ul class=&quot;menu--wrapper&quot;&gt;\n    &lt;li class=&quot;menu--item&quot;&gt;&lt;button href=&quot;#&quot;&gt;Facebook&lt;\/button&gt;&lt;\/li&gt;\n    &lt;li class=&quot;menu--item&quot;&gt;&lt;button href=&quot;#&quot;&gt;Netflix&lt;\/button&gt;&lt;\/li&gt;\n    &lt;li class=&quot;menu--item&quot;&gt;&lt;button href=&quot;#&quot;&gt;Instagram&lt;\/button&gt;&lt;\/li&gt;\n    &lt;li class=&quot;menu--item&quot;&gt;&lt;button href=&quot;#&quot;&gt;Google&lt;\/button&gt;&lt;\/li&gt;\n    &lt;li class=&quot;menu--item&quot;&gt;&lt;button href=&quot;#&quot;&gt;Twitter&lt;\/button&gt;&lt;\/li&gt;\n    &lt;li class=&quot;menu--item&quot;&gt;&lt;button href=&quot;#&quot;&gt;Amazon&lt;\/button&gt;&lt;\/li&gt;\n    &lt;li class=&quot;menu--item&quot;&gt;&lt;button href=&quot;#&quot;&gt;Pinterest&lt;\/button&gt;&lt;\/li&gt;\n    &lt;li class=&quot;menu--item&quot;&gt;&lt;button href=&quot;#&quot;&gt;Spotify&lt;\/button&gt;&lt;\/li&gt;\n    &lt;li class=&quot;menu--item&quot;&gt;&lt;button href=&quot;#&quot;&gt;YouTube&lt;\/button&gt;&lt;\/li&gt;\n  &lt;\/ul&gt;\n&lt;\/div&gt;\n&lt;script src=&quot;https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/gsap\/3.4.2\/gsap.min.js&quot;&gt;&lt;\/script&gt;\n\/\/\u0421\u043a\u0440\u0438\u043f\u0442 js \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c\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;}\">* {\n  box-sizing: border-box;\n}\n\nbody {\n  height: 100vh;\n  overflow: hidden;\n  background: #c9b3a6;\n  color: #020000;\n}\n\n.menu {\n  height: 100vh;\n  overflow: hidden;\n  background: #abb35b;\n  cursor: -webkit-grab;\n  cursor: grab;\n}\n.menu.is-dragging {\n  cursor: -webkit-grabbing;\n  cursor: grabbing;\n}\n.menu ul {\n  counter-reset: count;\n}\n.menu--item {\n  counter-increment: count;\n  position: absolute;\n  z-index: 1;\n  top: 0;\n  left: 0;\n  width: 100%;\n  font-size: 120px;\n  line-height: 1.2;\n  padding: 2rem 0;\n  text-align: center;\n}\n@media (max-width: 767px) {\n  .menu--item {\n    font-size: 10vw;\n    padding: 1rem 0;\n  }\n}\n.menu--item:nth-child(n+10):before {\n  content: counter(count);\n}\n.menu--item button {\n  color: #020000;\n  text-decoration: none;\n  position: relative;\n  z-index: 1;\n  display: inline-block;\n  -webkit-user-select: none;\n     -moz-user-select: none;\n      -ms-user-select: none;\n          user-select: none;\n  font-size: 120px;\n  -webkit-appearance: none;\n  background: none;\n  padding: 0;\n  border: none;\n  outline: none;\n  box-shadow: none;\n  color: #020000;\n  font-family: &quot;Orelo-sw-db&quot;, serif;\n  cursor: pointer;\n}\n@media (max-width: 767px) {\n  .menu--item button {\n    font-size: 10vw;\n  }\n}\n.menu--item button:before {\n  position: absolute;\n  z-index: -1;\n  left: 0;\n  display: inline-block;\n  transform: translateX(-100%) scale(0.4);\n  content: &quot;0&quot; counter(count);\n  color: #862929;\n  font-family: cursive;\n}\n\n\n\n@font-face {\n  font-family: &quot;Orelo-sw-db&quot;;\n  font-weight: inherit;\n  font-style: inherit;\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;}\">\/*--------------------\nVars\n--------------------*\/\nconst $menu = document.querySelector('.menu');\nconst $items = document.querySelectorAll('.menu--item');\nlet menuHeight = $menu.clientHeight;\nlet itemHeight = $items[0].clientHeight;\nlet wrapHeight = $items.length * itemHeight;\n\nlet scrollSpeed = 0;\nlet oldScrollY = 0;\nlet scrollY = 0;\nlet y = 0;\n\n\n\/*--------------------\nLerp\n--------------------*\/\nconst lerp = (v0, v1, t) =&gt; {\n  return v0 * (1 - t) + v1 * t;\n};\n\n\n\/*--------------------\nDispose\n--------------------*\/\nconst dispose = scroll =&gt; {\n  gsap.set($items, {\n    y: i =&gt; {\n      return i * itemHeight + scroll;\n    },\n    modifiers: {\n      y: y =&gt; {\n        const s = gsap.utils.wrap(-itemHeight, wrapHeight - itemHeight, parseInt(y));\n        return `${s}px`;\n      } } });\n\n\n};\ndispose(0);\n\n\n\/*--------------------\nWheel\n--------------------*\/\nconst handleMouseWheel = e =&gt; {\n  scrollY -= e.deltaY;\n};\n\n\n\/*--------------------\nTouch\n--------------------*\/\nlet touchStart = 0;\nlet touchY = 0;\nlet isDragging = false;\nconst handleTouchStart = e =&gt; {\n  touchStart = e.clientY || e.touches[0].clientY;\n  isDragging = true;\n  $menu.classList.add('is-dragging');\n};\nconst handleTouchMove = e =&gt; {\n  if (!isDragging) return;\n  touchY = e.clientY || e.touches[0].clientY;\n  scrollY += (touchY - touchStart) * 2.5;\n  touchStart = touchY;\n};\nconst handleTouchEnd = () =&gt; {\n  isDragging = false;\n  $menu.classList.remove('is-dragging');\n};\n\n\n\/*--------------------\nListeners\n--------------------*\/\n$menu.addEventListener('mousewheel', handleMouseWheel);\n\n$menu.addEventListener('touchstart', handleTouchStart);\n$menu.addEventListener('touchmove', handleTouchMove);\n$menu.addEventListener('touchend', handleTouchEnd);\n\n$menu.addEventListener('mousedown', handleTouchStart);\n$menu.addEventListener('mousemove', handleTouchMove);\n$menu.addEventListener('mouseleave', handleTouchEnd);\n$menu.addEventListener('mouseup', handleTouchEnd);\n\n$menu.addEventListener('selectstart', () =&gt; {return false;});\n\n\n\/*--------------------\nResize\n--------------------*\/\nwindow.addEventListener('resize', () =&gt; {\n  menuHeight = $menu.clientHeight;\n  itemHeight = $items[0].clientHeight;\n  wrapHeight = $items.length * itemHeight;\n});\n\n\n\/*--------------------\nRender\n--------------------*\/\nconst render = () =&gt; {\n  requestAnimationFrame(render);\n  y = lerp(y, scrollY, .1);\n  dispose(y);\n\n  scrollSpeed = y - oldScrollY;\n  oldScrollY = y;\n\n  gsap.to($items, {\n    scale: 1 - Math.min(100, Math.abs(scrollSpeed)) * .005,\n    rotate: scrollSpeed * 0.2 });\n\n};\nrender();<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":287,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[27,17],"class_list":["post-285","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-slider","tag-gsap","tag-jquery"],"_links":{"self":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/285","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=285"}],"version-history":[{"count":0,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/posts\/285\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media\/287"}],"wp:attachment":[{"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/media?parent=285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/categories?post=285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.profidev.online\/ru\/wp-json\/wp\/v2\/tags?post=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}