jlmakes / jlmakes/scrollreveal

Viewport issue on slider

Open
#567 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22.5k
Forks
2.2k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/jlmakes/scrollreveal/assets/69580797/591fd11f-e3ab-4030-9b88-664ce7766582

Replacing the following lines in `isElementVisible()` function solves the problem of viewport issue on slider.
```
function isElementVisible(element) {
...
var elementRect = element.node.getBoundingClientRect();
var geoBounds = element.geometry.bounds;
var highestBound = {
left: Math.min(elementRect.left, geoBounds.left),
right: Math.max(elementRect.right, geoBounds.right),
top: Math.max(elementRect.top, geoBounds.top),
bottom: Math.max(elementRect.bottom, geoBounds.bottom),
}

var elementBounds = {
top: highestBound.top + element.geometry.height * viewFactor,
right: highestBound.right - element.geometry.width * viewFactor,
bottom: highestBound.bottom - element.geometry.height * viewFactor,
left: highestBound.left + element.geometry.width * viewFactor
};
....
}
```

https://github.com/jlmakes/scrollreveal/assets/69580797/32b2e091-6f58-4598-83f0-434b9aa8fd52

But, you have to call ScrollReveal().delegate() function on the corresponding event listeners. Because ScrollReveal.js only works on scroll and resize event.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the isElementVisible() function and reproduce the viewport issue on the slider shown in the linked examples. Check how the element rectangle and geometry bounds determine visibility, and inspect the related ScrollReveal().delegate() event listeners. Done means slider elements receive the expected reveal behavior when their viewport position changes, not only on scroll or resize.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.