Skip to content

Commit

Permalink
Merge pull request #227 from mikepenz/fix/212
Browse files Browse the repository at this point in the history
Add new ability to configure `PlaceholderConfig` to disable animation via the `ImageTransformer`
  • Loading branch information
mikepenz authored Nov 1, 2024
2 parents 76c72af + 810a90a commit 9fc62f7
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 9fc62f7

Please sign in to comment.