Adding a shift property.

This commit is contained in:
Eric van der Vlist 2022-09-07 21:44:59 +02:00
parent 5a663d84d8
commit 04c2c12117
2 changed files with 11 additions and 5 deletions

View File

@ -19,14 +19,13 @@ import '@ionic/react/css/display.css';
/* Theme variables */
import './theme/variables.css';
import Background from './components/background';
setupIonicReact();
const App: React.FC = () => (
<IonApp>
<Background />
<Background shift={{ x: 1000, y: 1000 }} />
</IonApp>
);

View File

@ -2,10 +2,17 @@ import react from 'react';
import '../theme/background.css';
const Background: react.FC = () => {
const Background: react.FC<{ shift: { x: number; y: number } }> = (props: {
shift: { x: number; y: number };
}) => {
return (
<div className='background'>
<img src='/assets/background.jpg' />
<div
className='background'
style={{
transform: `translate(${-props.shift.x}px, ${-props.shift.y}px)`,
}}
>
<img src='/assets/background.jpg' alt='' />
</div>
);
};