Giter Site home page Giter Site logo

autoresize's Introduction

AutoResize v1.1.2

Tuesday, October 10th 2011

AutoResize is a jQuery Plugin that matches a textarea to the height of its text content. It is intended to be used with the latest version of jQuery: http://code.jquery.com/jquery-latest.js

Homepage: http://azoffdesign.com/autoresize

Support

If you're having problems with using the project, use the support forum at CodersClan.

License

Copyright 2011, Jonathan Azoff

Dual licensed under the MIT or GPL Version 2 licenses.

http://jquery.org/license

Usage

jQuery(selector).autoResize();
  • selector The jQuery selector, targeting a <textarea> element to apply the auto resize to

Events

Apart from regular DOM events, an auto-resized textarea emits events to inform the listeners of its state. To listen to these events, simply listen for one of the following events on an overscrolled element:

  • autoresize:resize
    • Called after re-sizing happens. This event is only called when the size actually changes.

Here is an example using jQuery's bind() method, listening for resize:

$('selector').autoresize().bind('autoresize:resize', function(e, height){ console.log(this, 'is', height, 'px tall') });

Notes

AutoResize only works with textareas, so please don't complain if your contenteditable elements aren't resizing when you apply this plug-in to them. This plug-in was designed to solve what should be a very simple problem, but seemingly fell short of a complete solution in many past attempts. Each auto-resizing plug-in I've tested has failed in situations where the textarea is hidden, or messes with selector logic by inserting a cloned element of the same class. AutoResize attempts to be as unobtrusive as possible, while still maintaining resilience in the face of DHTML. Use it at your own risk and please submit bug reports on the Issue Tracker

Special Thanks

This plug-in would not exist if it was not for a specific need and level of quality demanded by a particular project. For AutoResize, that inspiration is RentJuice (http://rentjuice.com), which uses the plug-in in many of their new features. Special thanks to RentJuice and the entire dev team for allowing this plug-in to go open-sourced!

Change Log

  • 1.1.1
  • Fixed page jump behavior on autoscroll (issue)
  • 1.1.1
  • Fixed page jump behavior on autoscroll (issue)
  • 1.1.0
  • No more clones, long live scrollHeight!
  • 1.0.0
  • Out of the gate, hurrah!

autoresize's People

Contributors

snappedtogrid avatar

Watchers

Dror Cohen avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.