Last active
January 25, 2016 07:52
-
-
Save supersha/feff2862d2271dd009b5 to your computer and use it in GitHub Desktop.
总是让浏览器显示滚动条,但是页面又不能滚动的问题
This file contains hidden or 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
// 有时候的场景是,弹窗之后,页面不能滚动,但是如果在有滚动条的情况下,滚动条消失,页面会左右晃动 | |
// 要让滚动条一直都存在,解决的办法如下: | |
// 在某个元素focus的时候,设置document.documentElement.style.overflow = 'hidden'; 但是设置document.body.style.overflow = 'scroll'; | |
// 在元素blur的时候,再重置回来auto | |
ue.addListener('focus', function(editor){ | |
$(document.body).css('overflow', 'scroll'); | |
document.documentElement.style.overflow = 'hidden'; | |
}); | |
ue.addListener('blur', function(editor){ | |
vm.checkContent(); | |
$(document.body).css('overflow', 'initial'); | |
document.documentElement.style.overflow = 'initial'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment