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

On window move #103

Merged
merged 3 commits into from Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "@origam/components",
"main": "dist/index.js",
"version": "1.5.4",
"version": "1.6.0",
"license": "GPL-3.0",
"files": [
"dist",
Expand All @@ -10,7 +10,7 @@
"devDependencies": {
"@origam/styles": "^2.0.2",
"@types/lodash": "^4.14.178",
"@types/react": "^17.0.39",
"@types/react": "^17.0.40",
"@types/react-dom": "^17.0.11",
"@types/react-measure": "^2.0.8",
"@types/uuid": "^8.3.4",
Expand All @@ -34,15 +34,16 @@
},
"peerDependencies": {
"mobx": "5",
"mobx-react": "6",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"mobx-react": "6"
},
"resolutions": {
"@types/react": "17.0.40"
},
"scripts": {
"build": "rollup -c",
"start": "rollup -c -w"
},
"dependencies": {
"react-inlinesvg": "^2.3.0"
"react-inlinesvg": "^3.0.1"
}
}
30 changes: 28 additions & 2 deletions src/components/Dialogs/Dialog.tsx
Expand Up @@ -38,11 +38,31 @@ export class ModalWindow extends React.Component<{
fullScreen?: boolean;
topPosiotionProc?: number;
onKeyDown?: (event: any) => void;
onWindowMove?: (top: number, left: number)=>void;
}> {
@observable top: number = window.screen.height + 50;
@observable left: number = window.screen.width + 50;
@observable _top: number = window.screen.height + 50;
set top(value: number){
this._top = value;
if(this.props.onWindowMove && this.reportingWindowMove){
this.props.onWindowMove(this._top, this._left);
}
}
get top(){
return this._top;
}
@observable _left: number = window.screen.width + 50;
set left(value: number){
this._left = value;
if(this.props.onWindowMove && this.reportingWindowMove){
this.props.onWindowMove(this._top, this._left);
}
}
get left(){
return this._left;
}
@observable isDragging = false;

reportingWindowMove = false;
dragStartMouseX = 0;
dragStartMouseY = 0;
dragStartPosX = 0;
Expand All @@ -64,6 +84,12 @@ export class ModalWindow extends React.Component<{
}

@action.bound handleTitleMouseDown(event: any) {
if(!this.reportingWindowMove){
this.reportingWindowMove = true;
if(this.props.onWindowMove){
this.props.onWindowMove(this._top, this._left);
}
}
window.addEventListener("mousemove", this.handleWindowMouseMove);
window.addEventListener("mouseup", this.handleWindowMouseUp);
this.isDragging = true;
Expand Down