Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions Source/BTNavigationDropdownMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ import UIKit
// MARK: BTNavigationDropdownMenu
open class BTNavigationDropdownMenu: UIView {

open var bounces: Bool {
get {
return self.configuration.bounces
}
set(value) {
self.configuration.bounces = value
}
}

// The color of menu title. Default is darkGrayColor()
open var menuTitleColor: UIColor! {
get {
Expand Down Expand Up @@ -460,11 +469,21 @@ open class BTNavigationDropdownMenu: UIView {

self.menuWrapper.superview?.bringSubview(toFront: self.menuWrapper)

var animationDuration: Double = self.configuration.animationDuration
var damping: CGFloat = 1.0
var velocity: CGFloat = 1.0

if self.bounces {
animationDuration *= 1.5
damping = 0.7
velocity = 0.5
}

UIView.animate(
withDuration: self.configuration.animationDuration * 1.5,
withDuration: animationDuration,
delay: 0,
usingSpringWithDamping: 0.7,
initialSpringVelocity: 0.5,
usingSpringWithDamping: damping,
initialSpringVelocity: velocity,
options: [],
animations: {
self.tableView.frame.origin.y = CGFloat(-300)
Expand Down
2 changes: 2 additions & 0 deletions Source/Internal/BTConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import UIKit

final class BTConfiguration {
var bounces: Bool!
var menuTitleColor: UIColor?
var cellHeight: CGFloat!
var cellBackgroundColor: UIColor?
Expand Down Expand Up @@ -57,6 +58,7 @@ final class BTConfiguration {
let arrowImagePath = imageBundle?.path(forResource: "arrow_down_icon", ofType: "png")

// Default values
self.bounces = true
self.menuTitleColor = UIColor.darkGray
self.cellHeight = 50
self.cellBackgroundColor = UIColor.white
Expand Down