iframe多页签下滚动条宽度计算有问题
This commit is contained in:
parent
373a6fef2f
commit
e2481f75ff
|
@ -775,7 +775,7 @@ var Table = function (_Component) {
|
|||
useFixedHeader = true;
|
||||
|
||||
// Add negative margin bottom for scroll bar overflow bug
|
||||
var scrollbarWidth = this.scrollbarWidth;
|
||||
var scrollbarWidth = this.scrollbarWidth ? this.scrollbarWidth : 15;
|
||||
if (scrollbarWidth >= 0) {
|
||||
(fixed ? bodyStyle : headStyle).paddingBottom = '0px';
|
||||
//显示表头滚动条
|
||||
|
|
|
@ -27,7 +27,7 @@ var _parseInt2 = _interopRequireDefault(_parseInt);
|
|||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
|
||||
var scrollbarWidth = void 0;
|
||||
var scrollbarSize = void 0;
|
||||
|
||||
// Measure scrollbar width for padding body during modal show/hide
|
||||
var scrollbarMeasure = {
|
||||
|
@ -39,24 +39,29 @@ var scrollbarMeasure = {
|
|||
};
|
||||
|
||||
function measureScrollbar() {
|
||||
var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'vertical';
|
||||
|
||||
if (typeof document === 'undefined' || typeof window === 'undefined') {
|
||||
return 0;
|
||||
}
|
||||
if (window.scrollbarWidth) {
|
||||
return window.scrollbarWidth;
|
||||
if (scrollbarSize) {
|
||||
return scrollbarSize;
|
||||
}
|
||||
var scrollDiv = document.createElement('div');
|
||||
for (var scrollProp in scrollbarMeasure) {
|
||||
if (scrollbarMeasure.hasOwnProperty(scrollProp)) {
|
||||
Object.keys(scrollbarMeasure).forEach(function (scrollProp) {
|
||||
scrollDiv.style[scrollProp] = scrollbarMeasure[scrollProp];
|
||||
}
|
||||
}
|
||||
});
|
||||
document.body.appendChild(scrollDiv);
|
||||
var width = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||
var size = 0;
|
||||
if (direction === 'vertical') {
|
||||
size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||
} else if (direction === 'horizontal') {
|
||||
size = scrollDiv.offsetHeight - scrollDiv.clientHeight;
|
||||
}
|
||||
|
||||
document.body.removeChild(scrollDiv);
|
||||
scrollbarWidth = width;
|
||||
window.scrollbarWidth = scrollbarWidth;
|
||||
return scrollbarWidth;
|
||||
scrollbarSize = size;
|
||||
return scrollbarSize;
|
||||
}
|
||||
|
||||
function debounce(func, wait, immediate) {
|
||||
|
|
|
@ -11343,7 +11343,7 @@
|
|||
useFixedHeader = true;
|
||||
|
||||
// Add negative margin bottom for scroll bar overflow bug
|
||||
var scrollbarWidth = this.scrollbarWidth;
|
||||
var scrollbarWidth = (0, _utils.measureScrollbar)();
|
||||
if (scrollbarWidth >= 0) {
|
||||
(fixed ? bodyStyle : headStyle).paddingBottom = '0px';
|
||||
//显示表头滚动条
|
||||
|
@ -13378,7 +13378,7 @@
|
|||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
|
||||
|
||||
var scrollbarWidth = void 0;
|
||||
var scrollbarSize = void 0;
|
||||
|
||||
// Measure scrollbar width for padding body during modal show/hide
|
||||
var scrollbarMeasure = {
|
||||
|
@ -13390,24 +13390,29 @@
|
|||
};
|
||||
|
||||
function measureScrollbar() {
|
||||
var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'vertical';
|
||||
|
||||
if (typeof document === 'undefined' || typeof window === 'undefined') {
|
||||
return 0;
|
||||
}
|
||||
if (window.scrollbarWidth) {
|
||||
return window.scrollbarWidth;
|
||||
if (scrollbarSize) {
|
||||
return scrollbarSize;
|
||||
}
|
||||
var scrollDiv = document.createElement('div');
|
||||
for (var scrollProp in scrollbarMeasure) {
|
||||
if (scrollbarMeasure.hasOwnProperty(scrollProp)) {
|
||||
Object.keys(scrollbarMeasure).forEach(function (scrollProp) {
|
||||
scrollDiv.style[scrollProp] = scrollbarMeasure[scrollProp];
|
||||
}
|
||||
}
|
||||
});
|
||||
document.body.appendChild(scrollDiv);
|
||||
var width = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||
var size = 0;
|
||||
if (direction === 'vertical') {
|
||||
size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||
} else if (direction === 'horizontal') {
|
||||
size = scrollDiv.offsetHeight - scrollDiv.clientHeight;
|
||||
}
|
||||
|
||||
document.body.removeChild(scrollDiv);
|
||||
scrollbarWidth = width;
|
||||
window.scrollbarWidth = scrollbarWidth;
|
||||
return scrollbarWidth;
|
||||
scrollbarSize = size;
|
||||
return scrollbarSize;
|
||||
}
|
||||
|
||||
function debounce(func, wait, immediate) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -675,7 +675,7 @@ class Table extends Component {
|
|||
useFixedHeader = true;
|
||||
|
||||
// Add negative margin bottom for scroll bar overflow bug
|
||||
const scrollbarWidth = this.scrollbarWidth;
|
||||
const scrollbarWidth = this.scrollbarWidth ?this.scrollbarWidth: 15;
|
||||
if (scrollbarWidth >= 0) {
|
||||
(fixed ? bodyStyle : headStyle).paddingBottom = '0px';
|
||||
//显示表头滚动条
|
||||
|
|
28
src/utils.js
28
src/utils.js
|
@ -2,7 +2,7 @@ import warning from 'warning';
|
|||
import parseInt from 'lodash/parseInt';
|
||||
|
||||
|
||||
let scrollbarWidth;
|
||||
let scrollbarSize;
|
||||
|
||||
// Measure scrollbar width for padding body during modal show/hide
|
||||
const scrollbarMeasure = {
|
||||
|
@ -13,27 +13,31 @@ const scrollbarMeasure = {
|
|||
overflow: 'scroll',
|
||||
};
|
||||
|
||||
export function measureScrollbar() {
|
||||
export function measureScrollbar(direction = 'vertical') {
|
||||
if (typeof document === 'undefined' || typeof window === 'undefined') {
|
||||
return 0;
|
||||
}
|
||||
if (window.scrollbarWidth) {
|
||||
return window.scrollbarWidth;
|
||||
if (scrollbarSize) {
|
||||
return scrollbarSize;
|
||||
}
|
||||
const scrollDiv = document.createElement('div');
|
||||
for (const scrollProp in scrollbarMeasure) {
|
||||
if (scrollbarMeasure.hasOwnProperty(scrollProp)) {
|
||||
Object.keys(scrollbarMeasure).forEach(scrollProp => {
|
||||
scrollDiv.style[scrollProp] = scrollbarMeasure[scrollProp];
|
||||
}
|
||||
}
|
||||
});
|
||||
document.body.appendChild(scrollDiv);
|
||||
const width = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||
let size = 0;
|
||||
if (direction === 'vertical') {
|
||||
size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||
} else if (direction === 'horizontal') {
|
||||
size = scrollDiv.offsetHeight - scrollDiv.clientHeight;
|
||||
}
|
||||
|
||||
document.body.removeChild(scrollDiv);
|
||||
scrollbarWidth = width;
|
||||
window.scrollbarWidth = scrollbarWidth;
|
||||
return scrollbarWidth;
|
||||
scrollbarSize = size;
|
||||
return scrollbarSize;
|
||||
}
|
||||
|
||||
|
||||
export function debounce(func, wait, immediate) {
|
||||
let timeout;
|
||||
return function debounceFunc() {
|
||||
|
|
Loading…
Reference in New Issue