I want to create key frame dynamically, i need to show sheen effect over the image find the code is below.
var logo = document.querySelector('#main-logo');
var divshinny = document.querySelector('.shiny-effect');
divshinny.style.height = logo.offsetHeight + 'px';
divshinny.style.webkitMaskSize = logo.offsetWidth + 'px';
.logo-animation {
width: 40%;
margin: auto;
height: 100%;
position: absolute;
}
.logo-animation #logo-shinny {
position: relative;
display: block;
width: 100%;
height: 90%;
text-align: center;
margin: 5% auto;
}
.logo-animation #logo-shinny img {
width: 100%;
}
.logo-animation #logo-shinny .shiny-effect {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(90deg, rgba(255, 255, 255, 0) 90%, rgba(255, 255, 255, 0.5) 98%, rgba(255, 255, 255, 0) 100%) no-repeat;
-webkit-mask: url("http://dev.iamvdo.me/newLogoCSS3create2.png") center;
-webkit-mask-size: 500px 361px;
-webkit-mask-repeat: no-repeat;
-webkit-animation-name: ShineAnimation;
-webkit-animation-duration: 3s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
@-webkit-keyframes ShineAnimation {
from {
background-position: -200px 0px;
}
to {
background-position: 0px 0px;
}
}
<div class="logo-animation">
<div id="logo-shinny">
<img src="http://dev.iamvdo.me/newLogoCSS3create2.png" id="main-logo" />
<div class="shiny-effect"></div>
</div>
</div>
The issue is image resizes based on the screen size for bigger screen the image size will be bigger, but the sheen effect is based on background position in px, my question is can i directly create the keyframes using javascript based on the image size. if there is any other way this can be achieved please let me know.
Thanks in advance.