Skip to content

Instantly share code, notes, and snippets.

@supersha
Last active January 25, 2016 07:52
Show Gist options
  • Save supersha/feff2862d2271dd009b5 to your computer and use it in GitHub Desktop.
Save supersha/feff2862d2271dd009b5 to your computer and use it in GitHub Desktop.
总是让浏览器显示滚动条,但是页面又不能滚动的问题
// 有时候的场景是,弹窗之后,页面不能滚动,但是如果在有滚动条的情况下,滚动条消失,页面会左右晃动
// 要让滚动条一直都存在,解决的办法如下:
// 在某个元素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