Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to operate with 100% width? #437

Closed
tiagocaus opened this issue May 18, 2019 · 6 comments
Closed

How to operate with 100% width? #437

tiagocaus opened this issue May 18, 2019 · 6 comments

Comments

@tiagocaus
Copy link

How to operate with 100% width?

@freezed
Copy link

freezed commented Jul 2, 2019

Please be more explicit…

@tiagocaus
Copy link
Author

Please be more explicit…

I had made the canvas thinking of the handheld, the width had been perfect.

But they decided to use a tablet, so the width got smaller.

See the image:

How to make the signature screen responsive (Width 100%) to any screen size.

Thank you.

@freezed
Copy link

freezed commented Jul 2, 2019

(I cannot see your image)
Did the demo code work on your tablet ?

@xiaoxiaofan123
Copy link

Have the same issue.
I set the canvas width 100% height 100% in the mobile screen
Then the canvas don't work correct

@freezed
Copy link

freezed commented Jul 31, 2019

Talk is cheap. Show us the code.

@cncolder
Copy link

cncolder commented Nov 5, 2019

Use div wrap canvas. Then use ResizeObserver listen div size change. pass to canvas.

It's complex but worked. I use useMeasure of react-use. See below:

import React from 'react'
import { useMeasure } from 'react-use'

export default () => {
	const [containerRef, { width, height }] = useMeasure();

	return (
		<div ref={containerRef} style={{ width: '100%', height: '100%' }}>
			<canvas width={width} height={height} />
		</div>
	)
}

@UziTech UziTech closed this as completed Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants