Socket
Socket
Sign inDemoInstall

jquery-textfill

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jquery-textfill

This jQuery plugin resizes text to make it fit into a container. The font size gets as big as possible. http://jquery-textfill.github.io/


Version published
Weekly downloads
628
decreased by-30.3%
Maintainers
1
Install size
32.0 kB
Created
Weekly downloads
 

Changelog

Source

Version 0.6.0 (2014-08-19T21:12:07Z)

  • add changeLineHeight (functionality to resize line-height of parent)
  • greatly improved code readability and comments

Readme

Source

jQuery TextFill

This jQuery plugin resizes text to make it fit into a container. The font size gets as big as possible.

  • Homepage.
  • Simple example.
  • Unit tests (assure plugin correctness).

logo

Usage

  • Remember to include jQuery and jQuery TextFill:
<script src="jquery.min.js"></script>
<script src="jquery.textfill.min.js"></script>
  • Select which element you'll use. Make sure to:
    • Specify the parent's width and height
    • Put the text inside of a <span/> child by default (see Options to change this)
<div id='my-element' style='width:100px;height:50px;'>
  <span>The quick brown fox jumps over the lazy dog</span>
</div>
  • Initialize jQuery TextFill
$('#my-element').textfill({
    ...options...
});

Options

Remember, container means the parent element, while child is the element that will resize. On the example above, the parent was the div and the child was the span.

NameDescriptionDefault Value
minFontPixelsMinimal font size (in pixels). The text will shrink up to this value.4
maxFontPixelsMaximum font size (in pixels). The text will stretch up to this value.. If it's a negative value (size <= 0), the text will stretch to as big as the container can accommodate.40
innerTagThe child element tag to resize. We select it by using $(innerTag + ':visible:first', container)span
widthOnlyWill only resize to the width restraint. The font might become tiny under small containers.false
explicitWidthExplicit width to resize. Defaults to the container's width.null
explicitHeightExplicit height to resize. Defaults to the container's height.null
changeLineHeightAlso change the line-height of the parent container. This might be useful when shrinking to a small container.false
debugOutput debugging messages to console.false

For example,

<script>
$(function() {
    $('#my-element').textfill({
        maxFontPixels: 36
    });
});
</script>

Callbacks

NameCalled when...Default Value
successCalled when a resizing is successfulnull
failCalled when a resizing is failednull
completeCalled when all elements are donenull

For example,

<script>
$(function() {
    $('#my-element').textfill({
        success: function() {
		    console.log("yay!")
		},
		fail: function() {
		    alert("boo hoo!")
		}
    });
});
</script>

Contributing

You are very welcome to contribute! A good number of people did, so feel free to help no matter how small the changes might be.

Just make sure to read the file CONTRIBUTING.md first. There we make a quick take on how you could help us.

Also, there we lay down our rules for reporting issues and making pull requests. Gotcha! Now you can't say we didn't told you about it!

If you found something critical or just want to make a suggestion open an issue and start typing right away.

Credits

This jQuery plugin was created by Russ Painter around May 2009, beginning with a StackOverflow question.

In very early 2012, Yu-Jie Lin helped to move the project to GitHub with version 0.1 and obtained the clearly stated open source licensing from Russ.

Around July 2014 Alexandre Dantas was made a contributor, currently maintaining the project.

License

jquery-textfill is licensed under the MIT License. See file COPYING.md to see what you can and cannot do with the source.

Copyright (c) 2014 Alexandre Dantas
Copyright (c) 2012-2013 Yu-Jie Lin
Copyright (c) 2009 Russ Painter

FAQs

Last updated on 06 Sep 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc