This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
TTScrollView.h
211 lines (168 loc) · 4.01 KB
/
TTScrollView.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#import "Three20/TTGlobal.h"
@protocol TTScrollViewDelegate;
@protocol TTScrollViewDataSource;
@interface TTScrollView : UIView {
id<TTScrollViewDelegate> _delegate;
id<TTScrollViewDataSource> _dataSource;
NSInteger _centerPageIndex;
NSInteger _visiblePageIndex;
BOOL _scrollEnabled;
BOOL _zoomEnabled;
BOOL _rotateEnabled;
CGFloat _pageSpacing;
UIInterfaceOrientation _orientation;
NSMutableArray* _pages;
NSMutableArray* _pageQueue;
NSInteger _maxPages;
NSInteger _pageArrayIndex;
NSTimer* _tapTimer;
NSTimer* _animationTimer;
NSDate* _animationStartTime;
NSTimeInterval _animationDuration;
UIEdgeInsets _animateEdges;
UIEdgeInsets _pageEdges;
UIEdgeInsets _pageStartEdges;
UIEdgeInsets _touchEdges;
UIEdgeInsets _touchStartEdges;
NSUInteger _touchCount;
CGFloat _overshoot;
UITouch* _touch1;
UITouch* _touch2;
BOOL _dragging;
BOOL _zooming;
}
/**
*
*/
@property(nonatomic,assign) id<TTScrollViewDelegate> delegate;
/**
*
*/
@property(nonatomic,assign) id<TTScrollViewDataSource> dataSource;
/**
*
*/
@property(nonatomic) NSInteger centerPageIndex;
/**
*
*/
@property(nonatomic) BOOL scrollEnabled;
/**
*
*/
@property(nonatomic) BOOL zoomEnabled;
/**
*
*/
@property(nonatomic) BOOL rotateEnabled;
/**
*
*/
@property(nonatomic) CGFloat pageSpacing;
/**
*
*/
@property(nonatomic) UIInterfaceOrientation orientation;
/**
*
*/
@property(nonatomic,readonly) NSInteger numberOfPages;
/**
*
*/
@property(nonatomic,readonly) UIView* centerPage;
/**
* A dictionary of visible pages keyed by the index of the page.
*/
@property(nonatomic,readonly) NSDictionary* visiblePages;
- (void)setOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated;
/**
* Gets a previously created page view that has been moved off screen and recycled.
*/
- (UIView*)dequeueReusablePage;
/**
*
*/
- (void)reloadData;
/**
*
*/
- (UIView*)pageAtIndex:(NSInteger)pageIndex;
@end
///////////////////////////////////////////////////////////////////////////////////////////////////
@protocol TTScrollViewDelegate <NSObject>
/**
*
*/
- (void)scrollView:(TTScrollView*)scrollView didMoveToPageAtIndex:(NSInteger)pageIndex;
@optional
/**
*
*/
- (void)scrollViewWillRotate:(TTScrollView*)scrollView
toOrientation:(UIInterfaceOrientation)orientation;
/**
*
*/
- (void)scrollViewDidRotate:(TTScrollView*)scrollView;
/**
*
*/
- (void)scrollViewWillBeginDragging:(TTScrollView*)scrollView;
/**
*
*/
- (void)scrollViewDidEndDragging:(TTScrollView*)scrollView willDecelerate:(BOOL)willDecelerate;
/**
*
*/
- (void)scrollViewDidEndDecelerating:(TTScrollView*)scrollView;
/**
*
*/
- (BOOL)scrollViewShouldZoom:(TTScrollView*)scrollView;
/**
*
*/
- (void)scrollViewDidBeginZooming:(TTScrollView*)scrollView;
/**
*
*/
- (void)scrollViewDidEndZooming:(TTScrollView*)scrollView;
/**
*
*/
- (void)scrollView:(TTScrollView*)scrollView touchedDown:(UITouch*)touch;
/**
*
*/
- (void)scrollView:(TTScrollView*)scrollView touchedUpInside:(UITouch*)touch;
/**
*
*/
- (void)scrollView:(TTScrollView*)scrollView tapped:(UITouch*)touch;
@optional
- (BOOL)scrollView:(TTScrollView*)scrollView
shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation;
@end
///////////////////////////////////////////////////////////////////////////////////////////////////
@protocol TTScrollViewDataSource <NSObject>
/**
*
*/
- (NSInteger)numberOfPagesInScrollView:(TTScrollView*)scrollView;
/**
* Gets a view to display for the page at the given index.
*
* You do not need to position or size the view as that is done for you later. You should
* call dequeueReusablePage first, and only create a new view if it returns nil.
*/
- (UIView*)scrollView:(TTScrollView*)scrollView pageAtIndex:(NSInteger)pageIndex;
/**
* Gets the natural size of the page.
*
* The actual width and height are not as important as the ratio between width and height.
* This is used to determine how to
*/
- (CGSize)scrollView:(TTScrollView*)scrollView sizeOfPageAtIndex:(NSInteger)pageIndex;
@end