Resize a div layer with javascript

Resize a div layer with javascript

Pseudo formula:

// Acronyms used to save space.
New style.left = PCW+((E.X-PCX)-(MDX-PCX))
New style.top = PCH+((E.Y-PCY)-(MDY-PCY))

// PCW/PCH = Previous Container Width/Height.
// E.X/E.Y = Event X/Y.
// PCX/PCY = Previous Container Left/Top.
// MDX/MDY = Mouse Down X/Y (where you clicked).

With this formula you will resize the layer relative to where you clicked on it. An extended version of the movement formula. In effect it will take the existing width/height and add the amount of pixel movement as a positive or negative number.

My example, just view the source to see my code.

Leave a Reply