Scaling
ES Drager supports scaling functionality through mouse wheel interaction.
Basic Scaling
Enable scaling by setting the scalable prop:
<Drager
style={{
width: '128px',
height: '128px',
backgroundColor: '#3B82F6',
borderRadius: '8px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: 'white'
}}
scalable
>
Scroll to scale
</Drager>
Use your mouse wheel while hovering over the element to scale it.
Scale Limits
You can control the minimum and maximum scale values using the minScale
and maxScale
props:
<Drager
style={{
width: '128px',
height: '128px',
backgroundColor: '#3B82F6',
borderRadius: '8px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: 'white'
}}
scalable
minScale={0.5}
maxScale={2}
>
Limited scaling
</Drager>
This element can only be scaled between 50% and 200% of its original size.
Scale Events
Track scale changes using the onScale
event handler:
<Drager
style={{
width: '128px',
height: '128px',
backgroundColor: '#3B82F6',
borderRadius: '8px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: 'white'
}}
scalable
onScale={(scale) => {
console.log('Current scale:', scale)
}}
>
Check console
</Drager>
Open your browser's console to see the scale value being logged.
Combined Features
Scaling works seamlessly with dragging and rotation:
<Drager
style={{
width: '128px',
height: '128px',
backgroundColor: '#3B82F6',
borderRadius: '8px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
color: 'white'
}}
scalable
rotatable
minScale={0.5}
maxScale={2}
>
Try all features
</Drager>
This element can be dragged, rotated, and scaled.