Skip to content

I've tweaked the event attachment so you are able to stop FitText from firing without removing the window resize event. #28

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

Closed
wants to merge 4 commits into from

Conversation

replete
Copy link

@replete replete commented May 11, 2012

No description provided.

replete added 4 commits May 11, 2012 14:41
… other (window).resize events.


Would be better to write a function to turn fitText off, which detached the event and removes style tag font-size.
-Added `event` option, which allows you to define what event fitText fires on (useful if using custom debounced resize events, for example)
@federicovezzoli
Copy link

Sorry, I do not understand how to call the off event to disable fittext. Anyone can help me?

@davatron5000
Copy link
Owner

A resize.fittext event was added in 57ce345 This probably solves the functionality of your use case. Thanks for you commit.

@federicovezzoli You can disable fittext with:

$('.myelems').off('resize.fittext orientationchange.fittext');

@federicovezzoli
Copy link

hey @davatron5000 thanks for the tip.
But If I remove the handler on the element is not working, it works if I remove it from the window element.
so, it works only with:

$(window).off('resize.fittext orientationchange.fittext');

Is there any way to disable it only on some selectors, like in the example you gave?

@davatron5000
Copy link
Owner

Hmm... sounds like you're trying to use window.resize to trigger a window.resize. In that case, I'd probably go a different route and hijack fittext's resize instead.

$(window).on('resize.fittext', function(){
  var mediaQuery = '(max-width: 480px)';
  if(window.matchMedia(mediaQuery).matches) {
    $('h1.fixedFontSizeOnMobile').css('font-size', '36px');
  }
});

Anyways, this is personal support stuff for your specific implementation and not relevant to bugs, issues, or functionality to this plugin. I recommend asking your questions over on StackOverflow. Thanks.

@federicovezzoli
Copy link

Sorry than.

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

Successfully merging this pull request may close these issues.

3 participants