svg-高斯模糊+swiper伦播

时间:2023-12-16 19:47:14
 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="basic/css/swiper.min.css"/>
<style type="text/css">
.gaosi{
filter:url("#f1");
}
.swiper-container{
width: 100%;
height: 300px;
overflow: hidden;
}
img{
width: 100%;
height: 100%;
} </style>
</head>
<body>
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"
viewBox="0,0,500,500" width="500" height="" aria-labelledby="title desc">
<title id="title"></title>
<desc id="desc"></desc>
<defs>
<filter id='f1'>
<feGaussianBlur in = "SourceGraphic" stdDeviation="0" id="fe"/>
</filter>
</defs> <div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide"><img src="img/001.jpg" class="img gaosi"/></div>
<div class="swiper-slide"><img class = "img gaosi" src="img/002.jpg"/></div>
<div class="swiper-slide"><img class = "img gaosi" src="img/003.jpg"/></div>
</div>
<div class="swiper-pagination"> </div>
</div>
</svg>
<script type="text/javascript" src="basic/js/swiper.min.js"></script>
<script type="text/javascript">
var mySwiper = new Swiper('.swiper-container',{
pagination :'.swiper-pagination',
onSlideChangeStart: function(swiper){
var fe = document.querySelector('#fe');
fe.setAttribute('stdDeviation',15);
},
onSlideChangeEnd: function(swiper){
var fe = document.querySelector('#fe');
var x = 15;
var timer = setInterval(function(){
x--;
fe.setAttribute('stdDeviation',x);
if(x<=0){
clearInterval(timer)
}
},40)
}
}) </script>
</body>
</html>