I usually don’t publish it myself. Usually I find what I need through other threads, so I'm sorry if any of this is in the wrong place or incorrectly formatted. I have never done this before.
So the situation :
I am trying to rebuild my site and I decided to go with X Theme for WordPress. This is mostly great, but several times when I wanted to tweak and get around X, it turned out to be a bit more complicated. If you know a way to do this in X that will achieve this without doing custom coding, I'm all ears.
So here is what I am trying to do :
I came up with an idea for a circular menu that positions its items, where the top item is “selected” in the menu. So it would look something like this in terms of layout:
(Sorry, apparently I'm too new to using images in my posts: /)
Main condition : http://i.stack.imgur.com/Gs2Nz.jpg
Now that the user had to click on an item, I would like it to rotate the newly selected item up, where item "1" was in the previous image. So it would be like this:
Menu items rotate if user-selected item 3 : http://i.stack.imgur.com/KWseu.jpg
:
, , , , - .
, , , CSS. , .
, , .
, JQuery Animate(), JavaScript, css "top" "left" , , .
, X-customizer , JavaScript. , JavaScript/JQuery CSS , , JQuery/CSS ..
:
, . , , , . , .
, , , . ! !:)
UPDATE:
, , , . , Javascript X-Theme CSS, . , , , , . , CSS , Javascript - ?
marzelin ( JavaScript):
const buttons = Array.from(document.querySelectorAll('.button'))
const count = buttons.length
const increase = Math.PI * 2 / buttons.length
const radius = 150
let angle = 0
buttons.forEach((button, i) => {
button.style.top = Math.sin(-Math.PI / 2 + i * increase) * radius + 'px'
button.style.left = Math.cos(-Math.PI / 2 + i * increase) * radius + 'px'
button.addEventListener('click', move)
})
function move(e) {
const n = buttons.indexOf(e.target)
const endAngle = (n % count) * increase
turn()
function turn() {
if (Math.abs(endAngle - angle) > 1/8) {
const sign = endAngle > angle ? 1 : -1
angle = angle + sign/8
setTimeout(turn, 20)
} else {
angle = endAngle
}
buttons.forEach((button, i) => {
button.style.top = Math.sin(-Math.PI / 2 + i * increase - angle) * radius + 'px'
button.style.left = Math.cos(-Math.PI / 2 + i * increase - angle) * radius + 'px'
})
}
}
javascript X- ( , , ..):
jQuery(function($){
const stars = Array.from(document.querySelectorAll('.btnStars'));
const count = stars.length;
const increase = Math.PI * 2 / stars.length;
const radius = 300;
let angle = 0;
stars.forEach((star, i) => {
star.style.top = Math.sin(-Math.PI / 2 + i * increase) * radius + 'px';
star.style.left = Math.cos(-Math.PI / 2 + i * increase) * radius + 'px';
});
$('.btnStar').click(function(e) {
const n = stars.indexOf(e.target);
const endAngle = (n % count) * increase;
function turn() {
if (Math.abs(endAngle - angle) > 1/8) {
const sign = endAngle > angle ? 1 : -1;
angle = angle + sign/8;
setTimeout(turn, 20);
} else {
angle = endAngle;
}
stars.forEach((star, i) => {
star.style.top = Math.sin(-Math.PI / 2 + i * increase - angle) * radius + 'px';
star.style.left = Math.cos(-Math.PI / 2 + i * increase - angle) * radius + 'px';
})
}
turn();
});
});
, CSS .., . , , X Theme, , , , , , , . .
JQuery.click, , -, .
Javascript JQuery , WordPress, , .
- -, ? , .:/