Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Добавляет рецепт контейнера с горизонтальным скроллом и динамическими тенями #5480

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
147 changes: 147 additions & 0 deletions recipes/horizontal-scroll-with-shadow/demos/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Горизонтальный скролл с тенями</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
font-family: "Roboto", sans-serif;
}

body {
display: flex;
justify-content: center;
align-items: center;
background-color: #18191c;
}

.component {
position: relative;
width: 600px;
overflow: hidden;
}

.component__container {
display: flex;
gap: 25px;
padding-block-end: 25px;
overflow-x: scroll;
scroll-behavior: smooth;
scrollbar-color: #C56FFF transparent;
scrollbar-width: thin;
}

.component__container::-webkit-scrollbar {
height: 8px;
}

.component__container::-webkit-scrollbar-track {
background: #5F377D;
border-radius: 4px;
}

.component__container::-webkit-scrollbar-thumb {
background: #C56FFF;
border-radius: 4px;
}

.component__container::-webkit-scrollbar-thumb:hover {
background: #FFFFFF;
}

.component__container div {
min-width: 200px;
height: 200px;
background-color: #C56FFF;
flex-shrink: 0;
}

.component__shadow {
position: absolute;
top: 0;
bottom: calc(100% - 200px);
width: 50px;
pointer-events: none;
}

.scroll-shadow--left {
left: 0;
background: linear-gradient(to right, rgba(0, 0, 0, 0.5), transparent);
}

.scroll-shadow--right {
right: 0;
background: linear-gradient(to left, rgba(0, 0, 0, 0.5), transparent);
}

.scroll-shadow__shadow--hide {
display: none;
}

.component__container div {
background-repeat: no-repeat;
background-position: center;
}

.component__container div:nth-of-type(1) {
background-image: url(images/dosvg.svg);
}

.component__container div:nth-of-type(2) {
background-image: url(images/dosvg-heart.svg);
}

.component__container div:nth-of-type(3) {
background-image: url(images/dosvg-look.svg);
}

.component__container div:nth-of-type(4) {
background-image: url(images/dosvg-paw.svg);
}

.component__container div:nth-of-type(5) {
background-image: url(images/dosvg-sleep.svg);
}
</style>
</head>
<body>
<div class="component">
<div class="component__container">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>

<div class="component__shadow scroll-shadow scroll-shadow--left"></div>
<div class="component__shadow scroll-shadow scroll-shadow--right"></div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function () {
const container = document.querySelector('.component__container');
const shadowLeft = document.querySelector('.scroll-shadow--left');
const shadowRight = document.querySelector('.scroll-shadow--right');

function updateShadows() {
const scrollLeft = container.scrollLeft;
const maxScrollLeft = container.scrollWidth - container.clientWidth;

shadowLeft.classList.toggle('scroll-shadow__shadow--hide', scrollLeft <= 10);
shadowRight.classList.toggle('scroll-shadow__shadow--hide', scrollLeft >= maxScrollLeft - 10);
}

container.addEventListener('scroll', updateShadows);
window.addEventListener('resize', updateShadows);

updateShadows(); // Initial shadow update
});
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions recipes/horizontal-scroll-with-shadow/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: "Реализация горизонтального скролла с тенями"
description: ""
authors:
- punkmachine
related:
tags:
---
Loading