sandbox/background-move/src/components/background.tsx

32 lines
669 B
TypeScript

import react from 'react';
import '../theme/background.css';
const Background: react.FC<{
shift: { x: number; y: number };
zoom: number;
children?: JSX.Element;
}> = (props: {
shift: { x: number; y: number };
zoom: number;
children?: JSX.Element;
}) => {
const {children: children, ...argProps} = props;
console.log(`--- Rendering background, props: ${JSON.stringify(argProps)} ---`);
return (
<div
className='background'
style={{
transform: `translate(${-props.shift.x}px, ${-props.shift.y}px) scale(${
props.zoom
})`,
}}
>
{props.children}
</div>
);
};
export default Background;