mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
moved penMode from state to context
This commit is contained in:
parent
ceb43ed8fb
commit
cf8024bdc0
6 changed files with 9 additions and 8 deletions
|
@ -258,6 +258,7 @@ import {
|
|||
const defaultDeviceTypeContext: DeviceType = {
|
||||
isMobile: false,
|
||||
isTouchScreen: false,
|
||||
penDetected: false,
|
||||
};
|
||||
const DeviceTypeContext = React.createContext(defaultDeviceTypeContext);
|
||||
export const useDeviceType = () => useContext(DeviceTypeContext);
|
||||
|
@ -295,6 +296,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
deviceType: DeviceType = {
|
||||
isMobile: false,
|
||||
isTouchScreen: false,
|
||||
penDetected: false,
|
||||
};
|
||||
detachIsMobileMqHandler?: () => void;
|
||||
|
||||
|
@ -2863,11 +2865,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||
|
||||
//fires only once, if pen is detected, penMode is enabled
|
||||
//the user can disable this by toggling the penMode button
|
||||
if (!this.state.penDetected && event.pointerType === "pen") {
|
||||
if (!this.deviceType.penDetected && event.pointerType === "pen") {
|
||||
this.deviceType = updateObject(this.deviceType, { penDetected: true });
|
||||
this.setState((prevState) => {
|
||||
return {
|
||||
penMode: true,
|
||||
penDetected: true,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue