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

Unable to run a ForEach loop into it #9

Open
nameHabbo opened this issue Feb 12, 2024 · 3 comments
Open

Unable to run a ForEach loop into it #9

nameHabbo opened this issue Feb 12, 2024 · 3 comments

Comments

@nameHabbo
Copy link

Been looking for something like this for ages tonight but ive found an annoying bug? when I run the ForEach with the code below the marquee restarts the instant the first text hits the edge of the frame.

Im trying to create a Marquee of game resutls but the second the edge of the first one hits the edge of the box it restarts the loop.

Marquee { HStack{ ForEach(function.lastTen(), id: \.matchRecord.id) {index in HStack { Text("\(function.playerName(for: index.matchRecord.playerId))") Text("VS") Text("\(index.winnerName)") Image(systemName: "trophy.fill") } .padding(.trailing, 50) .font(.system(size: 20)) .foregroundColor(.white) } } } .frame(width: 200, height: 50) .background(Color.mint.opacity(0.8)) .marqueeDuration(duration)

If I run the code below without the external HStack however it loops round perfectlly like expected, but now my ForEach loop is displaying stacked ontop of each other not horizontally.

@stonko1994
Copy link

Hi @nameHabbo,

I had a look at this issue but was not able to reproduce it on my end 🤔

I'm doing something very similar in one of my apps, and it works fine. Could you share additional context or maybe also a little screen recording of the behaviour?


This is what I'm doing in my app:

Marquee {
    HStack {
        Text("(")
            .fontWeight(.regular)
            .foregroundColor(Color(UIColor.label))
        HStack(spacing: 30) {
            ForEach(regularPeriodScores, id: \.index) { periodScore in
                Text(periodScore.scoreInformation)
                    .tracking(10)
                    .fontWeight(.regular)
                    .foregroundColor(periodScore.isActive ? .appBlue : periodScore.isFinished ? .appRed : Color(UIColor.label))
            }
        }
        Text(")")
            .fontWeight(.regular)
            .foregroundColor(Color(UIColor.label))
    }
}
.frame(width: 200, height: 50)
.marqueeDuration(5)
.marqueeDelay(2)
.marqueeAutoreverses(true)
.marqueeWhenNotFit(true)
.marqueeBoundary(.inner)
.marqueeIdleAlignment(.center)

and this is how it looks:

ezgif com-video-to-gif-converter

I also tried to use a HStack inside the ForEach with multiple Text as you have it but it still worked as expected. Are you using Marquee from my fork or from this repo?

@nameHabbo
Copy link
Author

Hello @stonko1994 ,

Im gonna try the code you have within my xcode to see if its something im doing wrong or what im trying to inject because even when i was doing a very simple ForEach loop i was still getting the same issue, im also not sure why my code in the above comment looks like i did so trying to upload a video may not have gone well either haha. i will try and get back to you.

im also using the original package, shall i try yours instead??

@stonko1994
Copy link

im also using the original package, shall i try yours instead??

Yes, try my fork from https://github.com/stonko1994/Marquee. It does contain a few fixes and improvements.

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

No branches or pull requests

2 participants