Fixknob flex-wrap glitching issues

This commit is contained in:
lolabird 2023-11-12 10:03:16 -07:00
commit cb83a95351

View file

@ -35,6 +35,7 @@ colorPicker.addEventListener("input", changeColor);
colorPicker.addEventListener("change", changeColor);
backColorPicker.addEventListener("input", pickBackground);
reset.addEventListener("click", resetGrid);
gridSlider.addEventListener("input", getGridDimensions);
gridSlider.addEventListener("change", getGridDimensions);
rangeKnob.addEventListener("mousedown", (e) => {
@ -60,16 +61,17 @@ function resetGrid() {
function rotateKnob(e) {
const knobBounds = rangeKnob.getBoundingClientRect();
const knobCenter = {
x: knobBounds.left + knobBounds.width/2,
y: knobBounds.top + knobBounds.height/2
x: knobBounds.left + knobBounds.width / 2,
y: knobBounds.top + knobBounds.height / 2
};
let angle = Math.atan2(e.pageX - knobCenter.x, - (e.pageY - knobCenter.y) )*(180 / Math.PI);
let angle = Math.atan2(e.clientX - knobCenter.x, -(e.clientY - knobCenter.y)) * (180 / Math.PI);
rangeKnob.style.transform = `rotate(${angle}deg)`;
updateGridSlider(angle);
}
function updateGridSlider(angle) {
const maxRotation = 360;
const minSliderVal = gridSlider.min;