I'd like to change the picture using TweenMax and J-Query. But It is getting slower than the setInterval set.
I don't have any other settings, I'm only using them to change pictures. And in twinmax, there is no setinterval setting.
start at scale x : 0 on the left and shrink as I pass to the right, so that the background-image behind me changes at the specified time.
The time to change the picture is getting slower. I couldn't upload the picture because I didn't know how to upload it.
I want to convert at the same time, is there a better way? Can I do it with just the css and keyframe?
$(function() {
var roll = 1;
setInterval(function() {
roll++;
if (roll > 2) {
roll = 1;
}
$("#box1").attr("src", "assets/images/top/pc/main_" + roll + "_b.png");
}, 4000);
})
$(function() {
var roll = 1;
setInterval(function() {
roll++;
if (roll > 2) {
roll = 1;
}
$("#box2").attr("src", "assets/images/top/pc/main_" + roll + "_b.png");
}, 5000);
})
var tl = new TimelineMax({
repeat: -1,
repeatDelay: 3
});
tl.from(".layer1", 0.8, {
scaleX: 0,
transformOrigin: "left",
ease: 'expo.inOut'
});
tl.to(".layer1", 0.8, {
scaleX: 0,
transformOrigin: "right",
ease: 'expo.out'
});
var ta = new TimelineMax({
repeat: -1,
repeatDelay: 4
});
ta.from(".layer2", 0.8, {
scaleX: 0,
transformOrigin: "left",
ease: 'expo.inOut'
});
ta.to(".layer2", 0.8, {
scaleX: 0,
transformOrigin: "right",
ease: 'expo.out'
});
,
main {
position: relative;
width: 100%;
}
.box1 {
width: 40.4%;
position: absolute;
top: 3.7%;
left: 15%;
}
.box1 img {
width: 100%;
}
.box2 {
width: 19.9%;
position: absolute;
top: 3.7%;
left: 56.8%;
}
.box2 img {
width: 100%;
}
.layer1 {
background-color: #f85983;
position: absolute;
top: 0;
left: 0;
bottom: 0;
margin: auto;
width: 100%;
height: 100%;
}
.layer2 {
background-color: #f85983;
position: absolute;
top: 0;
left: 0;
bottom: 0;
margin: auto;
width: 100%;
height: 100%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.0.5/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.2/TweenMax.min.js"></script>
</head>
<body>
<div class="main">
<div class="box1">
<div class="layer1" id="layer1"></div>
<img id="box1" src="https://imgur.com/98BK2vZ" alt="">
</div>
<div class="box2">
<div class="layer2" id="layer2"></div>
<img id="box2" src="assets/images/top/pc/main_1_b.png" alt="">
</div>
</div>
</body>
</html>
I want to express the change of the image in the back as the pink layer passes through the header part.
I would like to express the same in 5 image boxes.
This site is for reference. I look forward to your kind cooperation.
https://a3-liber.com/index.html
here is sample video!!