You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At this moment at the very start malevic will render every child/node and thus calling onCreate once and on every node changes, every thing that specified onRender will also be executed.
as darkreader/darkreader#5926 indicates, it doesn't need to be this way. Especially when certain functions like rendering a canvas can be quite on the heavy side for the rendering.
Could the same technique be used to just execute(maybe even create these nodes) until they are visible?
The text was updated successfully, but these errors were encountered:
But you will not find out if it is visible or not until you create a node. To perform some kind of lazy rendering, you have to subscribe on window resize and scroll events (not applicable to Dark Reader's UI), and do some custom logic inside a component, to check if it is visible and to render its content separately, for example:
import{m}from'malevic';import{sync,render,getContext}from'malevic/dom';exportdefaultfunctionLazyContainer(props, ...content){constcontext=getContext();context.onRender((node)=>{if(node.offsetHeight===0){// or maybe some more stable checkrender(node,content);}};if(!context.node){constelement=context.node||document.createElement('div');sync(element,<divclass="lazy-element"></div>);returnelement;}returncontext.node;}
Sounds about right and good for now. Considering that it the execute function is in most cased under a millisecond and that these big render functions can be mitigated to check the offsetXXX property.
At this moment at the very start malevic will render every child/node and thus calling onCreate once and on every node changes, every thing that specified onRender will also be executed.
as darkreader/darkreader#5926 indicates, it doesn't need to be this way. Especially when certain functions like rendering a canvas can be quite on the heavy side for the rendering.
Could the same technique be used to just execute(maybe even create these nodes) until they are visible?
The text was updated successfully, but these errors were encountered: