multiplatform-markdown-renderer icon indicating copy to clipboard operation
multiplatform-markdown-renderer copied to clipboard

Provide an option to remove bad animations

Open keta1 opened this issue 1 year ago • 1 comments

About this issue

  • Briefly describe the issue
  • How can the issue be reproduced / sample code

Details

MarkdownBasicText contains a very bad default animation, please provide an option to remove this animation

see code here https://github.com/mikepenz/multiplatform-markdown-renderer/blob/develop/multiplatform-markdown-renderer/src/commonMain/kotlin/com/mikepenz/markdown/compose/elements/MarkdownText.kt#L131

Checklist

keta1 avatar Sep 20 '24 17:09 keta1

Thank you for bringing this up. A PR to address this feature request would be greatly appreciated!

mikepenz avatar Sep 27 '24 09:09 mikepenz

@mikepenz sorry to interrupt. I know this has been closed and implemented, I just can't get the animation disabled. I am trying with this code:

At the bottom, I add animate=false.

CompositionLocalProvider(LocalImageTransformer provides CustomImageTransformer()) {
                                Markdown(
...


class CustomImageTransformer : ImageTransformer {

    @Composable
    override fun transform(link: String): ImageData? {
        return null
    }

    override fun placeholderConfig(density: Density, containerSize: Size, intrinsicImageSize: Size): PlaceholderConfig {
        return PlaceholderConfig(
            size = with(density) {
                if (containerSize.isUnspecified) {
                    Size(180f, 180f)
                } else if (intrinsicImageSize.isUnspecified) {
                    Size(containerSize.width.toSp().value, 180f)
                } else {
                    val width = minOf(intrinsicImageSize.width, containerSize.width)
                    val height = if (intrinsicImageSize.width < containerSize.width) {
                        intrinsicImageSize.height
                    } else {
                        (intrinsicImageSize.height * containerSize.width) / intrinsicImageSize.width
                    }
                    Size(width.toSp().value, height.toSp().value)
                }
            },
            animate = false
        )
    }
}

Besides that, I find API-wise, linking MarkdownText animations to ImageTransformer is not very intuitive name-wise, but I suppose it is done this way since the images are displayed inline. Maybe some MarkdownAnimationProvider would be nicer? But just a minor detail.

Dima-369 avatar Dec 19 '24 20:12 Dima-369

@Dima-369 can you please create a new issue for this, so it's not being lost.

While animation was only part of the image loading at this time, I agree it might be long term more fitting to make it its own config.

mikepenz avatar Dec 20 '24 12:12 mikepenz

can you please create a new issue for this, so it's not being lost.

Sure, I created https://github.com/mikepenz/multiplatform-markdown-renderer/issues/244

Dima-369 avatar Dec 20 '24 12:12 Dima-369