Code Monkey home page Code Monkey logo

ng-fittext.js's People

Contributors

davearata avatar j-r-t avatar merott avatar patrickmarabeas avatar richarddavenport avatar trumbitta avatar zarko-tg avatar zurie avatar

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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-fittext.js's Issues

FitText makes the $digest cycle repeat a lot of times, and transition time becomes really long

Hey

thanks for ng-FitText, which is great.

I am using it in an Ionic (1) app, and I am experiencing big performance issue when transitionning to a page that contains a fittext directive. The digest cycle is called again several times, and my users can wait 5 seconds to see the next page.

One of the fittext directive is on the items of a ng-repeat.

<ion-slide ng-repeat="s in sliderPages">
					<ul>
						<!-- <li ng-repeat="item in prodata | matchingProBrand:data.computed.proName:data.computed.proBrand | limitTo:s*sliderItemNumber+sliderItemNumber  | limitTo:-sliderItemNumber"> -->
						<li ng-repeat="item in suggestionList | limitTo:s*sliderItemNumber+sliderItemNumber:s*sliderItemNumber ">
							<a class="suggestPro item-content" ng-click="itemID=item.id;changeisFlash();launchComputeService(item.id);">
								<span><img ng-src={{imagesUrls[item.imageName]}} /></span>
								<p class="flex-caption" ng-class="item.fun == '0' ? 'aNormal' :( item.fun == '1' ? 'aSmallWave' : (item.fun == '2' ? 'aStepUp' : ''))" fittext fittext-min="8" fittext-max="12" ng-bind="item.model + ' - ' + (item.name | split:' ':0)" > {{item.model}} - {{item.name | split:' ':0}}</p> 
							</a>
						</li>
					</ul>
				</ion-slide>

Do you have an idea to help me on this ?

Box-Sizing CSS3 support

Current calculation of font size appears to use (parent[0].offsetWidth - 6) as the detector of parent width. However, if the parent element has the following CSS applied:

-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;

Then the detected width fails to accommodate for any padding applied to the parent. (This is particularly noticeable when using Twitter Bootstrap with fittext elements directly inside col- items)

Current Hackaround for this is to wrap fittext elements in another div, however, out of the box support would be lovely :)

Setting the module variable overrides window.module

I recently included ng-fittext.js via bower into project and all my tests began to fail expressing module was undefined. I could fix the error if i switched my specs to angular.mock.module. I was able to narrow this down to window.module was being overriden from what angular.mock sets it to. If modified ng-fittext.js to not have a module variable this fixed the issue.

Update minified js

You have added global css inheritance, but minified js is still outdated. Please update it so it would be accessible through bower.

font size isn't set

Please correct me if I'm wrong, but my understanding is that this library should shrink text to fit within the width of an element. If I'm mistaken, feel free to close this issue.

issue:

This "lorem ipsum" text should be contained within the dark area.

web view

The text element itself is the width of the dark area (~280px).

code:

// config
angular.module('app')
  .config(function(fitTextConfigProvider) {
    fitTextConfigProvider.config = {
      debounce: _.debounce
    };
  })
<!-- view -->
<h1 data-fittext ng-model='user.name' ng-bind='user.name'></h1>

CSS (from web inspector):
CSS View

The following styles are set by this module:

{
  display: inline-block;
  white-space: nowrap;
  line-height: 1;
}

Notice that "font-size" property is absent. The rest of the styles were defined in the CSS of my app.

EDIT: I should also note that no errors have been thrown.

Can we adapt the font of multiples fitText using the max height of parent ?

I have 5 lines of text controlled by FitText, it is not mandatory to fill the 5 lines though, so I keep the max font size high. If the user enter 1 letter for each field though the height of the element exceeds it's limits and goes over the rest of the elements below.
Is there anyway that I could set a maximum parent height and adapt the fonts according to that too ?

Min Size and line break

I set a min size to 30 and it breaks outside of the container element on mobile. How can I get it to do lines breaks automatically?

Font size 0 issue

Font size is 0 if template is loaded dynamically by angular-route, unless I triggered $(window).resize().

Small improvements

  • a minified version could be provided
  • folder and script names should be lowercase

Other than that, great job.

Rename config value provider

The config value provider conflicts with a service of the same name in my application.

The config provider should be prefixed. I would suggest fitTextConstants or fitTextDefaultConfig would be better names.

Hide text container causes unexpected size (min size apparently)

I observed that when I hide a parent of the text, I sometimes (but not always) have an unexpected resize to the min size.
The hiding is done with some animations (slide / fade), and I suspect when showing again the fit routine is never called. Resizing the window works fine but I can't expect that from my users :)
Also to provoke this, you can : hide, resize the window, show.
Do you know any workaround ?

The behavior of Jade can make complicated integration

Hi, thank you for this module.

I had to investigate to understand why this module doesn't worked "out of the box" just by adding data-fittext as a directive on my element.

It appears that Jade compiles data-fittext as data-fittext="data-fittext" in HTML in order to support older browser (they don't like empty attribute). I would suggest to use a specific attribute name for the compressor value instead of using the default directive attribute value.

It's not a big deal but Jade is quite popular and it will probably save some time to other people in the exact same situation :)

Regards,

Module load error with angular 1.3.15

Hi
I've got an exception, when I bind ngFitText module to my angular application:

Error: [$injector:modulerr] Failed to instantiate module application due to:
[$injector:modulerr] Failed to instantiate module app.core due to:
[$injector:modulerr] Failed to instantiate module ngFitText due to:
[$injector:nomod] Module 'ngFitText' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.3.15/$injector/nomod?p0=ngFitText
minErr/<@http://127.0.0.1:3000/bower_components/angular/angular.js:63:12
module/<@http://127.0.0.1:3000/bower_components/angular/angular.js:1774:1
ensure@http://127.0.0.1:3000/bower_components/angular/angular.js:1698:38
module@http://127.0.0.1:3000/bower_components/angular/angular.js:1772:1
loadModules/<@http://127.0.0.1:3000/bower_components/angular/angular.js:4115:22
forEach@http://127.0.0.1:3000/bower_components/angular/angular.js:323:11
loadModules@http://127.0.0.1:3000/bower_components/angular/angular.js:4099:5 angular.js:63:11

I inserted in the module like this:

angular.module('app.core', ['ngAnimate', 'ngTouch', 'ngSanitize', 'restangular', 'ui.router', 'ngMaterial', 'ngFitText']);

and using ngFitText version 3.3.0
Thanks

Line height calculating incorrectly

getComputedStyle is ran too quickly to get the computed styles on page load. Needs a timeout to let dom calculate.

This is breaking line-height for me

can't load ng-FitText.js on angularjs 1.4

i'm using on ionic framework.

Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module starter.controllers due to:
Error: [$injector:modulerr] Failed to instantiate module ngFitText due to:
Error: [$injector:nomod] Module 'ngFitText' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

Force refreshing

Is it possible to have a way to manually refresh the font-size calculation ?

Maybe via a custom event that we could trigger when we want, or by watching another special attribute, or both...

We need to use ngBindHtml , and not ngBind (that is [watched](ngBind watch) by the directive).
It may also help people using the {{ ... }} notation, or after having resized the parent container.

Resizing of dynamic text - does not work when data changes constantly

I have a widget that can be resized to any size.
I have several lines of text inside it that need to scale when the widget resizes.
One of the text changes constantly ( like stock price)

The issue I see is that when the stock price value is updated (every 5 sec or so) , the text does not resize and appears out of the container.

eg.

``` kjhkj`

{{name}}

{{price}} {{attr1}}

`

Parent padding should be excluded

If the directive is wrapped inside an element with padding, it appears this is not being considered. The result is that the text is sized as if this padding was not there.

A solution could be changing:

Math.min((parent[0].offsetWidth - 6) * ratio * compressor,

to

Math.min(((parent[0].offsetWidth - (parseFloat(getComputedStyle(parent[0]).paddingLeft) + parseFloat(getComputedStyle(parent[0]).paddingRight))) - 6) * ratio * compressor,

unexpected token error

"[$parse:syntax] Syntax Error: Token '{' is an unexpected token at column 21 of the expression [{fontSize:fontSize} {fontSize:fontSize}] starting at [{fontSize:fontSize}]"

I don't have time to investigate right now but here's the piece of code that produces that error

<h5 data-fittext>{{object.property}}</h5>

which is inside a directive and a ng repeat.

Make all the objects using 'data-fittext' have the same font-size

Hi,

I'm using your plugin and I'd like to know if there's any way to have the same size for a set of elements.
I have a grid with 3 elements in it and I'd love to have a 'fixed' font-size, that would correspond to the minimal font-size in this set, for all my items in the set

Provide source in bower

For debugging purpose or to proceed own minifying process can you please provide source file through bower.

Method to reset FitText

Hi,

I have a div which the width and height is dynamic. the user can change values in an inputbox.
How can i trigger a rest of the FitText once the values change?

Thanks

using with line break

Is there a way to have a line break inside my fittext?

Is have some text that I want to display all the same size but on two lines, for example:

some
random text

the outcome I need is (all the text the same size):
some
random text

But doing this makes the text appear very large.

Can someone help?

The behavior of Jade may prevent this module to work out of the box

Hi, thank you for this module.

I had to investigate to understand why this module doesn't worked "out of the box". Just by adding data-fittext as a directive on my element.

It appears that Jade compiles data-fittext as data-fittext="data-fittext" in HTML in order to support older browser (they don't like empty attribute). I would suggest to use a specific attribute name for the compressor value instead of using the default directive attribute value.

It's not a big deal but Jade is quite popular and it will probably save some time to other people in the exact same situation :)

Regards,

Provide new version on npm

We would like to use ng-FitText, but noticed that the npm version is quite out of date and we don't make use of bower. Is there a chance we could get an updated npm version available?

debounce calls to window resize handler?

I noticed the resizer function gets called on every resize event. On systems where windows are continuously repainted as the user is resizing them, it could help to rate limit the number of resize calls per 100ms (for instance).

http://lodash.com/docs#debounce has just such an example:

// avoid costly calculations while the window size is in flux
var lazyLayout = _.debounce(calculateLayout, 150);
jQuery(window).on('resize', lazyLayout);

What do you think?

Optionally preserve original line-height

I'm using ngFitText in a context where I have several text elements aligned.
They have different lenghts, meaning they all resize differently.

Given ngFitText sets line-height: 1, they also lose the alignment.

A data-fittext-preserve-line-height="true" option, setting the line-height to the value of the original font-size, would be very handy :)

I tried myself something around this line of code:

window.getComputedStyle(element[0],null).getPropertyValue("font-size");

But I just couldn't make it properly work inside the algorithm you are using.

Doesn't work within ng-view

I've been having trouble getting this to work tonight, and after some experiments I discovered that I get great results when using this everywhere BUT within an ng-view. That is to say, with identical elements and css text will resize correctly outside of an ng-view but incorrectly within one. The text will render at font-size 10 and doesn't seem to respond to any prompting, including it seemingly ignores the data-fittext-max and data-fittext-min attributes.

Sorry I don't have time tonight to whip up an example to illustrate what I'm seeing, just thought I'd drop off the intel.

missing git tags for releases, hurting bower interoperability

If you add e.g. "ng-FitText.js": "2.0.0" to your bower.json and try "bower install", it will fail with "No versions found in git://github.com/patrickmarabeas/ng-FitText.js.git".

Thanks for releasing this project, look forward to trying it out.

font units

Hi

Is there a way to use "rem" units in data-fittext-max ?

Thanks a lot for this plugin

Line height issue

Hiya, lines seem to be overlapping in the example. I've had the same thing happen to me :( Any help?
ng-fittext_js
cursor_and_my_gym_progress

My code (i am using bootstrap)

<div class="col-xs-10 col-xs-offset-1 col-md-4 col-md-offset-4">
			<button class="col-xs-12 object-button"><span data-fittext >Create Object</span></button>						
		</div>

I would also prefer to not have a span inside the button, but not having the span there didn't work at all.
cursor_and_my_gym_progress

<div class="col-xs-10 col-xs-offset-1 col-md-4 col-md-offset-4">
			<button data-fittext class="col-xs-12 object-button">Create Object</button>						
		</div>

Relevant CSS

.object-button{
	height: 150px;
}

.other-object-button,
.object-button{
	/*font-size: 2vw;*/
	font-weight: 300;
	text-align: center;
	color: #ffffff;
	background-color: #1b39a8;
	border: 0px ;
	width:100%;
	display:inline-block;	
	/*border: 2px solid #0F358B;*/
}

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.