azoff/overscroll

overscroll() occasionally not working when loading / reloading a page

derjochenmeyer opened this issue · 4 comments

Thanks for this plugin! I love it.

However, sometimes (occasionally) when I load (Firefox 14.0.1 WIN) or reload (Chrome 21.0.1180.75 m WIN) the page overscroll() does not "fire". There are NO console errors. Activating overscroll() manually clicking a link <a href="javascript:$("#canvas").overscroll()">enable scrolling</a>works fine.

Here's my raw setup_

JavaScript

$(document).ready(function() {
  $("#canvas").overscroll();
});

HTML

<div id="canvas">
  <div id="tile-handlers">[100 handlers]</div>
  <div id="tile-images">[100 images]</div>
</div>

CSS

#canvas {
  position: relative;
  width: 940px;
  height: 400px;
  overflow: scroll;
}

Update: $(window).load(function() { }); instead of $(document).ready(function() { }); solves the problem.

$(window).load(function() {
  $("#canvas").overscroll();
});

Hello,

Sorry for the late reply, I've been traveling and haven't had a moment to look at any bugs. I plan on getting to these eventually when I get a moment but any pull requests will be considered if you decide to take initiative on this.

Best,

Jon

Given your description (and solution), I'm left to suppose that the problem has to do with when you call overscroll. If overscroll is called before the content is ready, then it will not calculate size correctly, and hence it may not work. The "document ready" event - in your case - may mean that the DOM is ready, but your content is not. The "window load" event may be fine, or you could probably even bind listeners to whatever nodes you are loading in the container.

Anyways, since this seems like an implementation issue - I'll have to close it. If you can create a demo (e.g. via jsfiddle) and post it here, then feel free to re-open.

Thanks,

Jon

Not sure if its the same issue I had, but setting off caching in my CMS solves issues with Chrome and Safari.