NullOperator404 / Developer-Diary

Just a blog where I echo thoughts on projects, bugs, etc.
0 stars 0 forks source link

MINOR ISSUE: Drag function needs to know if element is Name/Number #24

Closed NullOperator404 closed 1 year ago

NullOperator404 commented 1 year ago

When dragging Name or Number Placeholders in the design space, the Dev Tool is reporting errors from the Drag Function. The drag function works by referencing the focus variable, and expects accompanying Delete and Scale icons to be attached to the element. Since Name & Number placeholders do not feature these icons, the Drag function attempts to set the style attribute on non-existent icons.

To correct this, I should be able to implement similar logic that was used in the Outline, Font, & Fill color functions where JS will check to see if the element being dragged is a Name or Number element, and if so, ignore any Scale/Delete icons.

NullOperator404 commented 1 year ago

RESOLVED

As I surmised, a simple block of conditional logic rectified the issue:

if(focus !== "name" && focus !== "num") {
            document.getElementById(del).style.visibility = "hidden";
            document.getElementById(scale).style.visibility = "hidden";
            //CHANGE BORDER TO DASHED WHILE ELEMENT IS DRAGGED
            document.getElementById(viewBox).style.borderStyle = "dashed";
        }

With the above code, JS will only attempt to restyle Delete & Scale icons if the value of focus is NOT "name" or "num," which is what it would be if either placeholder is currently focused.