diff options
author | Brandon Aaron <brandon.aaron@gmail.com> | 2013-02-24 09:46:05 -0600 |
---|---|---|
committer | Brandon Aaron <brandon.aaron@gmail.com> | 2013-02-24 09:46:05 -0600 |
commit | 10e201d3df21a691b70e281c8ac9a7bd80917897 (patch) | |
tree | a01e78cac3d8a87ea245d8f06e6ca98420c8b6d6 | |
parent | 5511f8745967f58d42def44810ae3c44564ddd4e (diff) | |
download | jquery-expandable-10e201d3df21a691b70e281c8ac9a7bd80917897.zip jquery-expandable-10e201d3df21a691b70e281c8ac9a7bd80917897.tar.gz jquery-expandable-10e201d3df21a691b70e281c8ac9a7bd80917897.tar.bz2 |
monitor the textarea for width (resize) changes and update the mirror
-rw-r--r-- | jquery.expandable.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/jquery.expandable.js b/jquery.expandable.js index 9017b7b..dcd3f77 100644 --- a/jquery.expandable.js +++ b/jquery.expandable.js @@ -46,12 +46,16 @@ } // copy styles from textarea to mirror to mirror the textarea as best possible - $.each('borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth paddingTop paddingRight paddingBottom paddingLeft fontSize fontFamily fontWeight fontStyle fontStretch fontVariant wordSpacing lineHeight width'.split(' '), function(i,prop) { - $mirror.css(prop, $this.css(prop)); - }); + mirror($this, $mirror); // setup events $this + .bind('mouseup', function(event) { + // check if width has changed + if ($this.width() !== $mirror.width()) { + mirror($this, $mirror); + } + }) .bind('keypress', function(event) { if ( event.keyCode == '13' ) check(); }) .bind('focus blur', function(event) { if ( event.type == 'blur' ) clearInterval( interval ); @@ -106,4 +110,10 @@ }); } + function mirror(org, mir) { + $.each('borderTopWidth borderRightWidth borderBottomWidth borderLeftWidth paddingTop paddingRight paddingBottom paddingLeft fontSize fontFamily fontWeight fontStyle fontStretch fontVariant wordSpacing lineHeight width'.split(' '), function(i,prop) { + mir.css(prop, org.css(prop)); + }); + } + })); |