-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scrollreveal&style.css): slow network
- Loading branch information
Showing
3 changed files
with
17 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script> | ||
document.onreadystatechange = function () { | ||
if (document.readyState == 'complete') { | ||
// 页面加载完毕 样式加载失败,或是当前网速慢,或是开启了省流模式 | ||
const { saveData, effectiveType } = navigator.connection || navigator.mozConnection || navigator.webkitConnection || {} | ||
if (getComputedStyle(document.querySelector("#safearea"), null)["display"] == "none" || saveData || /2g/.test(effectiveType)) { | ||
document.querySelectorAll(".reveal").forEach(function (e) { | ||
e.style["opacity"] = "1"; | ||
}); | ||
document.querySelector("#safearea").style["display"] = "block"; | ||
} | ||
} | ||
} | ||
</script> |