Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply left/top bounds before scaling #2565

Merged
merged 3 commits into from
Oct 27, 2024

Conversation

qhyuan
Copy link
Contributor

@qhyuan qhyuan commented Oct 22, 2024

Should move the image to the right place before scaling it.

Should move the image to the right place before scaling it.
Copy link
Collaborator

@gpeal gpeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some context and an example of something that was broken before but working correctly now?

Copy link

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

@qhyuan
Copy link
Contributor Author

qhyuan commented Oct 22, 2024

@gpeal
sample-debug.apk.zip
image

Here is my code, you can add it to PreviewFragment to reproduce this issue. Thank you!

package com.airbnb.lottie.samples.views

import android.content.Context
import android.util.AttributeSet
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.appcompat.widget.AppCompatSeekBar
import com.airbnb.epoxy.ModelView
import com.airbnb.lottie.LottieCompositionFactory
import com.airbnb.lottie.LottieDrawable
import com.airbnb.lottie.samples.R

@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT)
class SeekBarExample @JvmOverloads constructor(context: Context?, attrs: AttributeSet? = null, defStyleAttr: Int = 0) :
    LinearLayout(context, attrs, defStyleAttr) {

    private val thumbLottieDrawable = object : LottieDrawable() {
        override fun getIntrinsicWidth(): Int {
            return 100
        }

        override fun getIntrinsicHeight(): Int {
            return 100
        }
    }

    init {
        orientation = VERTICAL
        val seekBar = AppCompatSeekBar(requireNotNull(context))
        addView(seekBar, LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))

        LottieCompositionFactory.fromRawRes(context, R.raw.bullseye)
            .addListener {
                thumbLottieDrawable.composition = it
                seekBar.thumb = thumbLottieDrawable
                thumbLottieDrawable.playAnimation()
            }
    }
}

企业微信截图_14813724-a8d5-46ef-9b92-5125f1121963

@gpeal
Copy link
Collaborator

gpeal commented Oct 22, 2024

Could you add a unit test or snapshot test that would catch this?

Should move the image to the right place before scaling it.
@qhyuan
Copy link
Contributor Author

qhyuan commented Oct 25, 2024

Could you add a unit test or snapshot test that would catch this?

Hi, are there any other issues with this commit?

Copy link

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

Copy link
Collaborator

@gpeal gpeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked other transforms and we do preTranslate before preScale in other places so this is likely correct. 🤞

@gpeal gpeal merged commit 3f4e535 into airbnb:master Oct 27, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants