One unresponsive image appears at top of stack
Describe the bug
I think it might have something to to with adding images dynamically. I am doing it this way:
self.cardImages.append(loadedImg)
let newIndices = Array(self.cardImages.count-1..<self.cardImages.count)
self.cardStack.appendCards(atIndices: newIndices)
Hey @mran3, the code snippet you provided looks fine. Also if you're only adding one card at a time, you can just do
cardImages.append(loadedImg)
cardStack.appendCards(atIndices: [cardImages.count - 1])
Where is this code being called? Are you calling on the main thread?
@mran3 did you find a fix for this? I am still unable to reproduce it and would like to address this issue
Hi I needed to send some example project so I ended up using another library. It could be my fault because I was adding images to the stack downloaded from an URL and the error used to appear when calling reloadData.
Ingeniero de sistemas y escritor Twitter: @mran3
On 17/07/2020, at 4:01 PM, Mac Gallagher [email protected] wrote:

@mran3https://github.com/mran3 did you find a fix for this? I am still unable to reproduce it and would like to address this issue
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/mac-gallagher/Shuffle/issues/108#issuecomment-660335976, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAT4W5JYLA5QNSWZHBIZH23R4C32HANCNFSM4OYGJ2MA.
@mran3 Thanks for the update. The appendCards feature is new so it could very well be an issue with the library. I will keep this open for now in case others face the same issue
Hi, I am facing this issue I guess.
I am adding cards dynamically using the apendCards method. Also, I am adding cards again and again to achieve infinite swiping.
Issue:
- Sometimes, when I do a swipe, one card gets stuck on the top. I am able to do the swiping, but the cards below the stuck card get swiped and the stuck card never goes away.
- Here is how it behaves:
Yeah, that is what happened to me.
De: Sharad Chauhan [email protected] Enviado: jueves, 10 de septiembre de 2020 4:38 a. m. Para: mac-gallagher/Shuffle [email protected] Cc: Andres Acevedo [email protected]; Mention [email protected] Asunto: Re: [mac-gallagher/Shuffle] One unresponsive image appears at top of stack (#108)
Hi, I am facing this issue I guess. I am adding cards dynamically using the apendCards method. Also, I am adding cards again and again to achieve infinite swiping.
Issue:
- Sometimes, when I do a swipe, one card gets stuck on the top. I am able to do the swiping, but the cards below the stuck card get swiped and the stuck card never goes away.
- Here is how it behaves: [ezgif com-video-to-gif]https://user-images.githubusercontent.com/16999326/92712507-676bd780-f377-11ea-8028-250471f66ec8.gif
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/mac-gallagher/Shuffle/issues/108#issuecomment-690115648, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAT4W5MNE55LI5XIJPZYOFLSFCNBNANCNFSM4OYGJ2MA.
@mran3 @skdevil can you share how you're adding the new cards? Are you calling appendCards on the main thread?
@mac-gallagher Yes I am using that on main thread. This is how I am adding more cards:
let oldModelsCount = self.offersArray.count
let newModelsCount = oldModelsCount + self.individualOffersArray.count
self.offersArray += self.individualOffersArray
let newIndices = Array(oldModelsCount..<newModelsCount)
self.cardStack.appendCards(atIndices: newIndices)
Ok, where are you calling this code block from? One of the delegate methods?
@mac-gallagher No, I am calling this after I get a response from API. It's a paginated API, so right after I get one page, I call this code.
So you’re not calling the API immediately after a swipe?
No, it’s adding as soon as it is getting response.
Got it. Will look into this. I’m wondering if it’s updating the card stack in the middle of an animation
Yes, that is correct. I feel so, it updates the cards in between.
@mac-gallagher Hi, did you get a chance to look into it?
Hey @skdevil . Yes, I took a look and it doesn't seem like a straightforward fix. I'd like to do something similar to what I mentioned here: https://github.com/mac-gallagher/Shuffle/issues/112#issuecomment-673252305. Maybe to detect if the card stack is animating, you could subclass SwipeCard and override the beginSwiping/continueSwiping/endSwiping methods to detect if the top card is being dragged. However, there is still the issue of detecting if the top card is animating.
Unfortunately, I won't have the time to put out a fix anytime soon (working full time + other side projects). Feel free to throw any suggestions out or put up a PR in the meantime
@mac-gallagher Hi, did you get a chance to work on this issue? I'm having some troubles as well.
@mac-gallagher Hi, sorry to bother you. I just wanted to ask you if you plan on working on what you mentioned here https://github.com/mac-gallagher/Shuffle/issues/112#issuecomment-673252305 or if maybe there's already a PR or a fork of this repo that does this, or fixes this bug. Thanks for your time, and this library is great!
Hey, did any of you fix/ got a workaround for this.
I'm also interested in a fix - thanks.
I found these two forks that mentions this issue:
- https://github.com/Yahenskyi/Shuffle
- https://github.com/LiuSky/Shuffle
I haven't tried them yet, but maybe they work. Let me know!
I've integrated LiuSky's method of fetching the isAnimated status and optimized it to my needs a little bit. It's working better than before but in case of faster swipes it's still the case that the issue appears. Edit: After some more testing I can say that this method is not helping much..
@mac-gallagher Do you have an alternative solution for this?
I'm also experiencing this. I'll try using isAnimating but in any case this is not good.
I wrote an email to @mac-gallagher and he said that he's working on some other projects right now + fulltime job, so I don't think he'll be able to help us.
Anyone got any idea on how to fix this?
Guys, we fixed it by appending the cards on the swipeCardStack on the main thread.
So wrap the method where you append the cards like:
DispatchQueue.main.async {
self.updateCards(values)
}
Let me know if this solution fixes the problem for you as well!
Guys try this temporary fix: update this function in this file: SwipeCardStack.swift
func reloadVisibleCards() {
visibleCards.forEach {
$0.card.swipeDirections = []
$0.card.removeFromSuperview()
}
visibleCards.removeAll()
cardContainer.subviews.forEach { $0.removeFromSuperview() }
let numberOfCards = min(stateManager.remainingIndices.count, numberOfVisibleCards)
for position in 0..<numberOfCards {
let index = stateManager.remainingIndices[position]
if let card = loadCard(at: index) {
self.insertCard(Card(index: index, card: card), at: position)
}
}
isAnimating = false
}
you can also check my fork: https://github.com/ifamirhasan/Shuffle/tree/dev