Skip to content

Commit

Permalink
feat(scrollreveal&style.css): slow network
Browse files Browse the repository at this point in the history
  • Loading branch information
MHuiG committed Jun 16, 2022
1 parent c9c823c commit c31f54a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions layout/_partial/scripts/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@

<%- partial('content-visibility-scroll-fix') %>

<%- partial('../../_plugins/slow-network/script') %>

<% if (theme.structured_data && theme.structured_data.enable) { %>
<%- structured_data() %>
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion layout/_plugins/end-of-support/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (/*@cc_on!@*/false || (!!window.MSInputMethodContext && !!document.documentMo
'<div class="kill-ie">'+
`<span class="kill-t"><b><%- __('kill.title')%></b></span><br/>`+
`<span class="kill-c"><%- __('kill.ie')%></span><br/>`+
`<a href="https://www.microsoft.com/zh-cn/WindowsForBusiness/End-of-IE-support"><strong><%- __('kill.more')%></strong></a>`+
`<a href="https://blogs.windows.com/windowsexperience/2021/05/19/the-future-of-internet-explorer-on-windows-10-is-in-microsoft-edge/"><strong><%- __('kill.more')%></strong></a>`+
'</div>');
</script>
<% } %>
Expand Down
14 changes: 14 additions & 0 deletions layout/_plugins/slow-network/script.ejs
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>

0 comments on commit c31f54a

Please sign in to comment.