diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2017-02-16 01:30:53 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2017-02-16 01:30:53 -0800 |
commit | a3d01a768f0e7f9d5a36b4bcea04458634818863 (patch) | |
tree | a3e62c81f8cf286cabe0bdf382c95caaf0722d0d /CyteKit/WebView.mm | |
parent | 68df8c0b7bacec286d4798408b5a110bdac88986 (diff) |
Move a bunch of clearly shared logic into CyteKit.
Diffstat (limited to 'CyteKit/WebView.mm')
-rw-r--r-- | CyteKit/WebView.mm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/CyteKit/WebView.mm b/CyteKit/WebView.mm index 3711587..9e0cbea 100644 --- a/CyteKit/WebView.mm +++ b/CyteKit/WebView.mm @@ -417,3 +417,29 @@ __attribute__((__constructor__)) static void $() { class_addMethod($UIWebViewWebViewDelegate, @selector(_clearUIWebView), (IMP) &$UIWebViewWebViewDelegate$_clearUIWebView, "v8@0:4"); } } + +@implementation UIWebDocumentView (Cydia) + +- (void) _setScrollerOffset:(CGPoint)offset { + UIScroller *scroller([self _scroller]); + + CGSize size([scroller contentSize]); + CGSize bounds([scroller bounds].size); + + CGPoint max; + max.x = size.width - bounds.width; + max.y = size.height - bounds.height; + + // wtf Apple?! + if (max.x < 0) + max.x = 0; + if (max.y < 0) + max.y = 0; + + offset.x = offset.x < 0 ? 0 : offset.x > max.x ? max.x : offset.x; + offset.y = offset.y < 0 ? 0 : offset.y > max.y ? max.y : offset.y; + + [scroller setOffset:offset]; +} + +@end |