angular-ellipsis icon indicating copy to clipboard operation
angular-ellipsis copied to clipboard

Show all

Open LordZombi opened this issue 10 years ago • 9 comments

How can I show all text on click please ? I tried to change the height of element, but I think it needs some 'restart' after then. Can you help me ? Thankx

LordZombi avatar Jan 22 '14 15:01 LordZombi

You want the full text to be shown when the append text is clicked? Or, you want the full text to be shown when any of the concatenated text is clicked?

dibari avatar Jan 27 '14 01:01 dibari

Just when I click on append text would be OK.

LordZombi avatar Jan 27 '14 08:01 LordZombi

I'm running into the same issue. I have angular-ellipsis working and truncating correctly, but when I add ellipsis-append and ellipsis-append-click, I'm not sure how to "turn off" the truncation effect when I click the ellipsis-append element.

For example, here I have my section set to max-height: 150px, and when you click Read more, I remove the max-height by using ng-class:

<section
    ng-bind="description"
    ellipsis
    ellipsis-append="Read more"
    ellipsis-append-click="showFullText=true"
    ng-init="showFullText=false"
    ng-class="{'unabbreviated':showFullText}">
</section>
section {
  max-height: 150px;
}
section.unabbreviated {
  max-height: none;
}

I can observe in the Web Inspector that the unabbreviated class is being applied by Angular when I click the ellipsis-append element, so that part is working correctly, but angular-ellipsis does not then re-evaluate the element's new height and show the full text that existed before the directive was applied.

command-tab avatar Mar 21 '14 18:03 command-tab

I just noticed something: the above is still true, but I can trigger the re-evaluation of the height by resizing my browser just a little. So, to make the above "work", I click Read more, then resize my browser window. It's so close to perfect!

command-tab avatar Mar 21 '14 18:03 command-tab

I seem to have fixed this by calling buildEllipsis(); right after scope.$apply gets called, but I'm unsure if it's a good fix.

command-tab avatar Mar 21 '14 18:03 command-tab

Can u share your code @commandtab ? How do you trigger that? Did you fork the project?

goldylucks avatar Mar 30 '15 09:03 goldylucks

Sorry, I don't think I have that snippet anymore, @Adam-Goldman7. The shipping code ended up with a small directive wrapping jQuery dotdotdot, and that's been working well in production for some time.

command-tab avatar Mar 30 '15 15:03 command-tab

@commandtab, would you mind sharing your dotdotdot angular integration ?

max-l avatar Aug 27 '15 17:08 max-l

@max-l It's remarkably short. Once dotdotdot is loaded (I use RequireJS, but really any JS loader ought to work), you keep track of whether you've already applied dotdotdot to the element, and if not, apply it:

angularModule.directive('dotdotdot', [function () {
  return {
    required: 'ngBindHtml',
    restrict: 'A',
    priority: 100,
    link: function ($scope, element, attrs, ctrl) {
      $scope.isTruncated = false;
      $scope.$watch(element.html(), function (value) {
        if (!$scope.isTruncated) {
          $scope.isTruncated = true;
          element.dotdotdot();
        }
      })
    }
  };
}])

Usage might be a little different depending on if your directive's content is being trusted as HTML, but that's the basic idea.

command-tab avatar Aug 27 '15 17:08 command-tab