Trace the indexpath of selection using gesture's location and loop until the selected indexpath
func makeSelection(on indexPath : IndexPath){
let cell = collectionView(collectionView, cellForItemAt: indexPath) as! GalleryPhotoCell
if selectionMode {
//gesture used for selecting photos
print("On selection")
cell.tapSelection ? nil : collectionView(collectionView, didSelectItemAt: indexPath)
}
else {
//gesture used for unselecting photos
print("On unselection")
cell.tapSelection ? collectionView(collectionView, didSelectItemAt: indexPath) : nil
}
}
func makeSelection(upto count : Int){
guard let start = prevIndex else {return}
if count > 0 {
for item in 0 ..< count {
let index = IndexPath(item: start.item + item + 1, section: start.section)
makeSelection(on: index)
}
}
else {
for item in 0 ..< abs(count){
let index = IndexPath(item: start.item - item - 1, section: start.section)
makeSelection(on: index)
}
}
}