Juanpe / SkeletonView

☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

crossDissolve animation not working

xygkevin opened this issue · comments

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

SkeletonView Environment:

**SkeletonView version:1.30.2
**Xcode version:13.4.1
**Swift version:swift5

Steps to reproduce:

Please replace this with the steps to reproduce the behavior.

view.showSkeleton(transition: .crossDissolve(0.25))
view.hideSkeleton(transition: .crossDissolve(0.25))

All show or hide cross dissolve animation are not working, the same problem with the demo project

both

Expected result:

Please replace this with what you expected to happen.

Actual result:

Please replace this with of what happened instead.

Attachments:

Logs, screenshots, sample project, funny gif, etc.

Confirm, it doesn't work even in the demo project

same on my end

@ardavydov and @xygkevin Here is the fix for hiding:
in CALayer extension find next function:
func setOpacity(from: Int, to: Int, duration: TimeInterval, completion: (() -> Void)?)
and change it code on the next:

DispatchQueue.main.async { [weak self] in
    guard let strongSelf = self else { return }
    CATransaction.begin ()
    let animation = CABasicAnimation (keyPath: #keyPath (CALayer.opacity))
    animation.fromValue = from
    animation.toValue = to
    animation.duration = duration
    animation.timingFunction = CAMediaTimingFunction (name:
    CAMediaTimingFunctionName.easeInEaseOut)
    animation.fillMode = .forwards
    animation.isRemovedOnCompletion = false
    CATransaction.setCompletionBlock(completion)
    strongSelf.add(animation, forKey: "setOpacityAnimation")
    CATransaction.commit ()
}