Skip to content

Commit

Permalink
Prevent item selection during closing animation (jjochen#234)
Browse files Browse the repository at this point in the history
* add test for double tap on action item

* prevent items to be tapped during closing animation
  • Loading branch information
jjochen authored Mar 1, 2020
1 parent 283032e commit 68b3464
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Example/Tests/JJFloatingActionButtonSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,23 @@ class JJFloatingActionButtonSpec: QuickSpec {
expect(actionCount).toEventually(equal(1))
}
}

context("and item is tapped twice") {
beforeEach {
let item = actionButton.items[0]
item.sendActions(for: .touchUpInside)
item.sendActions(for: .touchUpInside)
}

it("closes") {
expect(actionButton.buttonState) == .closing
expect(actionButton.buttonState).toEventually(equal(.closed))
}

it("performs action once") {
expect(actionCount).toEventually(equal(1))
}
}
}

context("and is closed animated") {
Expand Down
4 changes: 4 additions & 0 deletions Sources/JJFloatingActionButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ fileprivate extension JJFloatingActionButton {
}

@objc func itemWasTapped(sender: JJActionItem) {
guard buttonState == .open || buttonState == .opening else {
return
}

if closeAutomatically {
close()
}
Expand Down

0 comments on commit 68b3464

Please sign in to comment.