Skip to content

Instantly share code, notes, and snippets.

@6174
Last active December 21, 2015 10:19
Show Gist options
  • Save 6174/6291441 to your computer and use it in GitHub Desktop.
Save 6174/6291441 to your computer and use it in GitHub Desktop.
mobile web 下面强制浏览器重渲染页面。 // 这种问题一般出现在动态生成的html当中, 如果这部分动态生成的一开始就被隐藏, 那么以后出现的时候不会被浏览器渲染。
/**
* web 浏览器有这样的一类问题:
* 当某些内容被隐藏, 过一段时间需要被显示 显示出来, 这个时候可能导致浏览器不会渲染被隐藏
* 的内容, 可以通过旋转屏幕等方式强制浏览器重新渲染页面, 下面是一个比较笨的解决方法。 求更好的解决方法
*/
function reRender(){
document.body.style.display = 'none';
setTimeout(function(){
document.body.style.display = 'block';
}, 0);
}
/**
* 类似的方法, 只要能够触发浏览器重渲染就行, 那么对于我这里的问题, 解决方案是这样的
*/
$('.codeContainer').bind('scroll', function(){
console.log('scroll');
var $ul = $(this).find('ul');
$ul.css('opacity', 0.99);
setTimeout(function(){
$ul.css('opacity', 1);
}, 0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment