Skip to content

Commit

Permalink
Merge pull request highmountain12321#1 from highmountain12321/branch_…
Browse files Browse the repository at this point in the history
…0413

feat: beautify white.js, index.js., innerSize.js
  • Loading branch information
highmountain12321 authored Apr 13, 2023
2 parents a5fbc47 + 4553477 commit 2f94f1a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Textfit from './Textfit';
import Textfit from "./Textfit";
export { Textfit };
export default Textfit;
32 changes: 16 additions & 16 deletions src/utils/innerSize.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Calculate height without padding.
export function innerHeight(el) {
const style = window.getComputedStyle(el, null);
// Hidden iframe in Firefox returns null, https://github.com/malte-wessel/react-textfit/pull/34
if (!style) return el.clientHeight;
return (
el.clientHeight -
parseInt(style.getPropertyValue('padding-top'), 10) -
parseInt(style.getPropertyValue('padding-bottom'), 10)
);
const style = window.getComputedStyle(el, null);
// Hidden iframe in Firefox returns null, https://github.com/malte-wessel/react-textfit/pull/34
if (!style) return el.clientHeight;
return (
el.clientHeight -
parseInt(style.getPropertyValue("padding-top"), 10) -
parseInt(style.getPropertyValue("padding-bottom"), 10)
);
}

// Calculate width without padding.
export function innerWidth(el) {
const style = window.getComputedStyle(el, null);
// Hidden iframe in Firefox returns null, https://github.com/malte-wessel/react-textfit/pull/34
if (!style) return el.clientWidth;
return (
el.clientWidth -
parseInt(style.getPropertyValue('padding-left'), 10) -
parseInt(style.getPropertyValue('padding-right'), 10)
);
const style = window.getComputedStyle(el, null);
// Hidden iframe in Firefox returns null, https://github.com/malte-wessel/react-textfit/pull/34
if (!style) return el.clientWidth;
return (
el.clientWidth -
parseInt(style.getPropertyValue("padding-left"), 10) -
parseInt(style.getPropertyValue("padding-right"), 10)
);
}
24 changes: 12 additions & 12 deletions src/utils/whilst.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ const noop = () => {};
*/

export default function whilst(test, iterator, callback = noop) {
if (test()) {
iterator(function next(err, ...args) {
if (err) {
callback(err);
} else if (test.apply(this, args)) {
iterator(next);
} else {
callback(null);
}
});
} else {
if (test()) {
iterator(function next(err, ...args) {
if (err) {
callback(err);
} else if (test.apply(this, args)) {
iterator(next);
} else {
callback(null);
}
}
});
} else {
callback(null);
}
}

0 comments on commit 2f94f1a

Please sign in to comment.