hej, czy w takim kole po zakręceniu da się zrobić aby zawsze wypadało na środek danej ćwiartki czyli:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
* {
margin: 0;
padding: 0;
}
a {
color: #34495e;
}
/*WRAPPER*/
#wrapper {
margin: 40px auto 0;
width: 266px;
position: relative;
}
#txt {
color: red;
}
#inner-wheel-sec {
width: 250px;
height: 250px;
transform: rotate(-13deg);
}
/*WHEEL*/
#wheel {
width: 250px;
height: 250px;
border-radius: 50%;
position: relative;
overflow: hidden;
transform: rotate(0deg);
}
#wheel:before {
content: '';
position: absolute;
border: 4px solid rgba(0, 0, 0, 0.1);
width: 242px;
height: 242px;
border-radius: 50%;
z-index: 1000;
}
#inner-wheel {
width: 100%;
height: 100%;
-webkit-transition: all 6s cubic-bezier(0, .99, .44, .99);
-moz-transition: all 6 cubic-bezier(0, .99, .44, .99);
-o-transition: all 6s cubic-bezier(0, .99, .44, .99);
-ms-transition: all 6s cubic-bezier(0, .99, .44, .99);
transition: all 6s cubic-bezier(0, .99, .44, .99);
}
#wheel div.sec {
position: absolute;
width: 50%;
height: 50%;
transform-origin: bottom right;
transform: rotate(calc(60deg * var(--i)));
clip-path: polygon(0 0, 75% 0, 100% 100%, 0 75%);
}
#spin {
width: 68px;
height: 68px;
position: absolute;
top: 50%;
left: 50%;
margin: -34px 0 0 -34px;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.1) 0px 3px 0px;
z-index: 1000;
cursor: pointer;
}
</style>
<body>
<div id="wheel">
<div id="inner-wheel">
<div id="inner-wheel-sec">
<div class="sec" style="--i:1; background-color: red;"></div>
<div class="sec" style="--i:2; background-color: green;"></div>
<div class="sec" style="--i:3; background-color: red;"></div>
<div class="sec" style="--i:4; background-color: green;"></div>
<div class="sec" style="--i:5; background-color: red;"></div>
<div class="sec" style="--i:6; background-color: green;"></div>
</div>
</div>
<div id="spin">
<div id="inner-spin"></div>
</div>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4="
crossorigin="anonymous"></script>
<script>
var degree = 1800;
var clicks = 0;
$(document).ready(function () {
$('#spin').click(function () {
clicks++;
var newDegree = degree * clicks;
var extraDegree = Math.floor(Math.random() * (360 - 1 + 1)) + 1;
totalDegree = newDegree + extraDegree;
$('#wheel .sec').each(function () {
var t = $(this);
var noY = 0;
var c = 0;
var n = 700;
var interval = setInterval(function () {
c++;
if (c === n) {
clearInterval(interval);
}
var aoY = t.offset().top;
$("#txt").html(aoY);
console.log(aoY);
if (aoY < 23.89) {
console.log('<<<<<<<<');
$('#spin').addClass('spin');
setTimeout(function () {
$('#spin').removeClass('spin');
}, 100);
}
}, 10);
$('#inner-wheel').css({
'transform': 'rotate(' + totalDegree + 'deg)'
});
noY = t.offset().top;
});
});
});
</script>
</html>