Giter Site home page Giter Site logo

yuanqing / autosize-input Goto Github PK

View Code? Open in Web Editor NEW
67.0 1.0 12.0 106 KB

:balloon: Effortless, dynamic-width text boxes in vanilla JavaScript

Home Page: https://codepen.io/lyuanqing/pen/xYpmKj

License: MIT License

JavaScript 100.00%
dom forms textbox input autosize javascript

autosize-input's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

autosize-input's Issues

destroy method

Is it possible to destroy the instance - or a way to reinit it?

allow for one-off resizing

Right now the set function is closured inside the autosizeInput function and bound to 'input' but sometimes the value of an input can change via input.value = 'something' and the listener won't fire in that case. It would be nice to be able to call resize manually too.

getComputedStyle().width is not reliable on all browsers.

Hi,
I just found out, that Internet Explorer (11) behaves different calculating the width of the input.

using

61: var width = window.getComputedStyle(ghostElement).width

there are different results between IE11 and Chrome for example.

Suggestion: use

var width = ghostElement.offsetWidth, then it works everywhere.

Cannot Find Module

When I try to use this package with TypeScript/Webpack/Angular 2 I receive this error during my build: TS2307: Cannot find module 'autosize-input'. Imported like so:

import * as autosizeInput from 'autosize-input';

It is worth mentioning is that the application does run, it just doesn't compile correctly.

Webpack: 2.2.1
TypeScript: 2.0.3
Angular: 2.4.10

Include a built version of the lib

Would it be possible to include a built version (bundle.js) of the library like there used to be in version 0.4.0? That would be useful for those of us who just want to include the file directly and don't have a build system.

Turbolinks compatibility

When the library first loads, it creates a ghost div that is appended to the dom. This makes the library incompatible with Turbolinks which reloads the dom on each request.

Would it be possible to initialize the ghost div inside the autosizeInput function or create some sort of initializer that can be called to create the ghost div?

The codepen.io demo no longer works

At least not on my machine. It appears the wzrd.in service isn't resolving autosize-input.

However, codepen itself recomments importing npm packages via cdn.skypack.net; and even provides UI to help you find and import npm packages such as autosize-input.

The following variant of your pen works on my machine: https://codepen.io/emn13/pen/gOeNNQJ

All I did was remove the JS dependency referring to wzrd.in, and added the skypack alternative, which is effectively no more than adding import autosizeInput from "https://cdn.skypack.dev/[email protected]"; to the top of the JS code.

trigger event

I have functionality that updated the input value in other way that typing into the input field (e.g. click a button and update the input to 'test value').

$('#search').val('test-value')

I need to trigger an event to update the width of the input field. I tried using jquery trigger with 'keydown', 'change' and 'input' events, but nothing happened:

$('#search').trigger('input')

Preserve style input

It would be nice to keep defined style:

<input type="text" id="baz" placeholder="Matter" style="max-width: 200px">

Resize is nice, but don't resize too much though :p

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.