Closed masakudamatsu closed 3 years ago
Idea (1): REJECTED
Make the color triangle as a canvas element without rendering it
Get the URL with .toDataURL
method
Set this URL as the srcset
in <image>
element.
=> No, this method doesn't work with hue changes.
Idea (2)
resize
event
resolution
prop to ColorTriangle
component to set the image resolutionresolution
prop value by the screen width stateTo obtain the screen width, we need to access to window.innerWidth
.
But the window
object is accessible only within useEffect
hook in Next.js
See https://stackoverflow.com/questions/55151041/window-is-not-defined-in-next-js-react-app
To change the resolution of the color picker by the ranges of window.innerWidth, we use the
if ... else if ... else if ...
pattern, not switch
, for the performance reason, as described in: https://stackoverflow.com/a/12259830/11847654
Currently it's drawn as 1010px wide.
Using
width: 100%
in CSS does not work in this caseclientX
andclientY
will not shrink or expand