Skip to content

Commit 3cb3061

Browse files
authored
Merge pull request #3 from shakurocom/II-16-add_accessibility
Ii 16 add accessibility
2 parents c3641c5 + 80b284d commit 3cb3061

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Shakuro.InfinityScrollView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Shakuro.InfinityScrollView'
3-
s.version = '1.0.2'
3+
s.version = '1.0.3'
44
s.summary = 'Shakuro Infinity Scroll View'
55
s.homepage = 'https://github.com/shakurocom/InfinityScrollView'
66
s.license = { :type => "MIT", :file => "LICENSE.md" }

Source/InfinityScrollView.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,34 @@ public class InfinityScrollView: UIView {
209209

210210
// MARK: - Public
211211

212+
public func viewForItem(at index: Int) -> UIView? {
213+
return visibleTileViews[index]
214+
}
215+
216+
public func accessibilityScrollForward() {
217+
guard visibleTileViews.count > 1,
218+
let currentIndex = indexOfItemAtVisibleCenter()
219+
else {
220+
return
221+
}
222+
let nextIndex = currentIndex + 1 == visibleTileViews.count ? 0 : currentIndex + 1
223+
if let frame = visibleTileViews[nextIndex]?.frame {
224+
internalScrollView.setContentOffset(CGPoint(x: frame.midX - (internalScrollView.frame.width / 2), y: 0), animated: true)
225+
}
226+
}
227+
228+
public func accessibilityScrollBackward() {
229+
guard visibleTileViews.count > 1,
230+
let currentIndex = indexOfItemAtVisibleCenter()
231+
else {
232+
return
233+
}
234+
let previousIndex = currentIndex - 1 == -1 ? visibleTileViews.count - 1 : currentIndex - 1
235+
if let frame = visibleTileViews[previousIndex]?.frame {
236+
internalScrollView.setContentOffset(CGPoint(x: frame.midX - (internalScrollView.frame.width / 2), y: 0), animated: true)
237+
}
238+
}
239+
212240
public func reloadData() {
213241
recreateCacheFromDataSource()
214242
updateScroll()

0 commit comments

Comments
 (0)