Coder Social home page Coder Social logo

Comments (10)

asturur avatar asturur commented on June 2, 2024

Hi @Jonnas123 what do you mean by zoom the text?

from fabric.js.

Jonnas123 avatar Jonnas123 commented on June 2, 2024

I mean use mouse wheel to zoom in.

from fabric.js.

asturur avatar asturur commented on June 2, 2024

Yes there is a simple bug.

    if (
      this.paintFirst === 'stroke' &&
      this.hasFill() &&
      this.hasStroke() &&
      typeof this.shadow === 'object'
    ) {
      return true;
    }

we are running this condition to determine if the object needs the cache forced on.
Somehow since some change, this.shadow is an object even if we are not setting it.

This is probably an easy fix ( i didn't look at it ).

If you look at it is also possible you can open a PR to fix it.

from fabric.js.

asturur avatar asturur commented on June 2, 2024

https://github.com/fabricjs/fabric.js/blob/master/src/shapes/Object/defaultValues.ts#L79

Here the shadow is set as 'null' as a default.

I sincerly do not remember why we have the shadow property typed as Shadow | null, it could just be ?: Shadow and then fix the code to actually work with this change.

A simpler and more direct fix is to update that condition to say:

this.paintFirst === 'stroke' &&
      this.hasFill() &&
      this.hasStroke() &&
      this.shadow !== null 

Probably less involved

Would require adding a jest test anyway in both cases

from fabric.js.

Jonnas123 avatar Jonnas123 commented on June 2, 2024

Could you give a hint on where to place the codes? I 've tied both codes inside and outside the zoom function but not working.

from fabric.js.

ShaMan123 avatar ShaMan123 commented on June 2, 2024

start using codesandbox for repro
https://codesandbox.io/p/sandbox/fabric-vanillajs-sandbox-forked-y3kryw?file=%2Fsrc%2Findex.ts%3A14%2C24

from fabric.js.

asturur avatar asturur commented on June 2, 2024

Could you give a hint on where to place the codes? I 've tied both codes inside and outside the zoom function but not working.

if you do a full search for this.paintFirst === 'stroke' you shouldn't get more than one or two results.
One of those results is 'needsItsOwnCache' that is the one you need to fix.

Even better, if you just look for typeof this.shadow === 'object' you find the exact bug and code.

from fabric.js.

gloriousjob avatar gloriousjob commented on June 2, 2024

@asturur Do you have a recommendation for testing? This looks like a visual test (i.e., pixelmatch to see if the blur occurs) but I'm not sure that there's an example for jest. Is something like this needed?
https://github.com/americanexpress/jest-image-snapshot

Or did you have a simpler idea?

from fabric.js.

ShaMan123 avatar ShaMan123 commented on June 2, 2024

We use playwright for that.
Look at https://github.com/fabricjs/fabric.js/tree/master/e2e/tests/template-with-node

from fabric.js.

asturur avatar asturur commented on June 2, 2024

I don't think a visual test is a good idea.
For a visual test is hard to determine if something is blurry or not.
We just need to test the output of 'needsItsOwnCache' function for a text object with different combination of properties.
The bug is not being blurry, that is not a bug itself, the bug is that it force cache on, against your request without a valid reason.

from fabric.js.

Related Issues (20)

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.