Skip to content

Commit c1f9aca

Browse files
remorsesgithub-actions[bot]
authored andcommitted
New Framer Release
1 parent c9c35e9 commit c1f9aca

File tree

1 file changed

+66
-8
lines changed

1 file changed

+66
-8
lines changed

unframer/src/framer.js

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11214,7 +11214,7 @@ function stagger(duration = 0.1, {
1121411214
};
1121511215
}
1121611216

11217-
// /:https://app.framerstatic.com/framer.QYMX4MSQ.mjs
11217+
// /:https://app.framerstatic.com/framer.UWLYDHV3.mjs
1121811218
import { lazy as ReactLazy, } from 'react';
1121911219
import React4 from 'react';
1122011220
import { startTransition as startTransition2, } from 'react';
@@ -19294,8 +19294,13 @@ var DimensionType = /* @__PURE__ */ ((DimensionType2) => {
1929419294
DimensionType2[DimensionType2['Auto'] = 2] = 'Auto';
1929519295
DimensionType2[DimensionType2['FractionOfFreeSpace'] = 3] = 'FractionOfFreeSpace';
1929619296
DimensionType2[DimensionType2['Viewport'] = 4] = 'Viewport';
19297+
DimensionType2[DimensionType2['FitImage'] = 5] = 'FitImage';
1929719298
return DimensionType2;
1929819299
})(DimensionType || {},);
19300+
function isAutoDimensionType(dimensionType,) {
19301+
if (isUndefined(dimensionType,)) return false;
19302+
return dimensionType === 2 || dimensionType === 5;
19303+
}
1929919304
function isConstraintSupportingChild(child,) {
1930019305
if (!isReactChild(child,) || !isReactElement(child,)) {
1930119306
return false;
@@ -19306,7 +19311,7 @@ var ConstraintMask = {
1930619311
// Modifies the constraint mask to remove invalid (mutually exclusive) options and returns the original.
1930719312
// TODO: this removes major inconsistencies but probably needs to be merged with ConstraintSolver.
1930819313
quickfix: (constraints) => {
19309-
if (constraints.widthType === 2 || constraints.heightType === 2) {
19314+
if (isAutoDimensionType(constraints.widthType,) || isAutoDimensionType(constraints.heightType,)) {
1931019315
constraints.aspectRatio = null;
1931119316
}
1931219317
if (isFiniteNumber(constraints.aspectRatio,)) {
@@ -19324,13 +19329,13 @@ var ConstraintMask = {
1932419329
}
1932519330
}
1932619331
if (constraints.left && constraints.right) {
19327-
if (constraints.fixedSize || constraints.widthType === 2 || isFiniteNumber(constraints.maxWidth,)) {
19332+
if (constraints.fixedSize || isAutoDimensionType(constraints.widthType,) || isFiniteNumber(constraints.maxWidth,)) {
1932819333
constraints.right = false;
1932919334
}
1933019335
constraints.widthType = 0;
1933119336
}
1933219337
if (constraints.top && constraints.bottom) {
19333-
if (constraints.fixedSize || constraints.heightType === 2 || isFiniteNumber(constraints.maxHeight,)) {
19338+
if (constraints.fixedSize || isAutoDimensionType(constraints.heightType,) || isFiniteNumber(constraints.maxHeight,)) {
1933419339
constraints.bottom = false;
1933519340
}
1933619341
constraints.heightType = 0;
@@ -19439,7 +19444,7 @@ var ConstraintValues = {
1943919444
const hOpposingPinsOffset = pinnedOffset(values.left, values.right,);
1944019445
if (parentWidth && isFiniteNumber(hOpposingPinsOffset,)) {
1944119446
width = parentWidth - hOpposingPinsOffset;
19442-
} else if (autoSize && values.widthType === 2) {
19447+
} else if (autoSize && isAutoDimensionType(values.widthType,)) {
1944319448
width = autoSize.width;
1944419449
} else if (isFiniteNumber(values.width,)) {
1944519450
switch (values.widthType) {
@@ -19456,6 +19461,7 @@ var ConstraintValues = {
1945619461
}
1945719462
break;
1945819463
case 2:
19464+
case 5:
1945919465
break;
1946019466
default:
1946119467
assertNever(values.widthType,);
@@ -19464,7 +19470,7 @@ var ConstraintValues = {
1946419470
const vOpposingPinsOffset = pinnedOffset(values.top, values.bottom,);
1946519471
if (parentHeight && isFiniteNumber(vOpposingPinsOffset,)) {
1946619472
height = parentHeight - vOpposingPinsOffset;
19467-
} else if (autoSize && values.heightType === 2) {
19473+
} else if (autoSize && isAutoDimensionType(values.heightType,)) {
1946819474
height = autoSize.height;
1946919475
} else if (isFiniteNumber(values.height,)) {
1947019476
switch (values.heightType) {
@@ -19481,6 +19487,7 @@ var ConstraintValues = {
1948119487
}
1948219488
break;
1948319489
case 2:
19490+
case 5:
1948419491
break;
1948519492
default:
1948619493
assertNever(values.heightType,);
@@ -23410,7 +23417,7 @@ var key = 'src';
2341023417
var BackgroundImage = {
2341123418
isImageObject: function (image,) {
2341223419
if (!image || typeof image === 'string') return false;
23413-
return key in image;
23420+
return typeof image === 'object' && key in image;
2341423421
},
2341523422
};
2341623423
function applyForwardOverrides(background, props,) {
@@ -23451,6 +23458,29 @@ function backgroundImageFromProps(props,) {
2345123458
}
2345223459
return applyForwardOverrides(backgroundImage, props,);
2345323460
}
23461+
function getIntrinsicSizeForBackgroundImage(background,) {
23462+
if (!background) return void 0;
23463+
if (background.pixelHeight && background.pixelWidth) {
23464+
return {
23465+
width: background.pixelWidth,
23466+
height: background.pixelHeight,
23467+
};
23468+
}
23469+
return parseImageSizeFromSrc(background.src,);
23470+
}
23471+
function parseImageSizeFromSrc(src,) {
23472+
if (!src) return void 0;
23473+
const url = new URL(src,);
23474+
const width = url.searchParams.get('width',);
23475+
const height = url.searchParams.get('height',);
23476+
if (width && height) {
23477+
return {
23478+
width: parseInt(width,),
23479+
height: parseInt(height,),
23480+
};
23481+
}
23482+
return void 0;
23483+
}
2345423484
function htmlElementAsMotionComponent(asElem,) {
2345523485
return asElem && asElem !== 'search' && asElem !== 'slot' && asElem !== 'template' ? motion[asElem] : motion['div'];
2345623486
}
@@ -24559,6 +24589,11 @@ var VisibleFrame = /* @__PURE__ */ forwardRef(function VisibleFrame2(props, forw
2455924589
parentSize,
2456024590
);
2456124591
const MotionComponent = htmlElementAsMotionComponent(props.as,);
24592+
const intrinsicSize = getIntrinsicSizeForBackgroundImage(backgroundImage,);
24593+
if (props.fitImageDimension && intrinsicSize) {
24594+
currentStyle[props.fitImageDimension] = 'auto';
24595+
currentStyle.aspectRatio = intrinsicSize.width / intrinsicSize.height;
24596+
}
2456224597
return /* @__PURE__ */ jsxs(MotionComponent, {
2456324598
...dataProps,
2456424599
...motionProps,
@@ -47167,12 +47202,35 @@ var Image2 = /* @__PURE__ */ React4.forwardRef(function Image3(props, ref,) {
4716747202
children,
4716847203
alt,
4716947204
draggable,
47205+
fitImageDimension,
4717047206
style: styleFromProps,
4717147207
...rest
4717247208
} = props;
4717347209
const style2 = {
4717447210
...styleFromProps,
4717547211
};
47212+
const intrinsicSize = useMemo2(() => getIntrinsicSizeForBackgroundImage(background,), [background,],);
47213+
const [fallbackIntrinsicSize, setFallbackIntrinsicSize,] = useState();
47214+
React4.useLayoutEffect(() => {
47215+
if (!(background == null ? void 0 : background.src)) return;
47216+
if (!fitImageDimension) return;
47217+
if (intrinsicSize) return;
47218+
const img = document.createElement('img',);
47219+
img.onload = () => {
47220+
if (img.naturalWidth && img.naturalHeight) {
47221+
setFallbackIntrinsicSize({
47222+
width: img.naturalWidth,
47223+
height: img.naturalHeight,
47224+
},);
47225+
}
47226+
};
47227+
img.src = background.src;
47228+
}, [background == null ? void 0 : background.src, fitImageDimension, intrinsicSize,],);
47229+
const size = intrinsicSize ?? fallbackIntrinsicSize;
47230+
if (fitImageDimension && size) {
47231+
style2[fitImageDimension] = 'auto';
47232+
style2.aspectRatio = size.width / size.height;
47233+
}
4717647234
if (background) {
4717747235
delete style2.background;
4717847236
}
@@ -49432,7 +49490,7 @@ var TextComponent = /* @__PURE__ */ (() => {
4943249490
} = this.props;
4943349491
if (this.props.transformTemplate) return this.props.transformTemplate;
4943449492
const frame2 = this.frame;
49435-
const isDOMLayoutAutoSized = _usesDOMRect && (widthType === 2 || heightType === 2);
49493+
const isDOMLayoutAutoSized = _usesDOMRect && (isAutoDimensionType(widthType,) || isAutoDimensionType(heightType,));
4943649494
const hasTransformTemplate = !frame2 || !RenderTarget.hasRestrictions() || __fromCanvasComponent || isDOMLayoutAutoSized;
4943749495
if (hasTransformTemplate) return transformTemplate(this.props.center,);
4943849496
}

0 commit comments

Comments
 (0)