Comments (6)
I think it could be for two reasons.
- Plugin works laggy with text nodes. This is most likely due to the fact that you have one extra loop inside
loadFonts(selection)
. This can be fixed by changing toloadFonts(node)
, and removing loop throughselection
from the function. figma.loadFontAsync()
inside a loop. It would be better to usePromise.all()
However, note that loadFontAsync returns a Promise. Even a Promise resolves immediately, it still needs to round-trip to the JavaScript event loop. So you probably shouldn't call loadFontAsync on the same font repeatedly inside a loop.
https://www.figma.com/plugin-docs/api/properties/figma-loadfontasync/#docsNav
from fromcss.
Good point. I believe at least one loop is necessary as it has to loop through all sub node ranges to be able to load in all the different variants as pictured below:
from fromcss.
Hmm yeah as I feared:
- The first outer loop is necessary to apply to more than one text element being selected
- The second inner loop is needed to get the individual text ranges inside
Two suggestions:
- Is there a way to memoize? Maybe
_.memoize
or some Vue alternative? - Do we need to go character by character or can we load
0, len
instead ofi, i+1
?
from fromcss.
I may have misspelled my point. I haven't practiced my English for a long time
About extra loop: I uploaded this fix here https://github.com/jamillazarev/fromCSS/tree/fix-perfomance-of-updating-text-nodes
About caching: Vue has computed properties https://vuejs.org/v2/guide/computed.html
Based on the documentation, figma caches this aspect itself. It seems to me that we should try to wait for all the promises.
from fromcss.
As far as I can see after a little refactoring, everything works fine. However, I noticed other issues...
from fromcss.
After restarting figma, the problem returned... ๐คจ
from fromcss.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fromcss.