Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// because we will override it
containerState.style = {
overflow: container.style.overflow,
paddingRight: container.style.paddingRight,
};
if (containerState.overflowing) {
// use computed style, here to get the real padding
// to add our scrollbar width
style.paddingRight = `${parseInt(
css(container, 'paddingRight') || 0,
10,
) + this.scrollbarSize}px`;
}
css(container, style);
}
setContainerStyle(containerState, container) {
let style = { overflow: 'hidden' };
// we are only interested in the actual `style` here
// because we will override it
containerState.style = {
overflow: container.style.overflow,
paddingRight: container.style.paddingRight,
};
if (containerState.overflowing) {
// use computed style, here to get the real padding
// to add our scrollbar width
style.paddingRight = `${parseInt(
css(container, 'paddingRight') || 0,
10,
) + this.scrollbarSize}px`;
}
css(container, style);
}
it('should reset overflow style to the computed one', () => {
let modal = new Modal({});
expect(css(container, 'overflow')).to.equal('scroll');
manager.add(modal, container);
manager.remove(modal);
expect(container.style.overflow).to.equal('');
expect(css(container, 'overflow')).to.equal('scroll');
});
getDimensionValue(elem: HTMLElement) {
const top = css(elem, 'marginTop') ?? 0;
const bottom = css(elem, 'marginBottom') ?? 0;
return (elem.offsetHeight +
(top == 0 ? 0 : parseInt(top, 10)) +
(bottom == 0 ? 0 : parseInt(bottom, 10))
);
}
adjustAndStore = (prop, element, adjust) => {
const actual = element.style[prop];
element.dataset[prop] = actual;
css(element, prop, `${parseFloat(css(element, prop)) + adjust}px`);
};
restore = (prop, element) => {
const value = element.dataset[prop];
if (value !== undefined) {
delete element.dataset[prop];
css(element, prop, value);
}
};
function getHeight(elem) {
let value = elem.offsetHeight;
let margins = ['marginTop', 'marginBottom'];
return (value +
parseInt(style(elem, margins[0]), 10) +
parseInt(style(elem, margins[1]), 10)
);
}
function getHeight(elem) {
let value = elem.offsetHeight;
let margins = ['marginTop', 'marginBottom'];
return (value +
parseInt(style(elem, margins[0]), 10) +
parseInt(style(elem, margins[1]), 10)
);
}
getDimensionValue(elem: HTMLElement) {
const top = css(elem, 'marginTop') ?? 0;
const bottom = css(elem, 'marginBottom') ?? 0;
return (elem.offsetHeight +
(top == 0 ? 0 : parseInt(top, 10)) +
(bottom == 0 ? 0 : parseInt(bottom, 10))
);
}