private func buttonsAnimationIsShow(isShow isShow: Bool, duration: Double, hideDelay: Double = 0) {
guard let buttons = self.buttons else {
return
}
let step: Float = 360.0 / Float(self.buttonsCount)
for index in 0..<self.buttonsCount {
guard case let button as CircleMenuButton = buttons[index] else { continue }
let angle: Float = Float(index) * step
if isShow == true {
delegate?.circleMenu?(self, willDisplay: button, atIndex: index)
button.rotatedZ(angle: angle, animated: false, delay: Double(index) * showDelay)
button.showAnimation(distance: distance, duration: duration, delay: Double(index) * showDelay)
} else {
button.hideAnimation(
distance: Float(self.bounds.size.height / 2.0),
duration: duration, delay: hideDelay)
self.delegate?.menuCollapsed?(self)
}
}
if isShow == false { // hide buttons and remove
self.buttons = nil
}
}
when run the demo, function menuCollapsed will execute 5 times which is the number of the buttons. Is this by design?
When close action happen, the function menuCollapsed run once is better.
// self.delegate?.menuCollapsed?(self)
}
}
if isShow == false { // hide buttons and remove
self.delegate?.menuCollapsed?(self)
self.buttons = nil
}