-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add plugin support to ngu-flow
- Loading branch information
1 parent
a30c971
commit d8e2fb9
Showing
14 changed files
with
200 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
projects/flow/src/lib/arrangements.spec.ts → ...flow/src/lib/plugins/arrangements.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { FlowPlugin } from '../flow-interface'; | ||
import { FlowComponent } from '../flow.component'; | ||
|
||
export class ScrollIntoView implements FlowPlugin { | ||
data: FlowComponent; | ||
constructor(private id: string) {} | ||
|
||
afterInit(data: FlowComponent): void { | ||
this.data = data; | ||
this.focus(this.id); | ||
} | ||
|
||
focus(id: string) { | ||
const item = this.data.list.find((x) => x.position.id === id); | ||
if (item) { | ||
const { x, y } = item.position; | ||
const { width, height } = item.elRect; | ||
// this.flow.panX = -x * this.flow.scale + this.flow.zRect.width / 2; | ||
if (x + width * this.data.flow.scale > this.data.flow.zRect.width) { | ||
this.data.flow.panX = | ||
-x * this.data.flow.scale + (this.data.flow.zRect.width - width); | ||
} else if ( | ||
this.data.flow.panX + x * this.data.flow.scale < | ||
this.data.flow.zRect.width | ||
) { | ||
this.data.flow.panX = -x * this.data.flow.scale; | ||
} | ||
this.data.flow.panY = | ||
-y * this.data.flow.scale + (this.data.flow.zRect.height - height) / 2; | ||
this.data.updateZoomContainer(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.