Created
October 30, 2017 09:53
#Codevember 08 - Animated SVG Turbulence Filter
This file contains 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
#container | |
#water | |
svg(xlmns='http://www.w3.org/2000/svg' version='1.1') | |
filter#turbulence(filterUnits='objectBoundingBox' x='0' y='0' width='100%' height='100%') | |
feTurbulence#feturbulence(type='fractalNoise' numOctaves='3' seed='2') | |
feDisplacementMap(xChannelSelector='G' yChannelSelector='B' scale='20' in='SourceGraphic') | |
a#codepen-link(href='https://www.codepen.io/seanfree' target='_blank') |
This file contains 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
var timeline = new TimelineMax({ | |
repeat: -1, | |
yoyo: true | |
}), | |
feTurb = document.querySelector('#feturbulence'); | |
timeline.add( | |
TweenMax.to(feTurb, 8, { | |
onUpdate: function() { | |
var bfX = this.progress() * 0.005 + 0.015, //base frequency x | |
bfY = this.progress() * 0.05 + 0.1, //base frequency y | |
bfStr = bfX.toString() + ' ' + bfY.toString(); //base frequency string | |
feTurb.setAttribute('baseFrequency', bfStr); | |
} | |
}), 0 | |
); |
This file contains 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
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js"></script> |
This file contains 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
$lakeImg: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/544318/lake.jpg' | |
body | |
background: #cfcfcf | |
#container, #water | |
background-image: url($lakeImg) | |
background-position: center bottom | |
#container | |
position: absolute | |
top: calc(50% - 206px) | |
left: calc(50% - 275px) | |
height: 412px | |
width: 550px | |
&:after | |
position: absolute | |
top: 10% | |
left: 2.5% | |
z-index: -1 | |
content: '' | |
display: block | |
height: 95% | |
width: 95% | |
background: #0f0f0f | |
filter: blur(30px) | |
#water | |
position: absolute | |
bottom: 0 | |
width: 100% | |
height: 66% | |
filter: url('#turbulence') | |
overflow: hidden | |
#codepen-link | |
position: absolute | |
bottom: 30px | |
right: 30px | |
height: 40px | |
width: 40px | |
z-index: 10 | |
border-radius: 50% | |
box-sizing: border-box | |
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/544318/logo.jpg') | |
background-position: center center | |
background-size: cover | |
opacity: 0.5 | |
transition: all 0.25s | |
&:hover | |
opacity: 0.8 | |
box-shadow: 0 0 6px #0c0c0c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment