-
-
Notifications
You must be signed in to change notification settings - Fork 565
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
Suggestion: Keep Scrolling Position on Resizing #212
Comments
It's not possible at the moment, but that would definitely be a good feature! I've thought about it in the past but never tried implementing. I'll have to think about it again, and look up how things like scroll views handle it - that would probably be the best model to mimic. |
Is there any update on this? In my case it isn't resizing but the label seems to restart scrolling whenever a popover or modal view controller is presented. I don't know if it is related (would be helpful to know if so) but I've run into issues where the label doesn't show up (but is definitely added as a subview) until some sort of resizing/modal presentation occurs and then it pops up as visible. Not sure what's going on there... any ideas, @cbpowell? I have found a sorta kinda hacky way to get around the labels constantly restarting:
Unfortunately does not address the bit about the labels not being visible onscreen (but added to the hierarchy), until I guess layoutSubviews is called again. |
I haven't put any time into trying to maintain scrolling position, but I do still think it would be a good feature! The problem is all the scroll animations are based on the home and away positions, which are in turn functions of the label's frame size. So if the frame size changes due to a rotation (or for any other reason) the animation would need to be adjusted in-flight so that the label goes to the correct position on that animation loop. Certainly not impossible, but requires more work than just commenting out a few lines! @isaranjha your problems sound like possibly two separate issues, but at a high level MarqueeLabel tries to automatically catch when to perform its view layout and updates all of the require information at that point, but I guess it's missing however you're doing it? I won't claim to be totally up to date on all the latest iOS view layout mechanics, but I thought generally Instead of that hack, perhaps use |
I see. So I added the check for awayFromHome in order to solve issue #1 of the label restarting whenever there's a resize/presentation. It solved it well! Fingers crossed. Not ideal, but seems to work well in my use case even with rotations/etc. The most odd behavior I could see is it stopping for a quick second when it's actually at home, but that's not a huge deal in comparison it to it restarting and looking jerky. If something breaks, I'll be sure to let you know! As far as issue #2, being that the label doesn't automatically show up until there's a resize/presentation, I tried setting setNeedsLayout() but it didn't budge, unfortunately. I do have the MarqueeLabel as a subview to another UIView but I agree that it should catch the layout and show up properly. I'll keep playing with it. |
Welp! I solved it. Turns out I needed to call setNeedsLayout() on self.view. Strange but again, it works. 🤷🏻♂️ |
Weird, but nice! Glad you solved it. |
@cbpowell , @isaranjha |
@integral0909 |
Is it possible to keep the current scrolling position or state after layout changes?
For example: scrolling is about 50%, the frame changes from (100pt x 20pt) to (101pt x 20pt). At the moment the animation restarts from the beginning. Maybe a property "keepScrollingPossition: Bool"
The text was updated successfully, but these errors were encountered: