Skip to content

Commit

Permalink
- add ability to disable the animation for the placeholder via the Im…
Browse files Browse the repository at this point in the history
…ageTransformer

  - FIX #212
  • Loading branch information
mikepenz committed Nov 1, 2024
1 parent 42d5564 commit 810a90a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,32 +128,36 @@ fun MarkdownText(
imageState.setContainerSize(coordinates.size)
}
}
.animateContentSize(),
.let {
if (placeholderState.animate) it.animateContentSize() else it
},
style = style,
color = LocalMarkdownColors.current.text,
inlineContent = mapOf(MARKDOWN_TAG_IMAGE_URL to InlineTextContent(
Placeholder(
width = placeholderState.size.width.sp,
height = placeholderState.size.height.sp,
placeholderVerticalAlign = placeholderState.verticalAlign
)
) { link ->
transformer.transform(link)?.let { imageData ->
val intrinsicSize = transformer.intrinsicSize(imageData.painter)
LaunchedEffect(intrinsicSize) {
imageState.setImageSize(intrinsicSize)
}
Image(
painter = imageData.painter,
contentDescription = imageData.contentDescription,
modifier = imageData.modifier,
alignment = imageData.alignment,
contentScale = imageData.contentScale,
alpha = imageData.alpha,
colorFilter = imageData.colorFilter
inlineContent = mapOf(
MARKDOWN_TAG_IMAGE_URL to InlineTextContent(
Placeholder(
width = placeholderState.size.width.sp,
height = placeholderState.size.height.sp,
placeholderVerticalAlign = placeholderState.verticalAlign
)
) { link ->
transformer.transform(link)?.let { imageData ->
val intrinsicSize = transformer.intrinsicSize(imageData.painter)
LaunchedEffect(intrinsicSize) {
imageState.setImageSize(intrinsicSize)
}
Image(
painter = imageData.painter,
contentDescription = imageData.contentDescription,
modifier = imageData.modifier,
alignment = imageData.alignment,
contentScale = imageData.contentScale,
alpha = imageData.alpha,
colorFilter = imageData.colorFilter
)
}
}
}),
),
onTextLayout = {
layoutResult.value = it
onTextLayout.invoke(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ interface ImageTransformer {
data class PlaceholderConfig(
val size: Size,
val verticalAlign: PlaceholderVerticalAlign = PlaceholderVerticalAlign.Bottom,
val animate: Boolean = true,
)

@Immutable
Expand Down

0 comments on commit 810a90a

Please sign in to comment.