From a2a932f31581da2d082604c551b386d607717a8d Mon Sep 17 00:00:00 2001 From: ppoffice Date: Sat, 3 Nov 2018 11:43:50 -0400 Subject: [PATCH] fix(*): change fallback font to sans and optimize back to top --- source/css/style.styl | 4 ++-- source/js/back-to-top.js | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/source/css/style.styl b/source/css/style.styl index ce7c475..f00a63f 100644 --- a/source/css/style.styl +++ b/source/css/style.styl @@ -1,4 +1,4 @@ -family-serif = "Ubuntu", "Roboto", "Open Sans", "Microsoft YaHei", serif +family-sans = "Ubuntu", "Roboto", "Open Sans", "Microsoft YaHei", sans-serif family-mono = "Source Code Pro", monospace, "Microsoft YaHei" /* --------------------------------- @@ -8,7 +8,7 @@ html font-size: 14px body - font-family: family-serif + font-family: family-sans background-color: #f7f7f7 @media screen and (min-width: 1280px) diff --git a/source/js/back-to-top.js b/source/js/back-to-top.js index 08fbf1c..11d2b3f 100644 --- a/source/js/back-to-top.js +++ b/source/js/back-to-top.js @@ -7,7 +7,7 @@ $(document).ready(function () { var lastScrollTop = 0; var rightMargin = 20; var bottomMargin = 20; - + var lastState = null; var state = { base: { classname: 'card has-text-centered', @@ -36,7 +36,24 @@ $(document).ready(function () { classname: state['mobile-hidden'].classname + ' rise-up', }); + function isStateEquals(prev, next) { + for (var prop in prev) { + if (!next.hasOwnProperty(prop) || next[prop] !== prev[prop]) { + return false; + } + } + for (var prop in next) { + if (!prev.hasOwnProperty(prop) || prev[prop] !== prev[prop]) { + return false; + } + } + return true; + } + function applyState(state) { + if (lastState !== null && isStateEquals(lastState, state)) { + return; + } $button.attr('class', state.classname); for (let prop in state) { if (prop === 'classname') { @@ -44,6 +61,7 @@ $(document).ready(function () { } $button.css(prop, state[prop]); } + lastState = state; } function isDesktop() {