Skip to content

Commit

Permalink
feat: update ruler and add drawRuler method
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Jun 2, 2023
1 parent d6ed4f2 commit 20b1182
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/croact-guides/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@scena/dragscroll": "^1.3.0",
"@scena/react-guides": "~0.26.0",
"croact-css-styled": "^1.1.8",
"croact-ruler": "^0.17.0",
"croact-ruler": "^0.18.0",
"css-to-mat": "^1.0.3",
"framework-utils": "^1.1.0",
"gesto": "^1.18.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/preact-guides/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"framework-utils": "^1.1.0",
"gesto": "^1.18.1",
"preact-css-styled": "^1.1.8",
"preact-ruler": "^0.18.0",
"preact-ruler": "^0.19.0",
"react-css-styled": "^1.1.8"
}
}
2 changes: 1 addition & 1 deletion packages/react-guides/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"dependencies": {
"@daybrush/utils": "^1.12.1",
"@scena/dragscroll": "^1.3.0",
"@scena/react-ruler": "^0.18.0",
"@scena/react-ruler": "^0.19.0",
"css-to-mat": "^1.0.3",
"framework-utils": "^1.1.0",
"gesto": "^1.18.1",
Expand Down
8 changes: 7 additions & 1 deletion packages/react-guides/src/react-guides/Guides.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import Ruler, { PROPERTIES as RULER_PROPERTIES, RulerProps } from "@scena/react-ruler";
import Ruler, { DrawRulerOptions, PROPERTIES as RULER_PROPERTIES, RulerProps } from "@scena/react-ruler";
import { ref, refs } from "framework-utils";
import DragScroll from "@scena/dragscroll";
import Gesto, { OnDrag, OnDragEnd, OnDragStart } from "gesto";
Expand Down Expand Up @@ -104,6 +104,12 @@ export default class Guides extends React.PureComponent<GuidesProps, GuidesState
</div>
</GuidesElement>;
}
/**
* Draw ruler
*/
public drawRuler(options: DrawRulerOptions) {
this.ruler.draw(options);
}
public renderGuides() {
const props = this.props;
const {
Expand Down
1 change: 1 addition & 0 deletions packages/react-guides/src/react-guides/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const METHODS = [
"getRulerScrollPos",
"getGuideScrollPos",
"zoomTo",
"drawRuler",
] as const;

export const EVENTS = [
Expand Down
3 changes: 2 additions & 1 deletion packages/react-guides/src/react-guides/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RulerProps } from "@scena/react-ruler/declaration/types";
import { DrawRulerOptions, RulerProps } from "@scena/react-ruler/declaration/types";
import { IObject } from "@daybrush/utils";
import {
OnDragStart as OnGestoDragStart,
Expand Down Expand Up @@ -198,6 +198,7 @@ export interface GuidesInterface {
getGuides(): number[];
scroll(pos: number): void;
scrollGuides(pos: number): void;
drawRuler(options: DrawRulerOptions): void;
loadGuides(guides: number[]): void;
resize(): void;
getElement(): HTMLElement;
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3042,10 +3042,10 @@
dependencies:
"@daybrush/utils" "^1.4.0"

"@scena/react-ruler@^0.18.0", "@scena/react-ruler@~0.18.0":
version "0.18.0"
resolved "https://registry.npmjs.org/@scena/react-ruler/-/react-ruler-0.18.0.tgz#b2d89ddb9b93277712f486c7722d6e0937dbc681"
integrity sha512-mS76YxfNtzjrWlv5HDwwRhsWK+dTjAdGrsDWkuhS9i5io7lBLmEBSCn4bByH28nlHR6N+rAPhH5jjopWmockag==
"@scena/react-ruler@^0.19.0", "@scena/react-ruler@~0.19.0":
version "0.19.0"
resolved "https://registry.npmjs.org/@scena/react-ruler/-/react-ruler-0.19.0.tgz#7e94a3b016e9c3e0bd105455f0939832c80def0e"
integrity sha512-2OEOjLMOptDxdSuEqID2JAljQuYoeoV09MnLjiBeyzJxoUcVjzyBCPwkMbHRKj2Z3WrwztJAFBF+y6yNNM5Lcw==
dependencies:
"@daybrush/utils" "^1.11.0"
framework-utils "^1.1.0"
Expand Down Expand Up @@ -6570,12 +6570,12 @@ croact-css-styled@^1.1.8:
css-styled "~1.0.7"
framework-utils "^1.1.0"

croact-ruler@^0.17.0:
version "0.17.0"
resolved "https://registry.npmjs.org/croact-ruler/-/croact-ruler-0.17.0.tgz#432f0674614094cb1a25ccd63545a31a0c30dc6b"
integrity sha512-2+BYQpPC8deg/DhjjQMuyHwDXRbINZmuFmJakJZnyDXBwFH/6WqF1PfAgNIrI1plZCO27NXyo2K3eXX09UIGAQ==
croact-ruler@^0.18.0:
version "0.18.0"
resolved "https://registry.npmjs.org/croact-ruler/-/croact-ruler-0.18.0.tgz#50850341f6574fe24b26cc32db34fc1c19f5cdc8"
integrity sha512-FZtYH1n3Mpv7VX24y26lAMOVqem+/qRG4a7nBy9pwDeh9Q8UycOQqAdmWxNC1CNh1Pw1k4K28/gRQOyo4r1Zag==
dependencies:
"@scena/react-ruler" "~0.18.0"
"@scena/react-ruler" "~0.19.0"

croact@^1.0.3:
version "1.0.3"
Expand Down Expand Up @@ -15268,12 +15268,12 @@ preact-render-to-string@^3.8.2:
dependencies:
pretty-format "^3.5.1"

preact-ruler@^0.18.0:
version "0.18.0"
resolved "https://registry.npmjs.org/preact-ruler/-/preact-ruler-0.18.0.tgz#29603431c655552215d470d75427f4f996c7ad44"
integrity sha512-+VTw+pgcaz72Ax8OV9up2jJlcLwg2UH1vUTXqIJSPPvwUA53LXk3rRpzHkUlCIhxM8VJpMypMvOcu0B11Wudbw==
preact-ruler@^0.19.0:
version "0.19.0"
resolved "https://registry.npmjs.org/preact-ruler/-/preact-ruler-0.19.0.tgz#faa5abbd4c53e5227b6169f3fe56f09690fa762c"
integrity sha512-mkL7YoROisIgJzP/bnLGba7MgKuJ/VPPBI7OFhqFILW6ew7/4rMIrZW1U0Vu1OZ+FtYUXtQ4ZtK8JTtquUTxUQ==
dependencies:
"@scena/react-ruler" "~0.18.0"
"@scena/react-ruler" "~0.19.0"

preact-transition-group@^1.1.1:
version "1.1.1"
Expand Down

0 comments on commit 20b1182

Please sign in to comment.