This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(scroll): 🐛Fix scroll not triggered
- Loading branch information
Showing
7 changed files
with
140 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"> | ||
<title>impression</title> | ||
<link rel="stylesheet" href="manual-test.css"> | ||
<style> | ||
.scroll-container { | ||
overflow-x: scroll; | ||
width: 100%; | ||
} | ||
|
||
.container { | ||
width: 1000px; | ||
font-size: 0; | ||
} | ||
|
||
.element { | ||
display: inline-block; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="scroll-container"> | ||
<div class="container"> | ||
<div class="element" data-impression-unique-id="1"></div> | ||
<div class="element" data-impression-unique-id="2"></div> | ||
<div class="element" data-impression-unique-id="3"></div> | ||
<div class="element" data-impression-unique-id="4"></div> | ||
<div class="element" data-impression-unique-id="5"></div> | ||
<div class="element" data-impression-unique-id="6"></div> | ||
<div class="element" data-impression-unique-id="7"></div> | ||
<div class="element" data-impression-unique-id="8"></div> | ||
<div class="element" data-impression-unique-id="9"></div> | ||
<div class="element" data-impression-unique-id="10"></div> | ||
</div> | ||
</div> | ||
<script src="../bundle/impression.rollup.js"></script> | ||
<script> | ||
function init() { | ||
const SELECTOR_ALL = '[data-impression-unique-id]'; | ||
const impression = new Impression({ | ||
tolerance: 0, | ||
debounce: 100, | ||
}); | ||
let flagBegin = 0; | ||
const callbackBegin = (el, info) => { | ||
flagBegin++; | ||
console.log('begin', flagBegin, el, info); | ||
}; | ||
let flagEnd = 0; | ||
const callbackEnd = (el, info) => { | ||
flagEnd++; | ||
console.log('end', flagEnd, el, info); | ||
}; | ||
|
||
impression.on('begin', SELECTOR_ALL, callbackBegin); | ||
impression.on('end', SELECTOR_ALL, callbackEnd); | ||
|
||
impression.scan(); | ||
|
||
return impression; | ||
} | ||
|
||
if (document.readyState === 'complete') { | ||
window.impression = init() | ||
} else { | ||
window.addEventListener('load', () => { | ||
window.impression = init(); | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* @since 2019-05-29 20:58 | ||
* @author vivaxy | ||
*/ | ||
|
||
html { | ||
width: 100%; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
width: 100%; | ||
} | ||
|
||
.element { | ||
width: 100px; | ||
height: 100px; | ||
} | ||
|
||
.element:nth-child(6n) { | ||
background-color: #f99; | ||
} | ||
|
||
.element:nth-child(6n+1) { | ||
background-color: #9f9; | ||
} | ||
|
||
.element:nth-child(6n+2) { | ||
background-color: #99f; | ||
} | ||
|
||
.element:nth-child(6n+3) { | ||
background-color: #ff9; | ||
} | ||
|
||
.element:nth-child(6n+4) { | ||
background-color: #f9f; | ||
} | ||
|
||
.element:nth-child(6n+5) { | ||
background-color: #9ff; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters