Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable rubber-band scrolling for webview in lion

I have a Cocoa webview, with a web application in it. The web application has a fixed toolbar itself, and with the elastic scrolling, and the toolbar coming below the top, it looks bad. Is there a way to disable the elastic/rubber-band scrolling, or at least keep the toolbar from moving with the rest of the content? I can modify the web app as much as neede.

like image 435
penguinrob Avatar asked Aug 11 '11 04:08

penguinrob


3 Answers

If you're interested in doing it from the WebView and Cocoa perspective, you can also implement the finish load delegate, grab the scroll view, and disable elasticity:

- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
    NSScrollView *mainScrollView = sender.mainFrame.frameView.documentView.enclosingScrollView;
    [mainScrollView setVerticalScrollElasticity:NSScrollElasticityNone]; 
    [mainScrollView setHorizontalScrollElasticity:NSScrollElasticityNone];
}
like image 152
Vervious Avatar answered Nov 11 '22 20:11

Vervious


Maybe this article would help you.

In short: disable overflow on HTML and BODY, add a wrapper with overflow:auto around all the page contents

like image 4
kizu Avatar answered Nov 11 '22 22:11

kizu


I know this comment likely won't be accepted, since there's already an answer.

However, there's an actual method you can call on your NSView (docs here):

[[[webView mainFrame] frameView] setAllowsScrolling:NO]; 
like image 3
briangonzalez Avatar answered Nov 11 '22 22:11

briangonzalez