Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
yomotsu committed Apr 20, 2024
1 parent 38b43be commit b59a648
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions dist/match-height.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,16 @@
const maxHeightInRow = Math.max(...processingTargets.map((item) => item.height));
processingTargets.forEach((item) => {
const error = processingTop - item.top + errorThreshold;
const isBorderBox = window.getComputedStyle(item.el).getPropertyValue('box-sizing') === 'border-box';
const getPropertyValue = window.getComputedStyle(item.el).getPropertyValue;
const isBorderBox = getPropertyValue('box-sizing') === 'border-box';
if (isBorderBox) {
item.el.style.minHeight = `${maxHeightInRow + error}px`;
}
else {
const paddingAndBorder = parseFloat(window.getComputedStyle(item.el).getPropertyValue('padding-top')) +
parseFloat(window.getComputedStyle(item.el).getPropertyValue('padding-bottom')) +
parseFloat(window.getComputedStyle(item.el).getPropertyValue('border-top-width')) +
parseFloat(window.getComputedStyle(item.el).getPropertyValue('border-bottom-width'));
const paddingAndBorder = parseFloat(getPropertyValue('padding-top')) +
parseFloat(getPropertyValue('padding-bottom')) +
parseFloat(getPropertyValue('border-top-width')) +
parseFloat(getPropertyValue('border-bottom-width'));
item.el.style.minHeight = `${maxHeightInRow - paddingAndBorder + error}px`;
}
});
Expand Down
2 changes: 1 addition & 1 deletion dist/match-height.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions dist/match-height.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ class MatchHeight {
const maxHeightInRow = Math.max(...processingTargets.map((item) => item.height));
processingTargets.forEach((item) => {
const error = processingTop - item.top + errorThreshold;
const isBorderBox = window.getComputedStyle(item.el).getPropertyValue('box-sizing') === 'border-box';
const getPropertyValue = window.getComputedStyle(item.el).getPropertyValue;
const isBorderBox = getPropertyValue('box-sizing') === 'border-box';
if (isBorderBox) {
item.el.style.minHeight = `${maxHeightInRow + error}px`;
}
else {
const paddingAndBorder = parseFloat(window.getComputedStyle(item.el).getPropertyValue('padding-top')) +
parseFloat(window.getComputedStyle(item.el).getPropertyValue('padding-bottom')) +
parseFloat(window.getComputedStyle(item.el).getPropertyValue('border-top-width')) +
parseFloat(window.getComputedStyle(item.el).getPropertyValue('border-bottom-width'));
const paddingAndBorder = parseFloat(getPropertyValue('padding-top')) +
parseFloat(getPropertyValue('padding-bottom')) +
parseFloat(getPropertyValue('border-top-width')) +
parseFloat(getPropertyValue('border-bottom-width'));
item.el.style.minHeight = `${maxHeightInRow - paddingAndBorder + error}px`;
}
});
Expand Down

0 comments on commit b59a648

Please sign in to comment.