All Projects → fazouane-marouane → fancy-textfill

fazouane-marouane / fancy-textfill

Licence: MIT license
Fast implementation for resizing text to fill its container.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to fancy-textfill

jquery.skeleton.loader
A jQuery plugin to make screen skeleton loader.
Stars: ✭ 65 (+282.35%)
Mutual labels:  jquery-plugin, javascript-library
Jcanvas
A jQuery plugin that makes the HTML5 canvas easy to work with.
Stars: ✭ 612 (+3500%)
Mutual labels:  jquery-plugin, javascript-library
xGallerify
A lightweight, responsive, smart gallery based on jQuery
Stars: ✭ 52 (+205.88%)
Mutual labels:  jquery-plugin, javascript-library
kolorwheel.js
🌈 Color palette generator JavaScript library
Stars: ✭ 37 (+117.65%)
Mutual labels:  jquery-plugin, javascript-library
Ditherjs
A javascript library which dithers an <img> using a fixed palette
Stars: ✭ 76 (+347.06%)
Mutual labels:  jquery-plugin, javascript-library
Ua Parser Js
UAParser.js - Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment.
Stars: ✭ 6,421 (+37670.59%)
Mutual labels:  jquery-plugin, javascript-library
Filterizr
✨ Filterizr is a JavaScript library that sorts, shuffles and filters responsive galleries using CSS3 transitions ✨
Stars: ✭ 546 (+3111.76%)
Mutual labels:  jquery-plugin, javascript-library
Ui Components
Most used UI Components — of web applications. Curated/Most loved components for web development
Stars: ✭ 175 (+929.41%)
Mutual labels:  jquery-plugin, javascript-library
Tag Handler
Tag Handler is a jQuery plugin used for managing tag-type metadata.
Stars: ✭ 76 (+347.06%)
Mutual labels:  jquery-plugin, javascript-library
Trip.js
🚀 Trip.js is a plugin that can help you customize a tutorial trip easily with more flexibilities.
Stars: ✭ 789 (+4541.18%)
Mutual labels:  jquery-plugin, javascript-library
Jquery Mosaic
A jQuery plugin to build responsive mosaics of images or any other content fitted to match heights in multiple rows while maintaining aspect ratios. http://jquery-mosaic.tin.cat
Stars: ✭ 80 (+370.59%)
Mutual labels:  jquery-plugin, javascript-library
Modern.JS
모던 자바스크립트 라이브러리/프레임워크 × KIPFA(한국인터넷전문가협회)
Stars: ✭ 16 (-5.88%)
Mutual labels:  jquery-plugin, javascript-library
animeflv
Animeflv is a custom API that has the entire catalog of the animeflv.net website. You can enjoy all the content with subtitles in Spanish and the latest in the world of anime for free.
Stars: ✭ 37 (+117.65%)
Mutual labels:  javascript-library
tung
A javascript library for rendering html
Stars: ✭ 29 (+70.59%)
Mutual labels:  javascript-library
Kursor
Cursor style with javascript and css
Stars: ✭ 140 (+723.53%)
Mutual labels:  javascript-library
emulatetab
A jQuery plugin to emulate tabbing between elements on a page.
Stars: ✭ 15 (-11.76%)
Mutual labels:  jquery-plugin
jquery-lightbox
A jQuery plugin, inspired and based on Lightbox 2 by Lokesh Dhakar
Stars: ✭ 22 (+29.41%)
Mutual labels:  jquery-plugin
scrollbox
A lightweight jQuery custom scrollbar plugin, that triggers event when reached the defined point.
Stars: ✭ 15 (-11.76%)
Mutual labels:  jquery-plugin
jquery-asPieProgress
A jQuery plugin that animate the pie progress.
Stars: ✭ 41 (+141.18%)
Mutual labels:  jquery-plugin
mongo-uri-builder
A node.js module to easily create mongodb connection strings using configuration objects
Stars: ✭ 29 (+70.59%)
Mutual labels:  javascript-library

fancy-textfill

npm license

Fast implementation for resizing text to fill its container. It computes the optimal font-size needed to match a text to specific width and height. It's also available as a jquery plugin.

It's really fast. See for yourself. 🤘 Demo

Install

npm install --save fancy-textfill
# or you can use yarn (yarn add fancy-textfill)

Example

<!-- In case you're using it as a jquery plugin -->
<script src="jquery.min.js"></script>
<script src="https://unpkg.com/fancy-textfill/dist/fancy-text-fill.jQuery.js"></script>
<!-- Or you can use it without jquery, by using https://unpkg.com/fancy-textfill/dist/fancy-text-fill.js -->
<!-- Example setup -->
<style>
  .container {
    width: 200px;
    height: 50px;
  }
  .myText {
    display: block;
  }
</style>
<div class="container">
  <span class="myText">Hello darkness, my old friend.</span>
</div>
<div class="container">
  <span class="myText">I've come to talk with you again.</span>
</div>

You can either use it on bare dom elements or on jquery objects.

// Without jquery
document.getElementsByClassName('myText')
  .forEach(function (el) {
    fancyTextFill.fillParentContainer(el, {
      minFontSize: 6,
      maxFontSize: 26
    });
  });
// With jquery
$('.myText').fancyTextFill({
  minFontSize: 6,
  maxFontSize: 26
});

You can also use it as a module. You can import it like so:

// Without jquery
import { fillParentContainer } from 'fancy-textfill';
// Or const { fillParentContainer } = require('fancy-textfill');
fillParentContainer(el, {
  minFontSize: 6,
  maxFontSize: 26
});
// as a jquery plugin
import 'fancy-textfill/es2015/jquery.plugin';
// Or require('fancy-textfill/es2015/jquery.plugin');
$('.myText').fancyTextFill({
 minFontSize: 6,
 maxFontSize: 26
});

Options

Name Description Default value
minFontSize Minimal font size (in pixels). The text will shrink up to this value. 4
maxFontSize Maximum font size (in pixels). The text will stretch up to this value. If it is null or a negative number (maxFontSize <= 0), the text will stretch to as big as the container can accommodate. 40
maxWidth Explicit width to resize. Defaults to the container's width. null
maxHeight Explicit height to resize. Defaults to the container's height. null
multiline Will only resize to the width restraint when set to false true
explicitLineHeight When set to false, line-heights are assumed to be relative to the current font-size false

How does it compare to...

  1. jquery-textfill

Performance! fancy-TextFill implements the same features while being way faster than the original jquery plugin.

  1. BigText

BigText doesn't support multiple lines.

Unit tests

# Run chrome driver
chromedriver --port=4444 --url-base=wd/hub
# In another console
npm run build:dev
npm run test

License

This code is licensed under the MIT License. See file LICENSE for more details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].