|
Server IP : 217.21.85.138 / Your IP : 216.73.216.103 Web Server : LiteSpeed System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64 User : u915722082 ( 915722082) PHP Version : 7.4.33 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u915722082/.nvm/../public_html/rkeventandmedia/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Smooth Sticky Video Banner</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
}
.spacer {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
background: #f0f0f0;
}
.video-banner {
position: relative;
height: 225vh;
}
.sticky-container {
position: relative;
height: 350vh; /* Increased for slower final transition */
}
.video-section {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
z-index: 99;
will-change: transform; /* Performance optimization */
}
.video-holder {
position: relative;
height: 100%;
width: 100%;
}
.video-holder video {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
.play-btn {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
cursor: pointer;
z-index: 3;
transition: opacity 0.3s ease;
}
.play-btn:hover {
transform: translate(-50%, -50%) scale(1.1);
}
.video-n-accordion {
position: absolute;
top: 100vh;
left: 0;
width: 100%;
z-index: 100;
will-change: transform; /* Performance optimization */
}
.accordion-holder {
padding: 0 60px 61px;
}
.video-n-accordion-container {
min-height: 500px;
position: relative;
background: #B90808;
margin-top: 250px;
z-index: 2;
padding: 30px 20px;
}
.copy-block {
display: flex;
justify-content: space-evenly;
gap: 160px;
}
.copy-block-text {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.copy-block-text h2 {
font-size: 50px;
font-weight: 500;
line-height: 1;
text-transform: uppercase;
color: #fff;
max-width: 650px;
margin-top: 38px;
margin-left: 10px;
}
.copy-block-text h2 span {
color: #0d0d17;
}
.copy-block-accordion {
padding-right: 15px;
}
.accordion-wrapper {
max-width: 554px;
margin-top: 50px;
}
.accordion-wrapper .item {
padding-top: 12px;
margin-bottom: 20px;
border-top: 1px solid #fff;
}
.accordion-wrapper .item .title {
position: relative;
color: #fff;
font-size: 21px;
font-weight: 400;
line-height: 18.196px;
letter-spacing: -.2px;
margin-bottom: 20px;
cursor: pointer;
transition: .3s;
}
.accordion-wrapper .item .title::after {
content: "+";
position: absolute;
right: 0;
font-size: 24px;
transition: transform 0.3s ease;
}
.accordion-wrapper .item.active .title::after {
content: "-";
}
.accordion-wrapper .item .content {
color: #fff;
opacity: 0;
max-height: 0;
overflow: hidden;
transition: all 0.3s ease;
font-size: 16px;
line-height: 21px;
letter-spacing: -.176px;
visibility: hidden;
}
.accordion-wrapper .item.active .content {
visibility: visible;
opacity: 1;
max-height: 200px;
transition: all 0.3s ease;
}
@media (max-width: 1440px) {
.accordion-holder {
padding: 0 50px 80px;
}
.video-n-accordion-container {
border-radius: 39px;
padding: 15px 0 15px;
margin-top: -102px;
}
.copy-block-text {
justify-content: unset;
gap: 227px;
}
.copy-block-text h2 {
margin-top: 35px;
margin-left: 20px;
font-size: 45px;
line-height: 45px;
letter-spacing: -1px;
margin-bottom: 0 !important;
}
.copy-block-accordion {
padding-right: 25px;
}
.accordion-wrapper {
max-width: 520px;
margin-top: 2rem;
}
.accordion-wrapper .item .content {
font-size: 15px;
line-height: 21px;
}
}
@media (max-width: 768px) {
.copy-block {
flex-direction: column;
gap: 0px;
}
.copy-block-text h2 {
font-size: 26px;
line-height: 1.2;
margin-left: 0;
}
.accordion-holder {
padding: 0px;
}
.video-n-accordion-container {
padding: 20px 15px;
margin-top: 200px;
border-radius: 0px !important;
}
}
</style>
</head>
<body>
<div class="spacer">Scroll down to see the effect</div>
<section class="video-banner">
<div class="sticky-container" id="stickyContainer">
<div class="video-section" id="videoSection">
<div class="video-holder">
<video autoplay muted loop playsinline>
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
</video>
<div class="play-btn" id="playVideo">
<svg xmlns="http://www.w3.org/2000/svg" width="248" height="248" viewBox="0 0 248 248" fill="none">
<circle cx="124" cy="124" r="110.5" stroke="white"></circle>
<g filter="url(#filter0_d_66_184)">
<path d="M94 72.0385L184 124L94 175.962L94 72.0385Z" stroke="white" shape-rendering="crispEdges"></path>
</g>
<defs>
<filter id="filter0_d_66_184" x="89.5" y="71.1725" width="99.5" height="113.655" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix>
<feOffset dy="4"></feOffset>
<feGaussianBlur stdDeviation="2"></feGaussianBlur>
<feComposite in2="hardAlpha" operator="out"></feComposite>
<feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"></feColorMatrix>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_66_184"></feBlend>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_66_184" result="shape"></feBlend>
</filter>
</defs>
</svg>
</div>
</div>
</div>
<div class="video-n-accordion" id="accordionSection">
<div class="accordion-holder container">
<div class="video-n-accordion-container">
<div class="copy-block">
<div class="copy-block-left copy-block-text">
<h2>Lorem, ipsum dolor <span>Rerum velit nisi</span> dolorum</h2>
</div>
<div class="copy-block-right copy-block-accordion">
<div class="accordion-wrapper">
<div class="item active">
<p class="title">Lorem ipsum dolor sit</p>
<p class="content">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Consequatur quis quo fugit voluptate officia vero accusamus non similique eos iure.</p>
</div>
<div class="item">
<p class="title">Lorem ipsum dolor sit</p>
<p class="content">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Consequatur quis quo fugit voluptate officia vero accusamus non similique eos iure.</p>
</div>
<div class="item">
<p class="title">Lorem ipsum dolor sit</p>
<p class="content">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Consequatur quis quo fugit voluptate officia vero accusamus non similique eos iure.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<div class="spacer">Content after the video section</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const stickyContainer = document.getElementById('stickyContainer');
const videoSection = document.getElementById('videoSection');
const accordionSection = document.getElementById('accordionSection');
// Accordion functionality
const accordionItems = document.querySelectorAll('.accordion-wrapper .item');
accordionItems.forEach(item => {
const title = item.querySelector('.title');
title.addEventListener('click', () => {
const isActive = item.classList.contains('active');
accordionItems.forEach(i => i.classList.remove('active'));
if (!isActive) {
item.classList.add('active');
}
});
});
function handleScroll() {
const containerRect = stickyContainer.getBoundingClientRect();
const containerHeight = stickyContainer.offsetHeight;
const windowHeight = window.innerHeight;
if (containerRect.top <= 0 && containerRect.bottom >= windowHeight) {
const scrolled = Math.abs(containerRect.top);
const totalScrollDistance = containerHeight - windowHeight;
const progress = Math.min(scrolled / totalScrollDistance, 1);
if (progress <= 0.35) {
// Phase 1: Accordion slides up smoothly (0% to 35%)
const slideProgress = progress / 0.35;
const easeProgress = easeOutCubic(slideProgress);
const slideDistance = easeProgress * windowHeight;
videoSection.style.position = 'fixed';
videoSection.style.top = '0px';
videoSection.style.transform = 'translateY(0)';
accordionSection.style.position = 'fixed';
accordionSection.style.top = '0px';
accordionSection.style.transform = `translateY(${windowHeight - slideDistance}px)`;
} else if (progress <= 0.65) {
// Phase 2: Both sections stay centered (35% to 65%)
videoSection.style.position = 'fixed';
videoSection.style.top = '0px';
videoSection.style.transform = 'translateY(0)';
accordionSection.style.position = 'fixed';
accordionSection.style.top = '0px';
accordionSection.style.transform = 'translateY(0)';
} else {
// Phase 3: Both sections move together slowly (65% to 100%)
const moveProgress = (progress - 0.65) / 0.35;
const easeMoveProgress = easeInOutCubic(moveProgress);
const moveDistance = easeMoveProgress * windowHeight;
videoSection.style.position = 'fixed';
videoSection.style.top = '0px';
videoSection.style.transform = `translateY(-${moveDistance}px)`;
accordionSection.style.position = 'fixed';
accordionSection.style.top = '0px';
accordionSection.style.transform = `translateY(-${moveDistance}px)`;
}
} else {
videoSection.style.position = 'absolute';
videoSection.style.top = '0';
videoSection.style.transform = 'translateY(0)';
accordionSection.style.position = 'absolute';
accordionSection.style.top = '100vh';
accordionSection.style.transform = 'translateY(0)';
}
}
// Easing functions for smooth transitions
function easeOutCubic(t) {
return 1 - Math.pow(1 - t, 3);
}
function easeInOutCubic(t) {
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
}
// Optimized scroll handling with requestAnimationFrame
let ticking = false;
function onScroll() {
if (!ticking) {
window.requestAnimationFrame(() => {
handleScroll();
ticking = false;
});
ticking = true;
}
}
window.addEventListener('scroll', onScroll, { passive: true });
handleScroll(); // Initial call
// Video play/pause functionality
const playBtn = document.getElementById('playVideo');
const video = document.querySelector('video');
playBtn.addEventListener('click', () => {
if (video.paused) {
video.play();
playBtn.style.opacity = '0';
} else {
video.pause();
playBtn.style.opacity = '1';
}
});
video.addEventListener('pause', () => {
playBtn.style.opacity = '1';
});
video.addEventListener('play', () => {
playBtn.style.opacity = '0';
});
});
</script>
</body>
</html>