Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a64002ef72 | |||
| d3d5136f3d | |||
| 8691a862bc | |||
| e4378462e2 | |||
| a8b2962c9b | |||
| 31f9b56b3a | |||
| 51473be4c7 | |||
| ee26e28d39 | |||
| f6b339ad96 | |||
| cc916ccd92 | |||
| ae1969e26f | |||
| 42e8d150a2 | |||
| b839a5af47 | |||
| a522cf0c36 | |||
| 294fd763f8 | |||
| 9468de35bd |
@@ -33,3 +33,4 @@ Carthage
|
||||
# Pods/
|
||||
/Example/InfiniteLayout.xcworkspace
|
||||
/Example/Pods
|
||||
/Example/InfiniteLayout.xcodeproj/project.xcworkspace/xcshareddata
|
||||
|
||||
@@ -226,7 +226,6 @@
|
||||
607FACCD1AFB9204008FA782 /* Frameworks */,
|
||||
607FACCE1AFB9204008FA782 /* Resources */,
|
||||
36EEEA4F62F7A41DC7E00F9B /* [CP] Embed Pods Frameworks */,
|
||||
BF7EA699B063C96A45D69BF2 /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -245,8 +244,6 @@
|
||||
607FACE11AFB9204008FA782 /* Sources */,
|
||||
607FACE21AFB9204008FA782 /* Frameworks */,
|
||||
607FACE31AFB9204008FA782 /* Resources */,
|
||||
066936A649BBA50B7D22FE7E /* [CP] Embed Pods Frameworks */,
|
||||
56B85F2D241E5ED6DDCED73C /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -321,21 +318,6 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
066936A649BBA50B7D22FE7E /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InfiniteLayout_Tests/Pods-InfiniteLayout_Tests-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
36EEEA4F62F7A41DC7E00F9B /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -364,21 +346,6 @@
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InfiniteLayout_Example/Pods-InfiniteLayout_Example-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
56B85F2D241E5ED6DDCED73C /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InfiniteLayout_Tests/Pods-InfiniteLayout_Tests-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
BB5E5FB53E7C451064DBC9A2 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -397,21 +364,6 @@
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
BF7EA699B063C96A45D69BF2 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InfiniteLayout_Example/Pods-InfiniteLayout_Example-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
DF297DCD753BC67E73166377 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -597,6 +549,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -613,6 +566,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<scene sceneID="l4I-9G-XdF">
|
||||
<objects>
|
||||
<navigationController id="yGQ-hH-2v6" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="IdE-R7-9TG">
|
||||
<rect key="frame" x="0.0" y="20" width="320" height="44"/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" largeTitles="YES" id="IdE-R7-9TG">
|
||||
<rect key="frame" x="0.0" y="20" width="320" height="96"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
@@ -98,14 +98,18 @@
|
||||
<segue destination="ctO-Ld-yhL" kind="show" id="qss-AL-dgi"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</cells>
|
||||
</tableViewSection>
|
||||
<tableViewSection headerTitle="Delegate" id="lpd-Xl-djA">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="c9c-gc-NDL" style="IBUITableViewCellStyleDefault" id="7Dq-og-5lN">
|
||||
<rect key="frame" x="0.0" y="132" width="320" height="44"/>
|
||||
<rect key="frame" x="0.0" y="160" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="7Dq-og-5lN" id="XGb-gg-zbn">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Picker" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="c9c-gc-NDL">
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Horizontal Picker" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="c9c-gc-NDL">
|
||||
<rect key="frame" x="16" y="0.0" width="288" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
@@ -123,7 +127,7 @@
|
||||
<tableViewSection headerTitle="Rx" id="l6q-RG-uyY">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" textLabel="i8W-08-UPB" style="IBUITableViewCellStyleDefault" id="1E8-fo-BBx">
|
||||
<rect key="frame" x="0.0" y="204" width="320" height="44"/>
|
||||
<rect key="frame" x="0.0" y="232" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="1E8-fo-BBx" id="NMq-kd-IrV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
|
||||
@@ -203,6 +207,9 @@
|
||||
</cells>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="isItemPagingEnabled" value="YES"/>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="velocityMultiplier">
|
||||
<real key="value" value="500"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="ctO-Ld-yhL" id="bXu-Jz-K7t"/>
|
||||
@@ -218,14 +225,14 @@
|
||||
<constraint firstItem="enX-ef-ELn" firstAttribute="leading" secondItem="C5p-bu-Djh" secondAttribute="leading" id="uX4-ox-gnL"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Custom Layout" id="hZl-1w-5Nq"/>
|
||||
<navigationItem key="navigationItem" title="Custom Layout" largeTitleDisplayMode="never" id="hZl-1w-5Nq"/>
|
||||
<connections>
|
||||
<outlet property="infiniteCollectionView" destination="enX-ef-ELn" id="jKo-DT-4uH"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="4s9-AY-FII" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-770" y="802"/>
|
||||
<point key="canvasLocation" x="21" y="788"/>
|
||||
</scene>
|
||||
<!--Infinite Delegate-->
|
||||
<scene sceneID="HqS-9O-oG4">
|
||||
@@ -313,7 +320,7 @@
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="jlK-LR-KNy" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="22" y="802"/>
|
||||
<point key="canvasLocation" x="784" y="-664"/>
|
||||
</scene>
|
||||
<!--Rx-->
|
||||
<scene sceneID="w7X-Gq-cbX">
|
||||
@@ -371,14 +378,14 @@
|
||||
<constraint firstAttribute="bottom" secondItem="ci9-0n-fka" secondAttribute="bottom" id="yOo-Td-V0c"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Rx" id="BMY-0d-YCj"/>
|
||||
<navigationItem key="navigationItem" title="Rx" largeTitleDisplayMode="never" id="BMY-0d-YCj"/>
|
||||
<connections>
|
||||
<outlet property="infiniteCollectionView" destination="ci9-0n-fka" id="fSY-Qh-bhA"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="TkU-4C-L7I" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-770" y="-671"/>
|
||||
<point key="canvasLocation" x="784" y="60"/>
|
||||
</scene>
|
||||
<!--Horizontal Layout-->
|
||||
<scene sceneID="0Xz-LA-moA">
|
||||
@@ -396,7 +403,7 @@
|
||||
</collectionViewFlowLayout>
|
||||
<cells>
|
||||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cell" id="BVQ-cb-bj4" customClass="Cell" customModule="InfiniteLayout_Example" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="177" width="250" height="150"/>
|
||||
<rect key="frame" x="0.0" y="151" width="250" height="150"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
|
||||
<rect key="frame" x="0.0" y="0.0" width="250" height="150"/>
|
||||
@@ -421,9 +428,6 @@
|
||||
</cells>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="isItemPagingEnabled" value="YES"/>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="velocityMultiplier">
|
||||
<real key="value" value="1"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="CU7-Hg-6kG" id="BOZ-dL-WLG"/>
|
||||
@@ -434,7 +438,7 @@
|
||||
</collectionViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Dsp-JP-Q6i" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="21" y="-670"/>
|
||||
<point key="canvasLocation" x="21" y="-664"/>
|
||||
</scene>
|
||||
<!--Vertical Layout-->
|
||||
<scene sceneID="ccn-9j-1sQ">
|
||||
@@ -483,7 +487,7 @@
|
||||
<outlet property="delegate" destination="9P2-Ud-D2M" id="ns0-fe-DSq"/>
|
||||
</connections>
|
||||
</collectionView>
|
||||
<navigationItem key="navigationItem" title="Vertical Layout" id="2E2-oh-ELb"/>
|
||||
<navigationItem key="navigationItem" title="Vertical Layout" largeTitleDisplayMode="never" id="2E2-oh-ELb"/>
|
||||
</collectionViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Lvb-qy-gZV" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
|
||||
@@ -22,4 +22,8 @@ class BaseCollectionViewController: InfiniteCollectionViewController {
|
||||
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return 20
|
||||
}
|
||||
|
||||
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
collectionView.scrollToItem(at: indexPath, at: self.infiniteCollectionView!.infiniteLayout.scrollDirection == .vertical ? .centeredVertically : .centeredHorizontally, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,7 @@ class CustomViewController: UIViewController {
|
||||
extension CustomViewController: UICollectionViewDataSource {
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return 14
|
||||
}
|
||||
|
||||
func numberOfSections(in collectionView: UICollectionView) -> Int {
|
||||
return 2
|
||||
return 20
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
@@ -31,6 +27,13 @@ extension CustomViewController: UICollectionViewDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
extension CustomViewController: UICollectionViewDelegate {
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
collectionView.scrollToItem(at: indexPath, at: .centeredVertically, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
extension CustomViewController: UICollectionViewDelegateFlowLayout {
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
||||
|
||||
@@ -30,6 +30,13 @@ extension PickerController: UICollectionViewDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
extension PickerController: UICollectionViewDelegate {
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
extension PickerController: InfiniteCollectionViewDelegate {
|
||||
|
||||
func infiniteCollectionView(_ infiniteCollectionView: InfiniteCollectionView, didChangeCenteredIndexPath centeredIndexPath: IndexPath?) {
|
||||
|
||||
@@ -35,5 +35,11 @@ class RxBaseCollectionViewController: UIViewController {
|
||||
}
|
||||
print("centered: \(current + 1)")
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
infiniteCollectionView.rx.itemSelected
|
||||
.asDriver()
|
||||
.drive(onNext: { [unowned self] indexPath in
|
||||
self.infiniteCollectionView.scrollToItem(at: indexPath, at: .centeredVertically, animated: true)
|
||||
}).disposed(by: disposeBag)
|
||||
}
|
||||
}
|
||||
|
||||
+22
-13
@@ -1,16 +1,17 @@
|
||||
PODS:
|
||||
- CocoaProxy (0.1.1)
|
||||
- Differentiator (3.0.2)
|
||||
- InfiniteLayout (0.1.6):
|
||||
- CocoaProxy (~> 0.1)
|
||||
- InfiniteLayout/Core (= 0.1.6)
|
||||
- InfiniteLayout/Core (0.1.6):
|
||||
- CocoaProxy (~> 0.1)
|
||||
- InfiniteLayout/Rx (0.1.6):
|
||||
- CocoaProxy (~> 0.1)
|
||||
- RxCocoa (~> 4.0)
|
||||
- RxDataSources (~> 3.0)
|
||||
- RxSwift (~> 4.0)
|
||||
- InfiniteLayout (0.2.3.1):
|
||||
- CocoaProxy (~> 0)
|
||||
- InfiniteLayout/Core (= 0.2.3.1)
|
||||
- InfiniteLayout/Core (0.2.3.1):
|
||||
- CocoaProxy (~> 0)
|
||||
- InfiniteLayout/Rx (0.2.3.1):
|
||||
- CocoaProxy (~> 0)
|
||||
- InfiniteLayout/Core (~> 0)
|
||||
- RxCocoa (~> 4)
|
||||
- RxDataSources (~> 3)
|
||||
- RxSwift (~> 4)
|
||||
- RxCocoa (4.1.0):
|
||||
- RxSwift (~> 4.0)
|
||||
- RxDataSources (3.0.2):
|
||||
@@ -23,18 +24,26 @@ DEPENDENCIES:
|
||||
- InfiniteLayout (from `../`)
|
||||
- InfiniteLayout/Rx (from `../`)
|
||||
|
||||
SPEC REPOS:
|
||||
https://github.com/cocoapods/specs.git:
|
||||
- CocoaProxy
|
||||
- Differentiator
|
||||
- RxCocoa
|
||||
- RxDataSources
|
||||
- RxSwift
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
InfiniteLayout:
|
||||
:path: ../
|
||||
:path: "../"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
CocoaProxy: 35ab81e24325b33834cffe45a3d1fd48ca67ef3a
|
||||
Differentiator: a87be69eba49ec4ab460c7671143ee3a9eececfd
|
||||
InfiniteLayout: 27a10e0a766122807a73740b5e7c7384fcdc37a2
|
||||
InfiniteLayout: 17bbab705aa4d941fa82a7e9b658c96d13ce91a3
|
||||
RxCocoa: cc1fec49cdc8fabe645964de7c51c099a36c2aa8
|
||||
RxDataSources: cb7c31e652a87ebb919da45f716bbb87b3765f6b
|
||||
RxSwift: 4219941c1244c88002901bd87a69d3aea9ae71f0
|
||||
|
||||
PODFILE CHECKSUM: 3501aeed91e62112dd38178a52f26b204b97c8c0
|
||||
|
||||
COCOAPODS: 1.4.0.rc.1
|
||||
COCOAPODS: 1.5.3
|
||||
|
||||
+10
-10
@@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'InfiniteLayout'
|
||||
s.version = '0.2.0.3'
|
||||
s.version = '0.2.3.2'
|
||||
s.summary = 'Horizontal and Vertical infinite scrolling feature for UICollectionView with Paging, NSProxy delegate, Reactive extension'
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
@@ -21,11 +21,11 @@ Pod::Spec.new do |s|
|
||||
Horizontal and Vertical infinite scrolling feature for UICollectionView with Paging, NSProxy delegate, Reactive extension, SectionModel & AnimatableSectionModel support
|
||||
DESC
|
||||
|
||||
s.homepage = 'https://github.com/Arnoymous/InfiniteLayout'
|
||||
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
|
||||
s.homepage = 'https://github.com/arnauddorgans/InfiniteLayout'
|
||||
s.screenshots = 'https://github.com/arnauddorgans/InfiniteLayout/raw/master/horizontal.gif', 'https://github.com/arnauddorgans/InfiniteLayout/raw/master/vertical.gif', 'https://github.com/arnauddorgans/InfiniteLayout/raw/master/custom.gif', 'https://github.com/arnauddorgans/InfiniteLayout/raw/master/delegate.gif'
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.author = { 'Arnoymous' => 'ineox@me.com' }
|
||||
s.source = { :git => 'https://github.com/Arnoymous/InfiniteLayout.git', :tag => s.version.to_s }
|
||||
s.author = { 'Arnaud Dorgans' => 'ineox@me.com' }
|
||||
s.source = { :git => 'https://github.com/arnauddorgans/InfiniteLayout.git', :tag => s.version.to_s }
|
||||
s.social_media_url = 'https://twitter.com/arnauddorgans'
|
||||
|
||||
s.ios.deployment_target = '8.0'
|
||||
@@ -39,7 +39,7 @@ Horizontal and Vertical infinite scrolling feature for UICollectionView with Pag
|
||||
|
||||
# s.public_header_files = 'Pod/Classes/**/*.h'
|
||||
# s.frameworks = 'UIKit', 'MapKit'
|
||||
s.dependency 'CocoaProxy', '~> 0.1'
|
||||
s.dependency 'CocoaProxy', '~> 0'
|
||||
|
||||
s.default_subspec = 'Core'
|
||||
|
||||
@@ -48,10 +48,10 @@ Horizontal and Vertical infinite scrolling feature for UICollectionView with Pag
|
||||
end
|
||||
|
||||
s.subspec 'Rx' do |rx|
|
||||
rx.dependency 'InfiniteLayout/Core', '~> 0.2'
|
||||
rx.dependency 'RxSwift', '~> 4.0'
|
||||
rx.dependency 'RxCocoa', '~> 4.0'
|
||||
rx.dependency 'RxDataSources', '~> 3.0'
|
||||
rx.dependency 'InfiniteLayout/Core', '~> 0'
|
||||
rx.dependency 'RxSwift', '~> 4'
|
||||
rx.dependency 'RxCocoa', '~> 4'
|
||||
rx.dependency 'RxDataSources', '~> 3'
|
||||
rx.source_files = 'InfiniteLayout/Rx/**/*'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ open class InfiniteCollectionView: UICollectionView {
|
||||
lazy var dataSourceProxy = InfiniteCollectionViewDataSourceProxy(collectionView: self)
|
||||
lazy var delegateProxy = InfiniteCollectionViewDelegateProxy(collectionView: self)
|
||||
|
||||
@IBOutlet open var infiniteDelegate: InfiniteCollectionViewDelegate?
|
||||
@IBOutlet open weak var infiniteDelegate: InfiniteCollectionViewDelegate?
|
||||
|
||||
open private(set) var centeredIndexPath: IndexPath?
|
||||
open var preferredCenteredIndexPath: IndexPath? = IndexPath(item: 0, section: 0)
|
||||
@@ -25,7 +25,7 @@ open class InfiniteCollectionView: UICollectionView {
|
||||
var forwardDelegate: Bool { return true }
|
||||
var _contentSize: CGSize?
|
||||
|
||||
override open var delegate: UICollectionViewDelegate? {
|
||||
override open weak var delegate: UICollectionViewDelegate? {
|
||||
get { return super.delegate }
|
||||
set {
|
||||
guard forwardDelegate else {
|
||||
@@ -45,7 +45,7 @@ open class InfiniteCollectionView: UICollectionView {
|
||||
}
|
||||
}
|
||||
|
||||
override open var dataSource: UICollectionViewDataSource? {
|
||||
override open weak var dataSource: UICollectionViewDataSource? {
|
||||
get { return super.dataSource }
|
||||
set {
|
||||
guard forwardDelegate else {
|
||||
@@ -112,8 +112,7 @@ open class InfiniteCollectionView: UICollectionView {
|
||||
|
||||
open override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
self.loopCollectionViewIfNeeded()
|
||||
self.updateLayoutIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,15 +164,9 @@ extension InfiniteCollectionView: UICollectionViewDataSource {
|
||||
|
||||
extension InfiniteCollectionView: UICollectionViewDelegate {
|
||||
|
||||
// MARK: Loop
|
||||
func loopCollectionViewIfNeeded() {
|
||||
self.infiniteLayout.loopCollectionViewIfNeeded()
|
||||
self.centerCollectionViewIfNeeded()
|
||||
}
|
||||
|
||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
delegateProxy.delegate?.scrollViewDidScroll?(scrollView)
|
||||
func updateLayoutIfNeeded() {
|
||||
self.loopCollectionViewIfNeeded()
|
||||
self.centerCollectionViewIfNeeded()
|
||||
|
||||
let preferredVisibleIndexPath = infiniteLayout.preferredVisibleLayoutAttributes()?.indexPath
|
||||
if self.centeredIndexPath != preferredVisibleIndexPath {
|
||||
@@ -182,6 +175,16 @@ extension InfiniteCollectionView: UICollectionViewDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Loop
|
||||
func loopCollectionViewIfNeeded() {
|
||||
self.infiniteLayout.loopCollectionViewIfNeeded()
|
||||
}
|
||||
|
||||
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
delegateProxy.delegate?.scrollViewDidScroll?(scrollView)
|
||||
self.updateLayoutIfNeeded()
|
||||
}
|
||||
|
||||
// MARK: Paging
|
||||
func centerCollectionViewIfNeeded() {
|
||||
guard isItemPagingEnabled,
|
||||
|
||||
@@ -45,6 +45,10 @@ class InfiniteCollectionViewProxy<T: NSObjectProtocol>: CocoaProxy {
|
||||
super.init(proxies: [])
|
||||
self.collectionView = collectionView
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.proxies.removeAll()
|
||||
}
|
||||
}
|
||||
|
||||
class InfiniteCollectionViewDelegateProxy: InfiniteCollectionViewProxy<UICollectionViewDelegate>, UICollectionViewDelegate {
|
||||
|
||||
@@ -11,7 +11,7 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
|
||||
public var velocityMultiplier: CGFloat = 1 // used to simulate paging
|
||||
|
||||
private let multiplier: CGFloat = 100 // contentOffset multiplier
|
||||
private let multiplier: CGFloat = 500 // contentOffset multiplier
|
||||
|
||||
private var contentSize: CGSize = .zero
|
||||
|
||||
@@ -131,6 +131,13 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
}
|
||||
|
||||
// MARK: Loop
|
||||
private func updateContentOffset(_ offset: CGPoint) {
|
||||
guard let collectionView = self.collectionView else {
|
||||
return
|
||||
}
|
||||
collectionView.contentOffset = offset
|
||||
collectionView.layoutIfNeeded()
|
||||
}
|
||||
private func preferredContentOffset(forContentOffset contentOffset: CGPoint) -> CGPoint {
|
||||
return rect(from: CGRect(origin: contentOffset, size: .zero), page: self.page(from: .zero, offset: multiplier / 2)).origin
|
||||
}
|
||||
@@ -142,7 +149,7 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
let page = self.pageIndex(from: self.page(for: collectionView.contentOffset))
|
||||
let offset = self.preferredContentOffset(forContentOffset: collectionView.contentOffset)
|
||||
if (page < 2 || page > self.multiplier - 2) && collectionView.contentOffset != offset {
|
||||
collectionView.contentOffset = offset
|
||||
self.updateContentOffset(offset)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,11 +251,11 @@ open class InfiniteLayout: UICollectionViewFlowLayout {
|
||||
return
|
||||
}
|
||||
guard let preferredAttributes = self.preferredVisibleLayoutAttributes(indexPath: indexPath),
|
||||
let offset = self.centeredContentOffset(forRect: preferredAttributes.frame),
|
||||
let offset = self.centeredContentOffset(forRect: preferredAttributes.frame),
|
||||
collectionView.contentOffset != offset else {
|
||||
return
|
||||
}
|
||||
collectionView.contentOffset = offset
|
||||
self.updateContentOffset(offset)
|
||||
}
|
||||
|
||||
// MARK: Copy
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
# InfiniteLayout
|
||||
|
||||
[](https://travis-ci.org/Arnoymous/InfiniteLayout)
|
||||
[](https://travis-ci.org/arnauddorgans/InfiniteLayout)
|
||||
[](http://cocoapods.org/pods/InfiniteLayout)
|
||||
[](http://cocoapods.org/pods/InfiniteLayout)
|
||||
[](http://cocoapods.org/pods/InfiniteLayout)
|
||||
|
||||
<img src="https://github.com/arnauddorgans/InfiniteLayout/raw/master/horizontal.gif" width="250" height="540"><img src="https://github.com/arnauddorgans/InfiniteLayout/raw/master/vertical.gif" width="250" height="540"><img src="https://github.com/arnauddorgans/InfiniteLayout/raw/master/custom.gif" width="250" height="540">
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
To run the example project, clone the repo, and run `pod install` from the Example directory first.
|
||||
@@ -75,7 +78,9 @@ self.infiniteCollectionView.preferredCenteredIndexPath = [0, 0] // center the ce
|
||||
self.infiniteCollectionView.preferredCenteredIndexPath = nil // center the closest cell from center
|
||||
```
|
||||
|
||||
### Centered IndexPath
|
||||
### Delegate
|
||||
|
||||
<img src="https://github.com/arnauddorgans/InfiniteLayout/raw/master/delegate.gif" width="250" height="540">
|
||||
|
||||
InfiniteCollectionView provide an **infiniteDelegate** protocol used to get the centered IndexPath, usefull if you want to use an InfiniteCollectionView like a Picker.
|
||||
|
||||
@@ -146,20 +151,20 @@ RxInfiniteCollectionView provide Reactive extension for **itemCentered** & **mod
|
||||
```swift
|
||||
infiniteCollectionView.rx.itemCentered
|
||||
.asDriver()
|
||||
.drive(onNext: { indexPath in
|
||||
.drive(onNext: { [unowned self] indexPath in
|
||||
self.selectedView.update(index: indexPath.row) // update interface with indexPath
|
||||
}).disposed(by: disposeBag)
|
||||
|
||||
infiniteCollectionView.rx.modelCentered(Int.self)
|
||||
.asDriver()
|
||||
.drive(onNext: { element in
|
||||
.drive(onNext: { [unowned self] element in
|
||||
self.selectedView.update(index: element) // update interface with model
|
||||
}).disposed(by: disposeBag)
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
Arnoymous, arnaud.dorgans@gmail.com
|
||||
Arnaud Dorgans, arnaud.dorgans@gmail.com
|
||||
|
||||
## License
|
||||
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 2.6 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 572 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 688 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
Reference in New Issue
Block a user