antoniocasero / Panels

Panels is a framework to easily add sliding panels to your application
MIT License
1.5k stars 89 forks source link

2nd time dismiss animation works but panel stay #14

Closed deshan closed 5 years ago

deshan commented 5 years ago

Panel

  1. Show
  2. Dismiss
  3. Show
  4. Dismiss (Here after dismiss animation, panel stay remain on visible position )

Any help?

Below is my code, took latest from pods (2.0.3)

            if self.currentPanel != nil {
                panelManager?.dismiss()
                self.currentPanel = nil
            } else {
                currentPanel = UIStoryboard.instantiatePanel(identifier: "PanelOptions")
                var panelConfiguration = PanelConfiguration(size: .custom(200))
                panelConfiguration.panelVisibleArea = 30

                panelManager?.show(panel: currentPanel as! UIViewController & Panelable, config: panelConfiguration)
            }
antoniocasero commented 5 years ago

Hi @deshan, I'm going to need more information:

deshan commented 5 years ago

Sorry for the late reply.

  1. Yes I am creating a new panel. but dismiss animation shows, but prev panel stays
  2. Yes after button press
  3. deinit not get called. Memory grows.

Thank you and again many apologies!

deshan commented 5 years ago

I think found the issue.

This would be needed.

self.panel?.removeFromParentViewController()
self.panel?.view.removeFromSuperview()

Ofc it's been called in self.panel?.removeContainer() But the second time it doesn't get called the reason is self.panel is nil

self.panel = nil moving inside the closure may fix the issue? haven't tried. I manually called them inside my code.

UIView.animate(withDuration: configuration.dismissAnimationDuration, animations: {
            panelView.frame.origin = CGPoint(x: 0, y: self.containerView!.frame.size.height)
        }) { _ in
            self.panel?.removeContainer()
            completion?()
            self.panel = nil // moving here may fix the issue
        }
antoniocasero commented 5 years ago

@deshan I have a question you said

Yes I am creating a new panel. but dismiss animation shows, but prev panel stays

how many panels are you presenting? If you create more than one, then you wouldn't have control over it and it will stay on the screen. You should dismiss the first panel before present the new one.