Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force refreshing #46

Open
piwel opened this issue Feb 19, 2016 · 7 comments
Open

Force refreshing #46

piwel opened this issue Feb 19, 2016 · 7 comments

Comments

@piwel
Copy link

piwel commented Feb 19, 2016

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.

@patrickmarabeas
Copy link
Owner

I've been mulling the idea of giving the fitTextConfigProvider an array of things to watch. Won't be able to implement this for the next ~month though unfortunately, so feel free to make a PR if you get something working in the meantime.

@andreadompe
Copy link

I use this workaround,

    <div id="containerdiv">
        <h1 data-fittext> Ciao Ciao!<h1>
    </div>

in the event resize

$compile($('#containerdiv'))($scope);

It's worked for me

@devidation
Copy link

Hi,
I have been trying to create my own speeddial thing and use fittext to change the font size of the tile titles. However I've created some sliders to change to width and height of each tile. I would now like to update/trigger the directive to resize the text when i change the size of the tile.
Using the above solution from andreadompe works just fine however the more it's used(the more times you change the tile size) the slower the rendering of the browser becomes. Sliding several times makes the window very laggy until you refresh the page.
Is there still no other method to trigger the directive through in other ways?
Thank in advance.

@patrickmarabeas
Copy link
Owner

@devidation: Debounce the call your slider makes. Have a look at how ngFitText handles the resize event if a debounce function is supplied.

@jmartinezuk
Copy link

jmartinezuk commented Jul 28, 2016

Ok, I solved this by simply doing a $(window).trigger('resize'), which the plugins listens to, to update itself, after changing the content.

On a side note, for others that might run into this, on angular 1.5+, when updating the scope itself, I was running into the "$scope.digest already in progress" errors... I solved it by removing the scope.apply and just calling resizer() on its own:
config.debounce ? angular.element(window).bind('resize', config.debounce(function(){ scope.$apply(resizer)}, config.delay)) : angular.element(window).bind('resize', function(){ resizer()}); }

@patrickmarabeas
Copy link
Owner

If you can create a demo on codepen illustrating the digest issue I'll look at fixing.

@mos379
Copy link

mos379 commented Jul 25, 2021

ran into this issue and solved it by doing small changes in the directive
added
if (attrs.fittextMax != undefined && maxFontSize !== attrs.fittextMax) { maxFontSize = attrs.fittextMax; }
in the caclulate() function

and added
scope.$eval(attrs.fittextMax),
to the watch

Now I can dynamically adjust the size by adjusting it in the model and using it in the html
data-fittext-max="{{vm.maxSize}}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants