Skip to content

Commit

Permalink
Add a way to disable html scaling (#2)
Browse files Browse the repository at this point in the history
* Add unsafe-eval to CSP

* Add option to disable HTML scaling
  • Loading branch information
inescri authored Jul 24, 2024
1 parent beaabcd commit cb0406f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/toniq-nft-frame/src/iframe/iframe-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ function setScaledNftSize(
}

if (dimensionScales && (dimensionScales.height !== 1 || dimensionScales.width !== 1)) {
htmlElement.querySelector('body')!.style.setProperty(
'transform',
[
`scaleX(${dimensionScales.width})`,
`scaleY(${dimensionScales.height})`,
].join(' '),
);
htmlElement.classList.add('scaled');
if (!nftConfig.disableHTMLScaling) {
htmlElement.querySelector('body')!.style.setProperty(
'transform',
[
`scaleX(${dimensionScales.width})`,
`scaleY(${dimensionScales.height})`,
].join(' '),
);
htmlElement.classList.add('scaled');
}
}

return newNftDimensions;
Expand Down
2 changes: 2 additions & 0 deletions packages/toniq-nft-frame/src/nft-frame-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export const defaultNftConfig = {
/** Set this to true to prevent removal of console method calls inside of the child iframe. */
allowConsoleLogs: undefined as boolean | undefined,
hideError: undefined as boolean | undefined,
/** Set this to true disable scaling feature on HTML NFTs */
disableHTMLScaling: undefined as boolean | undefined,
} as const;

type RequiredConfigKeys = 'nftUrl' | 'childFrameUrl';
Expand Down

0 comments on commit cb0406f

Please sign in to comment.