Skip to content

Instantly share code, notes, and snippets.

@kayac-chang
Created April 30, 2018 16:11
Show Gist options
  • Save kayac-chang/4f24337dd7f08404ccc06caf2eef1635 to your computer and use it in GitHub Desktop.
Save kayac-chang/4f24337dd7f08404ccc06caf2eef1635 to your computer and use it in GitHub Desktop.
trigger Mask
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