Merge pull request #2 from thr1llseek3r/fix_scrollToItem_forces_crash

Fix scroll to item forces crash
This commit is contained in:
Sergey 2021-12-20 20:23:26 +03:00 committed by GitHub
commit 00dd915191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 35 deletions

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -1,34 +1,15 @@
//
// Package.swift
// FSPagerView
//
// Created by Wenchao Ding on 22/02/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "FSPagerView",
dependencies : [],
exclude: []
platforms: [
.iOS(.v9)
],
products: [
.library(name: "FSPagerView", targets: ["FSPagerView"]),
],
targets: [
.target(name: "FSPagerView", path: "Sources", exclude: ["FSPagerViewObjcCompat.h", "FSPagerViewObjcCompat.m"]),
]
)

View File

@ -1,6 +1,6 @@
![fspagerview](https://cloud.githubusercontent.com/assets/5186464/24086370/45e7e8dc-0d49-11e7-86aa-139354fe00c5.jpg)
[![Languages](https://img.shields.io/badge/language-swift%204.2%20|%20objc-FF69B4.svg?style=plastic)](#) <br/>
[![Languages](https://img.shields.io/badge/language-swift%205.0%20|%20objc-FF69B4.svg?style=plastic)](#) <br/>
[![Platform](https://img.shields.io/badge/platform-iOS%20|%20tvOS-blue.svg?style=plastic)](http://cocoadocs.org/docsets/FSPagerView)
[![Version](https://img.shields.io/cocoapods/v/FSPagerView.svg?style=plastic)](http://cocoadocs.org/docsets/FSPagerView)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=plastic)](https://github.com/Carthage/Carthage)
@ -85,7 +85,7 @@ pagerView.interitemSpacing = 10
| ![1](https://cloud.githubusercontent.com/assets/5186464/22686429/1983b97e-ed5f-11e6-9a32-44c1830df7ac.gif) |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .crossfading)
pagerView.transformer = FSPagerViewTransformer(type: .crossFading)
```
---
@ -96,7 +96,7 @@ pagerView.transformer = FSPagerViewTransformer(type: .crossfading)
| ![2](https://cloud.githubusercontent.com/assets/5186464/22686426/19830862-ed5f-11e6-90be-8fb1319cd125.gif) |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .zoomout)
pagerView.transformer = FSPagerViewTransformer(type: .zoomOut)
```
---
@ -417,4 +417,4 @@ func pagerViewDidEndDecelerating(_ pagerView: FSPagerView)
---
# [Documentation](http://cocoadocs.org/docsets/FSPagerView)
# [Documentation](http://cocoadocs.org/docsets/FSPagerView)

View File

@ -26,8 +26,8 @@ open class FSPagerViewTransformer: NSObject {
open internal(set) weak var pagerView: FSPagerView?
open internal(set) var type: FSPagerViewTransformerType
open var minimumScale: CGFloat = 0.65
open var minimumAlpha: CGFloat = 0.6
@objc open var minimumScale: CGFloat = 0.65
@objc open var minimumAlpha: CGFloat = 0.6
@objc
public init(type: FSPagerViewTransformerType) {

View File

@ -512,7 +512,7 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
@objc(scrollToItemAtIndex:animated:)
open func scrollToItem(at index: Int, animated: Bool) {
guard index < self.numberOfItems else {
fatalError("index \(index) is out of range [0...\(self.numberOfItems-1)]")
return
}
let indexPath = { () -> IndexPath in
if let indexPath = self.possibleTargetingIndexPath, indexPath.item == index {