Problem with local variable inside an event in javascript -
I want to delete a page that has a large size and dragable div. I've attached a Masudown, Musemov and mouseup event handlers in this device.
The problem is with the mousemove event handler I have to go div to the current width, height, top and left. For this, I am using the function to return specific values and I have to use them in different situations in these situations within the main function.
If I try to set local variables with these values and use these variables in the first code then the script becomes slower. This means that there is a delay in resizing and dragging.
But if I call the function instead of using these variables in the condition every time there is no delay.
What would be the cause of this problem ??
code sample
// executes with code delay function AdjustElement () {Var elemHeight = GetHeight (AMM); Var elemWidth = GetWidth (elem); Var elemTop = GetTop (AMM); Var elemLeft = GetLeft (elem); {ElemTop> = 20 & amp; ElemTop & lt; = 200} {// For moving element} If (elemLeft> = 20 & amp; amp; amp; amp; amp; amp; amp; amp; elemRight & lt; = 200) if (elemHyight> 60 & amp; amp; elemHeight & Lt; = 300) {// code to resize size}} if (elemWidth> = 60 & amp; amp; amp; mmmmid = 300) {// resize Code}} // executes without code delay function AdjustElement (if (GetLeft (elem)> = 20 & amp; amp; and GetRight (elem) & lt; = 200) {/ / Code for moving element} if (GetTop (elem)> = 20 & amp; GetTop (elem) <= 200) {// code for moving element} if (GetHeight (elem)> = 60 & amp; amp; GetHeight (elem) & lt; = 300) {// code to change the code size} if (G EtWidth (= elem)> = 60 and & amp; GetWidth (elem) & lt; = 300) {// code to resize shape}} Normal function Ons function GetWidth (elem) {return elem.offsetWidth;} GetHyight function (Elem) {return elem.offsetHeight;} GetTop (elem) {return elem.offsetTop;} function GetLeft (elem) {return elem.offsetLeft;} < / Html>
Comments
Post a Comment