-
Notifications
You must be signed in to change notification settings - Fork 602
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
Feature/watch visibility #1032
base: master
Are you sure you want to change the base?
Feature/watch visibility #1032
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -752,6 +752,27 @@ proto.queryCell = function( selector ) { | |
return this.getCell( selector ); | ||
}; | ||
|
||
proto.checkVisibility = function() { | ||
var viewportX = this.viewport.getBoundingClientRect().x; | ||
var viewportWidth = this.viewport.offsetWidth; | ||
|
||
this.cells.forEach(function (cell) { | ||
var cellX = cell.element.getBoundingClientRect().x - viewportX; | ||
var isVisible = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I have added a test to check if the value of This is not an ideal solution as I am getting flashing before a slide comes to rest, but it is solving the issue in my use case. |
||
(cellX + cell.size.innerWidth > viewportX) && (cellX + cell.size.innerWidth < viewportWidth) || | ||
(cellX > viewportX) && (cellX < viewportWidth) | ||
); | ||
|
||
if (isVisible) { | ||
cell.element.classList.add('is-visible'); | ||
cell.element.removeAttribute('aria-hidden'); | ||
} else { | ||
cell.element.classList.remove('is-visible'); | ||
cell.element.setAttribute('aria-hidden', true); | ||
} | ||
}); | ||
}; | ||
|
||
// -------------------------- events -------------------------- // | ||
|
||
proto.uiChange = function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my testing,
isVisible
will be false when theis-selected
cell is itself wider than the browser window, despite that the cell is obviously visible (being theis-selected
cell centered on screen).