I have a div with these styles
<div :class="$style.holder">
<div :class="$style.inner" :style="{'background-position-x': bgPos + '%'}"></div>
</div>
.holder {
height: 60%;
width: 100%;
position: absolute;
top: 40%;
left: 0;
}
.inner{
background-image: url('img.png');
background-repeat: repeat-x;
background-size: auto 100%;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 70%;
transform: translateZ(1px);
}
I change bgPos or background position x
of element every second with JS
this.bgPos += (now - lastTime) * (window.innerWidth / window.innerHeight)
lastTime = now;
The problem is that when screen is certain height (maybe around 896px
and smaller) the image starts to move from left to right and when it is more than 896px
is starts to move from right to left.
But the background-position-x parametrs for both situatuations is positive, so it is 100%, 120% etc.
I can't figure out why height affect the direction of the image movement this way?