From 3f3f3d19a392f8e4d2c7d32004e5ae077eab3c19 Mon Sep 17 00:00:00 2001 From: Christoffer Winterkvist Date: Tue, 23 Apr 2019 07:28:46 +0200 Subject: [PATCH] Enable animations on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 💻 Perform updates using `.animator()` to enable animations on macOS --- Differific.podspec | 2 +- Source/macOS/NSCollectionView+Extensions.swift | 10 +++++----- Source/macOS/NSTableView+Extensions.swift | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Differific.podspec b/Differific.podspec index 2529c03..2256570 100644 --- a/Differific.podspec +++ b/Differific.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Differific" s.summary = "A fast and convenient diffing framework" - s.version = "0.6.0" + s.version = "0.7.0" s.homepage = "https://github.com/zenangst/Differific" s.license = 'MIT' s.author = { "Christoffer Winterkvist" => "christoffer@winterkvist.com" } diff --git a/Source/macOS/NSCollectionView+Extensions.swift b/Source/macOS/NSCollectionView+Extensions.swift index 5ae89dc..42e10f9 100644 --- a/Source/macOS/NSCollectionView+Extensions.swift +++ b/Source/macOS/NSCollectionView+Extensions.swift @@ -21,13 +21,13 @@ public extension NSCollectionView { let manager = IndexPathManager() let result = manager.process(changes, section: section) - performBatchUpdates({ + animator().performBatchUpdates({ updateDataSource() - validateUpdates(result.insert, then: insertItems) - validateUpdates(result.updates, then: reloadItems) - validateUpdates(result.deletions, then: deleteItems) + validateUpdates(result.insert, then: animator().insertItems) + validateUpdates(result.updates, then: animator().reloadItems) + validateUpdates(result.deletions, then: animator().deleteItems) if !result.moves.isEmpty { - result.moves.forEach { moveItem(at: $0.from, to: $0.to) } + result.moves.forEach { animator().moveItem(at: $0.from, to: $0.to) } } }, completionHandler: nil) diff --git a/Source/macOS/NSTableView+Extensions.swift b/Source/macOS/NSTableView+Extensions.swift index 01cfdf7..41b8e57 100644 --- a/Source/macOS/NSTableView+Extensions.swift +++ b/Source/macOS/NSTableView+Extensions.swift @@ -26,20 +26,20 @@ public extension NSTableView { let deletions = IndexSet(result.deletions.compactMap { $0.item }) let updates = IndexSet(result.updates.compactMap { $0.item }) - beginUpdates() + animator().beginUpdates() updateDataSource() - validateUpdates(insertions, animation: animation, then: insertRows) - validateUpdates(deletions, animation: animation, then: removeRows) + validateUpdates(insertions, animation: animation, then: animator().insertRows) + validateUpdates(deletions, animation: animation, then: animator().removeRows) if !updates.isEmpty { - reloadData(forRowIndexes: updates, columnIndexes: IndexSet([section])) + animator().reloadData(forRowIndexes: updates, columnIndexes: IndexSet([section])) } if !result.moves.isEmpty { - result.moves.forEach { moveRow(at: $0.from.item, to: $0.to.item) } + result.moves.forEach { animator().moveRow(at: $0.from.item, to: $0.to.item) } } - endUpdates() + animator().endUpdates() completion?() }