Created
April 30, 2018 16:11
-
-
Save kayac-chang/4f24337dd7f08404ccc06caf2eef1635 to your computer and use it in GitHub Desktop.
trigger Mask
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
function triggerMask() { | |
// 1. 找到遮罩 | |
let mask = document.getElementById("mask") | |
// 2. 當我滑到 多少高度時 | |
let flag = window.scrollY >= 50 | |
// 把遮罩打開 | |
mask.style.display = flag ? "none" : "block" | |
} | |
// For Mobile | |
document.addEventListener("touchmove",triggerMask) | |
// For Browser | |
document.addEventListener("scroll", triggerMask) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment