now supporting:::: container rotation!

This commit is contained in:
2025-08-23 17:12:42 -04:00
parent cc50553f14
commit 7cfcffa9ef
+84 -60
View File
@@ -249,7 +249,7 @@
.containerOptionListing { .containerOptionListing {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin: .25rem 0; margin: .25rem 1rem 0 .25rem;
} }
#noContainerWarning { #noContainerWarning {
@@ -997,7 +997,7 @@
</div> </div>
<div class="expandableMenuToggle" onclick="toggleExpandableMenu(this)"> <div class="expandableMenuToggle" onclick="toggleExpandableMenu(this)">
<p>shaping / color</p> <p>container styling</p>
<p class="expandedMenuIndicator">+</p> <p class="expandedMenuIndicator">+</p>
</div> </div>
<div class="expandableMenu"> <div class="expandableMenu">
@@ -1013,11 +1013,15 @@
<input id=${this.id + "-settings-bg-alpha"} type="range" min="0" max="100" /> <input id=${this.id + "-settings-bg-alpha"} type="range" min="0" max="100" />
</div> </div>
<p class="menuHeader">layer shape</p> <p class="menuHeader">shape</p>
<div class="containerOptionListing"> <div class="containerOptionListing">
<label for=${this.id + "-settings-border-radius"}>roundness: </label> <label for=${this.id + "-settings-border-radius"}>roundness: </label>
<input id=${this.id + "-settings-border-radius"} type="range" max="175" /> <input id=${this.id + "-settings-border-radius"} type="range" max="175" />
</div> </div>
<div class="containerOptionListing">
<label for=${this.id + "-settings-rotation"}>rotation: </label>
<input id=${this.id + "-settings-rotation"} type="range" min="-180" max="180" />
</div>
<p class="menuHeader">border</p> <p class="menuHeader">border</p>
<div class="containerOptionListing"> <div class="containerOptionListing">
@@ -1117,7 +1121,7 @@
</div> </div>
<div class="expandableMenuToggle" onclick="toggleExpandableMenu(this)"> <div class="expandableMenuToggle" onclick="toggleExpandableMenu(this)">
<p>general text / font options</p> <p>text / font options</p>
<p class="expandedMenuIndicator">+</p> <p class="expandedMenuIndicator">+</p>
</div> </div>
<div class="expandableMenu"> <div class="expandableMenu">
@@ -1235,6 +1239,9 @@
settings.borderWidth; settings.borderWidth;
document.getElementById(this.id + "-settings-border-radius").value = document.getElementById(this.id + "-settings-border-radius").value =
settings.borderRadius; settings.borderRadius;
// ROTATION
document.getElementById(this.id + "-settings-rotation").value =
settings.rotation;
// FONT // FONT
if (settings.fontName == "") { if (settings.fontName == "") {
document.getElementById(this.id + "-settings-font-name").innerHTML = document.getElementById(this.id + "-settings-font-name").innerHTML =
@@ -1454,11 +1461,15 @@
${this.youtubeId ? `` : imageHyperlinkOptions} ${this.youtubeId ? `` : imageHyperlinkOptions}
<p class="menuHeader">image shape</p> <p class="menuHeader">shape</p>
<div class="containerOptionListing"> <div class="containerOptionListing">
<label for=${this.id + "-settings-border-radius"}>roundness: </label> <label for=${this.id + "-settings-border-radius"}>roundness: </label>
<input id=${this.id + "-settings-border-radius"} type="range" max="175" /> <input id=${this.id + "-settings-border-radius"} type="range" max="175" />
</div> </div>
<div class="containerOptionListing">
<label for=${this.id + "-settings-rotation"}>rotation: </label>
<input id=${this.id + "-settings-rotation"} type="range" min="-360" max="360" />
</div>
<p class="menuHeader">border</p> <p class="menuHeader">border</p>
<div class="containerOptionListing"> <div class="containerOptionListing">
@@ -1556,6 +1567,9 @@
settings.borderWidth; settings.borderWidth;
document.getElementById(this.id + "-settings-border-radius").value = document.getElementById(this.id + "-settings-border-radius").value =
settings.borderRadius; settings.borderRadius;
// ROTATION
document.getElementById(this.id + "-settings-rotation").value =
settings.rotation;
// MIRRORING // MIRRORING
document.getElementById(this.id + "-settings-mirror-x").checked = document.getElementById(this.id + "-settings-mirror-x").checked =
settings.invertX; settings.invertX;
@@ -1594,6 +1608,10 @@
document document
.getElementById(this.id + "-settings-shadow-alpha") .getElementById(this.id + "-settings-shadow-alpha")
.addEventListener("input", changeContainerShadow, false); .addEventListener("input", changeContainerShadow, false);
// container rotation setting listeners
document
.getElementById(this.id + "-settings-rotation")
.addEventListener("input", changeContainerRotation, false);
/** if this is an media container, settings diverge here */ /** if this is an media container, settings diverge here */
if (this.mediaUrl != undefined) { if (this.mediaUrl != undefined) {
@@ -1706,7 +1724,10 @@
"px " + "px " +
settings.shadowRgba; settings.shadowRgba;
/** if this is a media container, settings diverge here */
/**
* if this is a media container, settings diverge here
*/
/** BORDER */ /** BORDER */
if (this.mediaUrl?.includes("youtube.com") || this.mediaUrl?.includes("youtu.be")) { if (this.mediaUrl?.includes("youtube.com") || this.mediaUrl?.includes("youtu.be")) {
@@ -1734,25 +1755,20 @@
settings.borderColor; settings.borderColor;
} }
/** MEDIA MIRRORING */ /** MEDIA MIRRORING + ROTATOIN*/
if (this.mediaUrl != undefined) { if (this.mediaUrl != undefined) {
let invertX = settings.invertX; let transformValue =
let invertY = settings.invertY; `scale(${settings.invertX ? `-1` : `1`}, ${settings.invertY ? `-1` : `1`}) `;
transformValue +=
`rotate(${settings.rotation}deg)`;
if (invertY && invertX) { document.getElementById(this.id).style.transform = transformValue;
document.getElementById(this.id).classList.add("doubleInverted");
}
else if (invertX) {
document.getElementById(this.id).classList.add("invertedX");
}
else if (invertY) {
document.getElementById(this.id).classList.toggle("invertedY");
}
return; return;
} }
/** apply text-container-only customizations */ /** apply text-container-only customizations */
/** FONT */ /** FONT */
if (settings.fontCode != "") { if (settings.fontCode != "") {
document.head.insertAdjacentHTML( document.head.insertAdjacentHTML(
@@ -1809,6 +1825,11 @@
divider.style.backgroundColor = settings.dividerColor; divider.style.backgroundColor = settings.dividerColor;
divider.style.borderColor = settings.dividerColor; divider.style.borderColor = settings.dividerColor;
} }
/** ROTATION */
document.getElementById(this.id).style.transform =
"rotate(" + settings.rotation + "deg)";
} }
/** /**
@@ -1817,8 +1838,6 @@
addContainerEventListeners() { addContainerEventListeners() {
let container = document.getElementById(this.id); let container = document.getElementById(this.id);
console.log("adding event listeners for " + this.id);
// make element movable + resizable // make element movable + resizable
container.addEventListener( container.addEventListener(
"mousedown", "mousedown",
@@ -2491,14 +2510,6 @@
let clickedListingCopy = document.getElementById(containerId + "-container-listing").cloneNode(true); let clickedListingCopy = document.getElementById(containerId + "-container-listing").cloneNode(true);
document.getElementById(containerId + "-container-listing").remove(); document.getElementById(containerId + "-container-listing").remove();
if (direction == "top") {
}
else if (direction == "bottom") {
}
/** then, deal with reordering the actual containers */ /** then, deal with reordering the actual containers */
// for up/down, simply swap container element z-indexes + save to map // for up/down, simply swap container element z-indexes + save to map
@@ -2533,8 +2544,6 @@
else if (direction == "top") { else if (direction == "top") {
// moved container will be at end, so we need to ripple all zIndexes between Current and end down 1 // moved container will be at end, so we need to ripple all zIndexes between Current and end down 1
for (let i = currentIndex; i < numberTotalContainers; i++) { for (let i = currentIndex; i < numberTotalContainers; i++) {
console.log("setting: " + i + ", " + zIndexMap.get(String(i+1)));
zIndexMap.set(String(i), zIndexMap.get(String(i+1))) zIndexMap.set(String(i), zIndexMap.get(String(i+1)))
document.getElementById(zIndexMap.get(String(i))).style.zIndex--; document.getElementById(zIndexMap.get(String(i))).style.zIndex--;
containerDataMap.get(zIndexMap.get(String(i))).settings.zIndex--; containerDataMap.get(zIndexMap.get(String(i))).settings.zIndex--;
@@ -2552,8 +2561,6 @@
else if (direction == "bottom") { else if (direction == "bottom") {
// moved container is now at bottom, so we need to ripple all other zIndexes up 1 // moved container is now at bottom, so we need to ripple all other zIndexes up 1
for (let i = currentIndex; i > 1; i--) { for (let i = currentIndex; i > 1; i--) {
console.log("setting: " + i + ", " + zIndexMap.get(String(i+1)));
zIndexMap.set(String(i), zIndexMap.get(String(i - 1))) zIndexMap.set(String(i), zIndexMap.get(String(i - 1)))
document.getElementById(zIndexMap.get(String(i))).style.zIndex++; document.getElementById(zIndexMap.get(String(i))).style.zIndex++;
containerDataMap.get(zIndexMap.get(String(i))).settings.zIndex++; containerDataMap.get(zIndexMap.get(String(i))).settings.zIndex++;
@@ -2567,7 +2574,7 @@
zIndexMap.set("1", containerId); zIndexMap.set("1", containerId);
} }
// since menu for moving container was removed+readded, we need to reapply listeners // since menu for moving container was removed+readded, we need to reapply listeners to inputs
movingContainer.addSettingsMenuEventListeners(); movingContainer.addSettingsMenuEventListeners();
// and refresh the listings based on the new saved data // and refresh the listings based on the new saved data
@@ -2660,7 +2667,6 @@
for(let index = 1; index < 200; index ++) { for(let index = 1; index < 200; index ++) {
id = "container-" + index; id = "container-" + index;
if (!containerDataMap.has(id)) { if (!containerDataMap.has(id)) {
console.log(id);
return id; return id;
} }
} }
@@ -2724,7 +2730,6 @@
function moveElement(mouseMove) { function moveElement(mouseMove) {
if (!moving) { if (!moving) {
console.log("RETURN: " + mouseMove.target.tagName);
return; return;
} }
@@ -2867,7 +2872,6 @@
// apply new grab cursor to grabbable elements... // apply new grab cursor to grabbable elements...
let movableElements = document.getElementsByClassName("movable"); let movableElements = document.getElementsByClassName("movable");
for (let i = 0; i < movableElements.length; i++) { for (let i = 0; i < movableElements.length; i++) {
console.log(movableElements[i]);
movableElements[i].style.cursor = cursors.grab ? 'url("' + cursors.grab + '"), grab' : "grab"; movableElements[i].style.cursor = cursors.grab ? 'url("' + cursors.grab + '"), grab' : "grab";
} }
document.getElementById("grabCursorInput").value = ""; document.getElementById("grabCursorInput").value = "";
@@ -3318,45 +3322,65 @@
document.getElementById(containerId).style.boxShadow = shadow; document.getElementById(containerId).style.boxShadow = shadow;
} }
// ROTATION
function changeContainerRotation(valueChanged) {
let containerId = valueChanged.target.id.split("-settings")[0];
let container = containerDataMap.get(containerId);
let rotation = valueChanged.target.value;
let invertX = container.settings.invertX;
let invertY = container.settings.invertY;
// save to container
container.settings.rotation = rotation;
// perform transformation
let transformValue =
`scale(${invertX ? `-1` : `1`}, ${invertY ? `-1` : `1`}) `;
transformValue +=
`rotate(${container.settings.rotation}deg)`;
document.getElementById(containerId).style.transform = transformValue;
}
// IMAGE INVERSION // IMAGE INVERSION
function toggleMirrorX(checkboxChanged) { function toggleMirrorX(checkboxChanged) {
let containerId = checkboxChanged.target.id.split("-settings")[0]; let containerId = checkboxChanged.target.id.split("-settings")[0];
let container = containerDataMap.get(containerId); let container = containerDataMap.get(containerId);
let invertX = checkboxChanged.target.checked;
let invertX = checkboxChanged.target.checked;
let invertY = container.settings.invertY;
// save to container
container.settings.invertX = invertX; container.settings.invertX = invertX;
if (invertX && container.settings.invertY) { // perform transformation
document.getElementById(containerId).classList.remove("invertedY"); let transformValue =
document.getElementById(containerId).classList.add("doubleInverted"); `scale(${invertX ? `-1` : `1`}, ${invertY ? `-1` : `1`}) `;
} transformValue +=
else if (!invertX && document.getElementById(containerId).classList.contains("doubleInverted")) { `rotate(${container.settings.rotation}deg)`;
document.getElementById(containerId).classList.remove("doubleInverted");
document.getElementById(containerId).classList.add("invertedY"); document.getElementById(containerId).style.transform = transformValue;
}
else {
document.getElementById(containerId).classList.toggle("invertedX");
}
} }
function toggleMirrorY(checkboxChanged) { function toggleMirrorY(checkboxChanged) {
let containerId = checkboxChanged.target.id.split("-settings")[0]; let containerId = checkboxChanged.target.id.split("-settings")[0];
let container = containerDataMap.get(containerId); let container = containerDataMap.get(containerId);
let invertY = checkboxChanged.target.checked;
let invertY = checkboxChanged.target.checked;
let invertX = container.settings.invertX;
// save to container
container.settings.invertY = invertY; container.settings.invertY = invertY;
if (invertY && container.settings.invertX) { // perform transformation
document.getElementById(containerId).classList.remove("invertedX"); let transformValue =
document.getElementById(containerId).classList.add("doubleInverted"); `scale(${invertX ? `-1` : `1`}, ${invertY ? `-1` : `1`}) `;
} transformValue +=
else if (!invertY && document.getElementById(containerId).classList.contains("doubleInverted")) { `rotate(${container.settings.rotation}deg)`;
document.getElementById(containerId).classList.remove("doubleInverted");
document.getElementById(containerId).classList.add("invertedX"); document.getElementById(containerId).style.transform = transformValue;
}
else {
document.getElementById(containerId).classList.toggle("invertedY");
}
} }
function toggleYoutubeAutoplay(checkbox) { function toggleYoutubeAutoplay(checkbox) {