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

23 lines
513 B
TypeScript
Raw Normal View History

import react from 'react';
import '../theme/background.css';
2022-09-07 19:44:59 +00:00
const Background: react.FC<{ shift: { x: number; y: number } }> = (props: {
shift: { x: number; y: number };
}) => {
2022-09-08 13:00:36 +00:00
console.log(`--- Rendering background, props: ${JSON.stringify(props)} ---`);
2022-09-07 21:19:42 +00:00
return (
2022-09-07 19:44:59 +00:00
<div
className='background'
style={{
transform: `translate(${-props.shift.x}px, ${-props.shift.y}px)`,
}}
>
<img src='/assets/background.jpg' alt='' />
</div>
);
};
export default Background;