Code Monkey home page Code Monkey logo

Comments (5)

MartinMalinda avatar MartinMalinda commented on September 15, 2024 1

So far it's not public, but I might later release it as something like vue-lineclamp or something like that. Will share a link here when that happens!

from lineclamp.

tvanc avatar tvanc commented on September 15, 2024

From the order of the issues you opened, I'm guessing you attempted to implement the requested functionality by saving the clamped element's original markup/text and then listening for clamping events, saving the resulting markup and then restoring?

Are you able to achieve the desired outcome more easily now that the clamp events don't fire unless clamping actually occurs?

from lineclamp.

MartinMalinda avatar MartinMalinda commented on September 15, 2024

@tvanc thanks, I did managed to implement it now! The only issue now is that the algorithm is too good at clamping at the end of line, while I would like to leave space for the "show more" button. But I'll see if I could apply an adhoc mutation to fix that case.

from lineclamp.

MartinMalinda avatar MartinMalinda commented on September 15, 2024
el.addEventListener("lineclamp.clamp", () => {
  isClamped.value = true;
  el.textContent = el.textContent?.slice(0, -20) + "... ";
});

Not flawless, but it seems like it does the job! I was afraid that I'd be continously losing the text on toggling but it's not the case.

from lineclamp.

tvanc avatar tvanc commented on September 15, 2024

Excellent! I'm glad to hear it. If your use of my lib is public I wouldn't mind seeing it?

from lineclamp.

Related Issues (5)

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.