How to prevent image flash when transitioning with blur?

依然范特西╮ 提交于 2019-12-02 14:36:04

问题


How to prevent flash on end of transition on filter: blur effect? (I'm using chrome) Snippet below to show problem.

$(window).on('load',function( event ){
  setTimeout(function(){
    $('.sec').addClass('active')
  },1000)
})
.sec {
  margin: 0 auto;
  width: 700px;
  height: 500px;
  background-image: url(http://placekitten.com/700/500);
  background-size: cover;
  
    -webkit-filter: blur(20px);
	  -moz-filter: blur(20px);
	  -o-filter: blur(20px);
	  -ms-filter: blur(20px);
	  filter: blur(20px);
}
.sec.active {
  -webkit-filter: blur(0px);
	-moz-filter: blur(0px);
	-o-filter: blur(0px);
	-ms-filter: blur(0px);
	filter: blur(0px);
	transition: all 3s ease, transform 1s ease-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sec">
  
</div>

回答1:


An idea is to avoid the blur to go to 0, you may consider a value close like 0.5px

$(window).on('load', function(event) {
  setTimeout(function() {
    $('.sec').addClass('active')
  }, 1000)
})
.sec {
  margin: 0 auto;
  width: 700px;
  height: 500px;
  background-image: url(http://placekitten.com/700/500);
  background-size: cover;
  filter: blur(20px);
}

.sec.active {
  filter: blur(0.5px);
  transition: all 3s ease, transform 1s ease-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sec">

</div>


来源:https://stackoverflow.com/questions/50249520/how-to-prevent-image-flash-when-transitioning-with-blur

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!