AsyncAttachmentRenderingDelegate
public protocol AsyncAttachmentRenderingDelegate : AnyObject
Describes an object that fulfils requirements to enable asynchronous rendering of attachments in the EditorView
-
Provides the viewport for the
Editor
. In typical cases, this would be used if theEditorView
is made non-scrollable and hosted within another scrollable container i.e. ScrollView.Note
To use default value, i.e. viewport of the EditorView, leave this value asnil
Important
EditorView
also has aviewport
property that also depends on this property. Care must be taken to not to returneditor.viewport
here. Doing so will cause a stack overflow crash. An independently calculated value can safely be returned here.Declaration
Swift
var prioritizedViewport: CGRect? { get }
-
Determines if particular attachment should be rendered asynchronously. The check may also be used to render certain types of attachments synchronously or asynchronously.
Declaration
Swift
func shouldRenderAsync(attachment: Attachment) -> Bool
Parameters
attachment
Attachment to be rendered.
Return Value
true
to render asynchronously. -
Notifies when an attachment is rendered asynchronously.
Declaration
Swift
func didRenderAttachment(_ attachment: Attachment, in editor: EditorView)
Parameters
attachment
Attachment that is rendered.
editor
Editor in which the attachment is rendered.
-
Notifies when the viewport is rendered. Value of
viewport
is governed byviewport
property inAsyncAttachmentRenderingDelegate
when not nil, else fromEditorView
Note
There may be more than one invocation for the sameviewport
especially when user scroll out and back to the sameviewport
. This is invoked when all the attachments in theviewport
are rendered or the text is laid out and there are no attachments to render.Declaration
Swift
func didCompleteRenderingViewport(_ viewport: CGRect, in editor: EditorView)
Parameters
viewport
Viewport that is rendered.
editor
Editor for which the
viewport
rendering is completed.