Skip to content

Commit

Permalink
fix hover on phones
Browse files Browse the repository at this point in the history
  • Loading branch information
MoayedHajiAli committed Jun 23, 2024
1 parent ba6ad9b commit 80c2db1
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -538,19 +538,19 @@ <h2 class="title">Improvements</h2>
<br />
<script>
document.addEventListener('DOMContentLoaded', function () {
const videoItems = document.querySelectorAll('.video-item'); // Get all video item elements
const videoItems = document.querySelectorAll('.video-item');
let userInteracted = false;

document.body.addEventListener('click', function() {
userInteracted = true; // Set to true on any click on the page
userInteracted = true;
});

videoItems.forEach(function(item) {
const video = item.querySelector('.video-player');
const caption = item.querySelector('.video-caption');

item.addEventListener('mouseenter', function() {
if (userInteracted) { // Only apply effects if the user has interacted with the page
if (userInteracted) {
if (video.muted) {
video.muted = false;
video.currentTime = 0;
Expand All @@ -565,7 +565,44 @@ <h2 class="title">Improvements</h2>
caption.style.opacity = '0.5';
});
});
});
});


document.addEventListener('DOMContentLoaded', function () {
const videoItems = document.querySelectorAll('.video-item'); // Get all video item elements
let userInteracted = false;

function isMobileDevice() {
return /Mobi|Android/i.test(navigator.userAgent);
}

document.body.addEventListener('click', function() {
userInteracted = true; // Set to true on any click on the page
});

videoItems.forEach(function(item) {
const video = item.querySelector('.video-player');
const caption = item.querySelector('.video-caption');

item.addEventListener('mouseenter', function() {
if (userInteracted && !isMobileDevice()) { // Only apply effects if the user has interacted with the page and is not on mobile
if (video.muted) {
video.muted = false;
video.currentTime = 0;
}
caption.style.opacity = '1';
}
});

item.addEventListener('mouseleave', function() {
if (!isMobileDevice() && !video.muted) {
video.muted = true;
}
caption.style.opacity = '0.5';
});
});
});


document.getElementById('menu-button').addEventListener('click', function() {
const navLinks = document.getElementById('nav-links');
Expand Down

0 comments on commit 80c2db1

Please sign in to comment.