brinley/jSignature — pull request #18 by dvdotsenko (2012-06-25 22:21:35+00:00)
Title: (fix #17) Specified Width and Height = sizing problem with jSignature

This fixes the issue where manually specifying the size of the signature area by passing 'height', 'width' to jSignture.init() would break the sizing logic.

There are two parts to this fix:
1. switched to jQuery.width(), jQuery.height(), jQuery.css(). Native methods ("offset*") + elem.style.width/height would fail when type of value is not what browser had expected.
2 found a problem with size detection that stems from "traditional" box sizing model, where border and padding of canvas would screw up size calculations. The side effect of this was drawing pointer coordinates did not line up with pixels when large padding, border were used. Padding, Border, Margin would also push canvas outside of the parent elem's box.

The fix to #1 is relatively transparent and does not break prior implementations. The fix to #2 involved *forbidding use of padding, border, margin on jSignature's canvas element. As of this commit, Padding, Border, Margin of the actual Canvas element are hardcoded to zero pixels wide.* This means, if someone before had CSS rules attached to the actual canvas, padding, border, margin values will now be ignored. Styles applied to parent of the canvas are honored as always.

#2 is a bit harsh, but is a better solution for everyone, as it pushes the users towards parent element's CSS and DOM for managing how jSignature looks, instead of advertising direct access to underlying rendering surface.

The minor sizing bug did annoy me for a while, and I do consider this my solution to sizing a "reliable, final, maintainable by me."

If it was not for chance that someone out there may now be using jSignature and assigning one of "padding, border, margin" to it, I would not bug you with long explanation for this change. If you estimate that there are a lot of users who might be relying on ability to assign "padding, border, or margin" directly to the canvas.jSignature, we'll need to mark this as a major release and explain the change.