Skip to content

Commit

Permalink
Merge pull request #3 from shakurocom/II-16-add_accessibility
Browse files Browse the repository at this point in the history
Ii 16 add accessibility
  • Loading branch information
EugenDevIOS authored Jan 23, 2023
2 parents c3641c5 + 80b284d commit 3cb3061
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Shakuro.InfinityScrollView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Shakuro.InfinityScrollView'
s.version = '1.0.2'
s.version = '1.0.3'
s.summary = 'Shakuro Infinity Scroll View'
s.homepage = 'https://github.com/shakurocom/InfinityScrollView'
s.license = { :type => "MIT", :file => "LICENSE.md" }
Expand Down
28 changes: 28 additions & 0 deletions Source/InfinityScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,34 @@ public class InfinityScrollView: UIView {

// MARK: - Public

public func viewForItem(at index: Int) -> UIView? {
return visibleTileViews[index]
}

public func accessibilityScrollForward() {
guard visibleTileViews.count > 1,
let currentIndex = indexOfItemAtVisibleCenter()
else {
return
}
let nextIndex = currentIndex + 1 == visibleTileViews.count ? 0 : currentIndex + 1
if let frame = visibleTileViews[nextIndex]?.frame {
internalScrollView.setContentOffset(CGPoint(x: frame.midX - (internalScrollView.frame.width / 2), y: 0), animated: true)
}
}

public func accessibilityScrollBackward() {
guard visibleTileViews.count > 1,
let currentIndex = indexOfItemAtVisibleCenter()
else {
return
}
let previousIndex = currentIndex - 1 == -1 ? visibleTileViews.count - 1 : currentIndex - 1
if let frame = visibleTileViews[previousIndex]?.frame {
internalScrollView.setContentOffset(CGPoint(x: frame.midX - (internalScrollView.frame.width / 2), y: 0), animated: true)
}
}

public func reloadData() {
recreateCacheFromDataSource()
updateScroll()
Expand Down

0 comments on commit 3cb3061

Please sign in to comment.