return width and height all the times
This commit is contained in:
@@ -74,11 +74,25 @@ module.exports = (lib) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function wrapMeasureFunction(measureFunction) {
|
function wrapMeasureFunction(measureFunction) {
|
||||||
return lib.MeasureCallback.implement({ measure: measureFunction });
|
return lib.MeasureCallback.implement({
|
||||||
|
measure: (...args) => {
|
||||||
|
const { width, height } = measureFunction(...args);
|
||||||
|
return {
|
||||||
|
width: width ?? NaN,
|
||||||
|
height: height ?? NaN,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
patch(lib.Node.prototype, "setMeasureFunc", function (original, measureFunc) {
|
patch(lib.Node.prototype, "setMeasureFunc", function (original, measureFunc) {
|
||||||
original.call(this, wrapMeasureFunction(measureFunc));
|
// This patch is just a convenience patch, since it helps write more
|
||||||
|
// idiomatic source code (such as .setMeasureFunc(null))
|
||||||
|
if (measureFunc) {
|
||||||
|
return original.call(this, wrapMeasureFunction(measureFunc));
|
||||||
|
} else {
|
||||||
|
return this.unsetMeasureFunc();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function wrapDirtiedFunc(dirtiedFunction) {
|
function wrapDirtiedFunc(dirtiedFunction) {
|
||||||
@@ -115,16 +129,6 @@ module.exports = (lib) => {
|
|||||||
this.free();
|
this.free();
|
||||||
});
|
});
|
||||||
|
|
||||||
patch(lib.Node.prototype, "setMeasureFunc", function (original, measureFunc) {
|
|
||||||
// This patch is just a convenience patch, since it helps write more
|
|
||||||
// idiomatic source code (such as .setMeasureFunc(null))
|
|
||||||
if (measureFunc) {
|
|
||||||
return original.call(this, (...args) => measureFunc(...args));
|
|
||||||
} else {
|
|
||||||
return this.unsetMeasureFunc();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
patch(
|
patch(
|
||||||
lib.Node.prototype,
|
lib.Node.prototype,
|
||||||
"calculateLayout",
|
"calculateLayout",
|
||||||
|
Reference in New Issue
Block a user