Я новичок в Javascript. Я хочу такую анимацию:
Во-первых, это изображение с закрытой сумкой. Когда человек нажимает на изображение с сумкой, изображение меняется на открытую сумку.
Затем объекты (я не знаю javascipt литературные, я имею в виду div, которые содержат изображение) начинают выходить из сумки с анимацией paraboli c. Когда анимация завершается sh, все элементы будут на одном на основе (выровнять) с сумкой.
Затем объекты начнут на go вправо. Каждый элемент, кроме первого, имеет задержку, так как мс также интервал между ними.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div.2").animate({left: '70vw'});
$("div.1").delay( 800 ).animate({left: '40vw'});
});
});
</script>
</head>
<body>
<button>Start Animation</button>
<p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p>
<div class="1" style="background:#98bf21;height:100px;width:100px;position:absolute;">
x
</div>
<div class="2" style="background:pink;height:100px;width:100px;position:absolute;"></div>
последняя форма:
http://migrate2.deniz-tasarim.site/wp-content/ball/ball.php
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<style>
.bag {
display: block;
width: 240px;
height: 120px;
background-image: url("http://migrate2.deniz-tasarim.site/wp-content/ball/New Project240x120.png");
position: relative;
top: 150px;
margin-left: auto!important;
margin-right: auto!important;
cursor: pointer;
}
.holder {
position: absolute;
top: 0;
left: 0;
}
.mask {
position: absolute;
top: 0;
left: 0;
width: 120px;
height: 60px;
display: block;
}
.dot {
position: absolute;
left: 95px;
top: 0;
}
.dot::after {
content: '';
display: block;
width: 50px;
height: 150px;
border-radius: 0px;
z-index: 1;
}
.dot1::after {
background-image: url("http://migrate2.deniz-tasarim.site/wp-content/ball/New Project (7).png");
}
.dot2::after {
background-image: url("http://migrate2.deniz-tasarim.site/wp-content/ball/New Project (8).png");
}
.bag.open,
.bag.open .mask {
background-image: url("http://migrate2.deniz-tasarim.site/wp-content/ball/New%20Project%20(1)240x120.png");
}
.bag.open .dot1 {
animation: xAxis1 2.5s cubic-bezier(0.02, 0.01, 0.21, 1);
animation-fill-mode: forwards;
}
.bag.open .dot1::after {
animation: yAxis1 2.5s cubic-bezier(0.3, 0.27, 0.07, 1.64);
animation-fill-mode: forwards;
}
.bag.open .dot2 {
animation: xAxis2 2.5s cubic-bezier(0.02, 0.01, 0.21, 1);
animation-fill-mode: forwards;
}
.bag.open .dot2::after {
animation: yAxis2 2.5s cubic-bezier(0.3, 0.27, 0.07, 1.64);
animation-fill-mode: forwards;
}
@keyframes yAxis1 {
50% {
animation-timing-function: cubic-bezier(0.02, 0.01, 0.21, 1);
transform: translateY(-100px);
}
100% {
animation-timing-function: cubic-bezier(0.02, 0.01, 0.21, 1);
transform: translateY(70px);
}
}
@keyframes xAxis1 {
100% {
animation-timing-function: cubic-bezier(0.3, 0.27, 0.07, 1.64);
transform: translateX(150px);
}
}
@keyframes yAxis2 {
50% {
animation-timing-function: cubic-bezier(0.02, 0.01, 0.21, 1);
transform: translateY(-100px);
}
100% {
animation-timing-function: cubic-bezier(0.02, 0.01, 0.21, 1);
transform: translateY(70px);
}
}
@keyframes xAxis2 {
100% {
animation-timing-function: cubic-bezier(0.3, 0.27, 0.07, 1.64);
transform: translateX(-150px);
}
}
</style>
<script>
$(document).ready(function() {
$(".bag").on("click", function() {
$(this).toggleClass("open");
});
});
</script>
</head>
<body>
<div class="bag">
<div class="dot dot1">
Ekipman
</div>
<div class="dot dot2">
Kıyafet
</div>
<div class="mask"></div>
</div>
</body>
</html>