forked from amirdew/CollectionViewPagingLayout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransformableView.swift
More file actions
35 lines (28 loc) · 1 KB
/
TransformableView.swift
File metadata and controls
35 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// TransformableView.swift
// CollectionViewPagingLayout
//
// Created by Amir Khorsandi on 12/26/19.
// Copyright © 2019 Amir Khorsandi. All rights reserved.
//
import Foundation
import UIKit
public protocol TransformableView {
/// Sends a float value based on the position of the view (cell)
/// if the view is in the center of CollectionView it sends 0
///
/// - Parameter progress: the interpolated progress for the cell view
func transform(progress: CGFloat)
/// Optional function for providing the Z index(position) of the cell view
/// As defined as an extension the default value of zIndex is Int(-abs(round(progress)))
///
/// - Parameter progress: the interpolated progress for the cell view
/// - Returns: the z index(position)
func zPosition(progress: CGFloat) -> Int
}
public extension TransformableView {
/// Defining the default value of zIndex
func zPosition(progress: CGFloat) -> Int {
Int(-abs(round(progress)))
}
}