Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mobile scroll menu display bug #737

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion layout/_partial/css.ejs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<link rel="stylesheet" type="text/css" href="<%=config.root%>./main.0cf68a.css">
<link rel="stylesheet" type="text/css" href="<%=config.root%>./main.785ee2.css">
5 changes: 1 addition & 4 deletions layout/_partial/script.ejs

Large diffs are not rendered by default.

25 changes: 7 additions & 18 deletions source-src/js/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,17 @@ function tabActive() {
}

function getElementLeft(element) {    
var actualLeft = element.offsetLeft;    
var current = element.offsetParent;    
while (current !== null) {      
actualLeft += current.offsetLeft;    
current = current.offsetParent;  
}  
var actualLeft = element.getBoundingClientRect().left;  
return actualLeft;
}  
function getElementTop(element) {    
var actualTop = element.offsetTop;    
var current = element.offsetParent;    
while (current !== null) {      
actualTop += current.offsetTop;      
current = current.offsetParent;    
}    
var actualTop = element.getBoundingClientRect().top;    
return actualTop;  
}

function scrollStop($dom, top, limit, zIndex, diff) {
function scrollStop($dom, limit, zIndex, diff) {
let nowLeft = getElementLeft($dom)
let nowTop = getElementTop($dom) - top

let nowTop = getElementTop($dom)
if (nowTop - limit <= diff) {
let $newDom = $dom.$newDom
if (!$newDom) {
Expand Down Expand Up @@ -75,8 +64,8 @@ function scrollStop($dom, top, limit, zIndex, diff) {
function handleScroll() {
let $overlay = document.querySelector('.js-overlay')
let $menu = document.querySelector('.js-header-menu')
scrollStop($overlay, document.body.scrollTop, -63, 2, 0)
scrollStop($menu, document.body.scrollTop, 1, 3, 0)
scrollStop($overlay, -63, 2, 0)
scrollStop($menu, 1, 3, 0)
}

function bindScroll() {
Expand Down Expand Up @@ -104,4 +93,4 @@ addLoadEvent(function() {
})

module.exports = {
}
}
1 change: 1 addition & 0 deletions source/main.785ee2.css

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions source/main.785ee2.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions source/mobile.fb128e.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions source/slider.22b85c.js

Large diffs are not rendered by default.