kswedberg / jquery-expander

Expand and Collapse HTML content
https://kswedberg.github.io/jquery-expander/
Other
459 stars 167 forks source link

Mobile - shows all text before collapsing #39

Closed mikemoser closed 12 years ago

mikemoser commented 12 years ago

Great plugin, thanks!

I've notice on mobile (iOS and Droid) that the full text shows for a split second, then it collapses to "see more". Is there a way to avoid this?

Thanks, -mm

komapa commented 12 years ago

I set display:none of the .truncate class and then:

$('.truncate').expander({ onSlice: function() { $(this).show(); } });

kswedberg commented 12 years ago

Excellent suggestion, @KirilAngov.

@mikemoser: I'd further recommend that you make sure display: none is only applied to the truncate class if JavaScript is enabled. To do so, if you're not already using Modernizr, reference a <script> in the <head> that has this line in it:

document.documentElement.className += ' js';

Then, in your CSS, do this:

.js .truncate {
  display: none;
}

Read this blog post for more information about js-only style rules.

komapa commented 12 years ago

This is exactly how we use it, with .js and Modernizr but did not want to overcomplicate the comment/solution. Thanks for your work @kswedberg!

kswedberg commented 12 years ago

Excellent! I suspected so. And you're welcome. I'm happy to be able to share my work.