MCPcopy
hub / github.com/layui/layui / boxModelAdjustment

Function boxModelAdjustment

src/modules/jquery.js:6711–6802  ·  view source on GitHub ↗
(
    elem,
    dimension,
    box,
    isBorderBox,
    styles,
    computedVal
  )

Source from the content-addressed store, hash-verified

6709 }
6710
6711 function boxModelAdjustment(
6712 elem,
6713 dimension,
6714 box,
6715 isBorderBox,
6716 styles,
6717 computedVal
6718 ) {
6719 var i = dimension === 'width' ? 1 : 0,
6720 extra = 0,
6721 delta = 0,
6722 marginDelta = 0;
6723
6724 // Adjustment may not be necessary
6725 if (box === (isBorderBox ? 'border' : 'content')) {
6726 return 0;
6727 }
6728
6729 for (; i < 4; i += 2) {
6730 // Both box models exclude margin
6731 // Count margin delta separately to only add it after scroll gutter adjustment.
6732 // This is needed to make negative margins work with `outerHeight( true )` (gh-3982).
6733 if (box === 'margin') {
6734 marginDelta += jQuery.css(elem, box + cssExpand[i], true, styles);
6735 }
6736
6737 // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
6738 if (!isBorderBox) {
6739 // Add padding
6740 delta += jQuery.css(elem, 'padding' + cssExpand[i], true, styles);
6741
6742 // For "border" or "margin", add border
6743 if (box !== 'padding') {
6744 delta += jQuery.css(
6745 elem,
6746 'border' + cssExpand[i] + 'Width',
6747 true,
6748 styles
6749 );
6750
6751 // But still keep track of it otherwise
6752 } else {
6753 extra += jQuery.css(
6754 elem,
6755 'border' + cssExpand[i] + 'Width',
6756 true,
6757 styles
6758 );
6759 }
6760
6761 // If we get here with a border-box (content + padding + border), we're seeking "content" or
6762 // "padding" or "margin"
6763 } else {
6764 // For "content", subtract padding
6765 if (box === 'content') {
6766 delta -= jQuery.css(elem, 'padding' + cssExpand[i], true, styles);
6767 }
6768

Callers 2

getWidthOrHeightFunction · 0.85
jquery.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected