adding .rotatable to object returns its initial degree to 0

Viewed 62

adding .rotatable to object returns its initial degree to 0

I have made a Code Pen where I insert the HTML via jquery and when I make them rotatable they lose their angle link

For example, if I have a div with class= box when I make this div rotatable using $('.box').rotatable(); this library adds ui-rotatable class to the div and adds the handle div

<div class="ui-rotatable-handle" unselectable="on" style="user-select: none; position: absolute; width: 9px; height: 9px; top: 0px; left: 0px; cursor: grab;"></div>

so the complete result shows as follows (after rotating the div with class box 180 degrees it have this as a style transform: rotate(180deg);)

<div class="box ui-rotatable" style="transform: rotate(180deg);">
Text rotate
<div class="ui-rotatable-handle" unselectable="on" style="user-select: none; position: absolute; width: 9px; height: 9px; top: 0px; left: 0px; cursor: grab;"></div>

Now that I have this code, I want to insert it on startup so the div takes 180degrees and can be rotated so I created a div container and using jquery I injected the div box to it $("#container").html(content);

at this point, the div is rotated 180 degrees but it is not rotatable, so I used $('.box').rotatable(); to make it rotatable again but now the div returned to 0 degrees.

I have searched within the code to find if something it resetting the degree but couldn't find it especially that it is taking as far as I can tell the original degree with this code instance.elementCurrentAngle

1 Answers

Returning back and inspecting the code closely I found that the _angle function is receiving and angle of value 0 and that function invokes the perform function with the angle of value 0 so I disabled the function return

 _angle: function(angle) {
            this.elementCurrentAngle = this._calculateAbsoluteAngle(this._num(angle));
            // return this.perform(this.element, this.elementCurrentAngle);
        },

Now that the angle isn't received as a 0 the old angle is used.

Related