jamesflorentino / nanoScrollerJS

A jQuery plugin that offers a simplistic way of implementing Lion OS scrollbars.
http://jamesflorentino.github.com/nanoScrollerJS/
MIT License
2.69k stars 502 forks source link

Scrollbar width is wrong calculated when used in iframe #243

Open sbergandy opened 10 years ago

sbergandy commented 10 years ago

The function getBrowserScrollbarWidth() calculates wrong result if we apply nanoscroller to some div which is placed in iframe. I fixed the issue by adding parent before each document like this:

  getBrowserScrollbarWidth = function() {
    var outer, outerStyle, scrollbarWidth;
    outer = parent.document.createElement('div');
    outerStyle = outer.style;
    outerStyle.position = 'absolute';
    outerStyle.width = '100px';
    outerStyle.height = '100px';
    outerStyle.overflow = SCROLL;
    outerStyle.top = '-9999px';
    parent.document.body.appendChild(outer);
    scrollbarWidth = outer.offsetWidth - outer.clientWidth;
    parent.document.body.removeChild(outer);
    return scrollbarWidth;
  };

But I have only one iframe layer. For more it could still be a problem.

brunowego commented 9 years ago

+1

bedrin commented 8 years ago

+1 It works fine in Chrome, but in IE it fails to calculate the scrollbar width