minor fixes
This commit is contained in:
parent
6a52ee2cf5
commit
d334cf8787
2 changed files with 2 additions and 32 deletions
|
@ -279,7 +279,7 @@ What if we'd like to fix some arguments, but not the context `this`? For example
|
|||
|
||||
The native `bind` does not allow that. We can't just omit the context and jump to arguments.
|
||||
|
||||
Fortunately, a helper function `partial` for binding only arguments can be easily implemented.
|
||||
Fortunately, a function `partial` for binding only arguments can be easily implemented.
|
||||
|
||||
Like this:
|
||||
|
||||
|
|
|
@ -169,39 +169,9 @@
|
|||
* It's enough that the top or bottom edge of the element are visible
|
||||
*/
|
||||
function isVisible(elem) {
|
||||
|
||||
let coords = elem.getBoundingClientRect();
|
||||
|
||||
let windowHeight = document.documentElement.clientHeight;
|
||||
|
||||
// top elem edge is visible OR bottom elem edge is visible
|
||||
let topVisible = coords.top > 0 && coords.top < windowHeight;
|
||||
let bottomVisible = coords.bottom < windowHeight && coords.bottom > 0;
|
||||
|
||||
return topVisible || bottomVisible;
|
||||
// todo: your code
|
||||
}
|
||||
|
||||
/**
|
||||
A variant of the test that considers the element visible if it's no more than
|
||||
one page after/behind the current screen.
|
||||
|
||||
function isVisible(elem) {
|
||||
|
||||
let coords = elem.getBoundingClientRect();
|
||||
|
||||
let windowHeight = document.documentElement.clientHeight;
|
||||
|
||||
let extendedTop = -windowHeight;
|
||||
let extendedBottom = 2 * windowHeight;
|
||||
|
||||
// top visible || bottom visible
|
||||
let topVisible = coords.top > extendedTop && coords.top < extendedBottom;
|
||||
let bottomVisible = coords.bottom < extendedBottom && coords.bottom > extendedTop;
|
||||
|
||||
return topVisible || bottomVisible;
|
||||
}
|
||||
*/
|
||||
|
||||
function showVisible() {
|
||||
for (let img of document.querySelectorAll('img')) {
|
||||
let realSrc = img.dataset.src;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue