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

Prevent shimmer animation from affecting initial layout of the view #20

Merged
merged 2 commits into from
Jan 28, 2024

Conversation

ast3150
Copy link
Contributor

@ast3150 ast3150 commented Nov 15, 2023

This introduces two changes:

  1. Prevents the shimmer animation from propagating to the modified view
  2. Delays the initial animation until the layout of the view is established so that the initial appearance of the view is not animated.

Fixes #19

@ast3150 ast3150 mentioned this pull request Nov 15, 2023
@ikok07
Copy link

ikok07 commented Nov 15, 2023

It's working great with this fix! Thank you :)

@vladyslavsosiuk
Copy link

hi @ast3150 could you check if the prior pr fixes the issue you are addressing for you?

@Mr-Fier-1
Copy link

@vladyslavsosiuk This prior pr fix, doesnt fix this Animation bug #19.

@vladyslavsosiuk
Copy link

Do you have steps to reproduce?

@Mr-Fier-1
Copy link

Sure!

import Shimmer
import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {  // Use NavigationStack here 
            VStack {
                Text("NavigationView")
                secondView()
            }
        }
    }
}

struct secondView: View {
    var body: some View {
        RoundedRectangle(cornerRadius: 15)
            .foregroundStyle(.red)
            .frame(width: 50, height: 50)

            .shimmering()
        Text("This is the second View")
            .redacted(reason: .placeholder)
            .shimmering()
    }
}

In my case the NavigationView and NavigationStack conflicted with the modifier.
When NavigationView was used this happened:

NavigationView.mp4

and with NavigationStack this:

NavigationStack.mp4

When using the changes from this MR, the visuals are as expected.

@daniel-tandem
Copy link

This PR fixes the issue I was seeing where I was trying to apply a shimmer on a view within a NavigationStack

Sources/Shimmer/Shimmer.swift Outdated Show resolved Hide resolved
Sources/Shimmer/Shimmer.swift Show resolved Hide resolved
@ast3150 ast3150 requested a review from markiv January 25, 2024 12:38
@markiv
Copy link
Owner

markiv commented Jan 28, 2024

Prevent shimmer animation from affecting initial layout of the view

@markiv markiv merged commit 5659a62 into markiv:main Jan 28, 2024
1 of 2 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.

Animation bug
6 participants