Giter VIP home page Giter VIP logo

Comments (26)

PomepuyN avatar PomepuyN commented on May 14, 2024 3

Hi,
Thanks for the quick answer but I am not sure how to use it (and I think I did not explain really well the issue).

Bug explanation

I do not call setDrawerPosition at all, it's the initialDrawerPositionFromIB that is broken when used in another tab.

Here is my StoryBoard:
StoryBoard

As you can see, I use Pulley in the second tab.
When I open it, even if the initialDrawerPositionFromIB is set to "collapsed", the drawer is animated from the top.

Here is the stack leading to setDrawerPosition(position: .collapsed, isAnimated: true)

PulleyViewController.viewDidLoad()
 ↘️ PulleyViewController.primaryContentViewController.didset
    ↘️ PulleyViewController.setNeedsSupportedDrawerPositionsUpdate()
       ↘️ PulleyViewController.supportedPositions.didset
          ↘️ PulleyViewController.setDrawerPosition(position:isAnimated:) //animated is true

You can simply debug it in the attached sample project by adding a breakpoint in PulleyViewController.setDrawerPosition() at the first line and see that the first call is animated.

PulleyTest.zip

Proposed solution

My proposed solution was to allow us the override setDrawerPosition.
The reason is that you may not want to manage this special case (in which Pulley is embed a another tab) as it may have side effects on the "natural" use case.

In this case, I would use a class extending PulleyViewController and forcing animation to false if the call is the first one (even if I agree, it would just be a workaround).

The ideal solution would be to make it work in my case though.

I hope that I have made it clearer and sorry if not (I am relatively new to iOS development).

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024 3

Okay, after some additional testing I've gone ahead and pushed this fix out to CocoaPods. It's version '2.2.9'. Assuming you haven't pinned your Pulley version, you can get the update by doing pod update Pulley. You made need to run pod repo update first.

Since this seems to be important to a lot of people, I'm gonna tag the people interested in this thread below so they see the notification.

@cyrilzakka @PomepuyN @azurechen @azhang66 @Vadim4016 @pablomarcos

If anyone has any issues, please let me know. I'll try to get them taken care of ASAP. Once a few people have reported back with success, then I'll close the issue. Thanks, everyone.

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024 2

It sounds like an issue with how you’re adding it to your view hierarchy. For example, the demo project doesn’t have that issue.

How’re you adding / presenting the controller?

from pulley.

cyrilzakka avatar cyrilzakka commented on May 14, 2024 1

Turns out changing this to false seems to have fixed the issue!

public func setDrawerPosition(position: PulleyPosition)
{
    setDrawerPosition(position: position, animated: false)
}

from pulley.

PomepuyN avatar PomepuyN commented on May 14, 2024 1

I second this issue.
I am currently using a PulleyViewController in an UITabBarController and when you load a tab for the first time, the drawer is jumping.
The only way to solve it for now is to import the lib manually and change the first setDrawerPositioncall to avoid the animation.
A quick and easy fix would be to declare this method open so we can override it (and avoid having to clone the entire library).
Another one could be to allow the drawer not to animate the first setDrawerPositioncall.

from pulley.

azhang66 avatar azhang66 commented on May 14, 2024 1

Fixed for me. Thanks!

from pulley.

PomepuyN avatar PomepuyN commented on May 14, 2024 1

The new version also fixed the issue for me

from pulley.

cyrilzakka avatar cyrilzakka commented on May 14, 2024

Doing everything from Storyboard - nothing really special about my setup. Any ideas what I should look into?

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

Are you presenting Pulley? Or using it as a root view controller of a window? Or?

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

Were you trying to set it in viewWillAppear / viewDidAppear / viewDidLoad? If so, I would definitely expect some odd visual glitches with animation enabled.

If you’re setting it in one of those locations, consider using the starting drawer position property.

from pulley.

cyrilzakka avatar cyrilzakka commented on May 14, 2024

Yup you're definitely right - will try that instead and report back

from pulley.

cyrilzakka avatar cyrilzakka commented on May 14, 2024

How exactly is it supposed to be used? Doesn't seem to be doing anything at all

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

It has to be set before the view is loaded. Setting it after the view has loaded has no effect. If you’re setting it within your drawer or main content VC, it’s too late as the view has already loaded.

If you’re using Interface Builder, use the initial drawer state option exposed in Interface Builder so it is set before the view loads. It accepts a string of the appropriate enum (see Pulley VC for info on that variable). The regular non-Interface Builder variable is to be used when instantiating Pulley programmatically, and should be set before doing something that causes the view to load.

from pulley.

cyrilzakka avatar cyrilzakka commented on May 14, 2024

It worked but the jump is still there

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

Is that the “animate from corner” issue you were having? Or something else? I’m not sure what you mean by a “jump”?

from pulley.

cyrilzakka avatar cyrilzakka commented on May 14, 2024

Yup still the animation from corner issue, my bad. You really don't have to worry about it for now - my temporary solution seems to have worked with no repercussions. Thank you for your time btw

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

Ok- glad it worked for you. A lot of people seem to be interested in presenting Pulley as a VC (instead of as a root view controller), and it’s never really been tested / debugged for that use case. I’ll add that to my list of things to work on, so hopefully some of these issues can be prevented. Thanks for your patience! Glad you found a workaround.

from pulley.

azurechen avatar azurechen commented on May 14, 2024

I have a totally same issue. But my PulleyController is the destination of a segue. the whole view will jump at enter this PulleyController.

and I fixed this problem with the same solution.

public func setDrawerPosition(position: PulleyPosition)
{
    setDrawerPosition(position: position, animated: false)
}

Maybe next version can solve this problem? Or just open setDrawerPosition for overriding should be great too.

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

@PomepuyN @azurechen Thanks for the info. I just pushed a proposed solution to master. Can you guys try the current 'master' branch (download or point your Podfile to it) and see if that works for you?

NOTE: The change is that I added an optional parameter to setDrawerPosition that allows you to specify whether or not to animate the change.

You can convert your current call to setDrawerPosition from this:

 pulley.setDrawerPosition(position: .collapsed)

to:

 pulley.setDrawerPosition(position: .collapsed, isAnimated: false)

I think it's more appropriate to yield the animation option to the app as an option, rather than add work-arounds for situations where people may not want it animated.

Let me know if it works for you. If it does, I'll push it out over CocoaPods.

from pulley.

azhang66 avatar azhang66 commented on May 14, 2024

Unfortunately, this bug is still present, even in the demo app. The effect in the demo app is somewhat obscured by the iOS app loading animation, but you can clearly see that Pulley animates the drawer jumping from the top left of the screen.

Looking at the PullyViewController.swift, it looks like setDrawerPosition() is called, with animated: false. However, it's evident that the animation occurs anyway. My suspicion is that the "jumping" animation that we're seeing from the top left corner is not the animation caused by setDrawerPosition().

@Brendan09 thoughts?

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

I’ll take a closer look and see what I can find.

I won’t be marking setDrawerPosition as open, however, as it would require making far too many internal variables and functions public in order for people to write their own implementation of the function.

from pulley.

azhang66 avatar azhang66 commented on May 14, 2024

That's fine (I probably couldn't figure out how to reimplement it anyways). I think the main issue here is getting rid of the corner jumps (which shouldn't be there even by default).

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

Ok, everyone. I think I have a fix for this. Sorry about the delay / misunderstanding the issue.

@azhang66 If you're still near some code, do you mind giving the current code on Master a try? The fix worked for the sample project. I'm about to test it on the sample from @PomepuyN to see it it fixes that use case as well.

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

Okay, the fix seems to work for the sample project from @PomepuyN as well.

I'm going to go ahead and push this out over CocoaPods after a few more minutes of testing.

from pulley.

cyrilzakka avatar cyrilzakka commented on May 14, 2024

@Brendan09 thanks for your work mate!

from pulley.

amyleecodes avatar amyleecodes commented on May 14, 2024

Fantastic! I'm going to go ahead and close this issue then. Thanks for the help in tracking this one down, everyone!

from pulley.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.