= {}) {
38 | let selfElement!: HTMLElement;
39 |
40 | if (options.warpSelf) {
41 | delete options.warpSelf;
42 | this._warp = true;
43 | selfElement = parentElement;
44 | } else {
45 | selfElement = document.createElement("canvas");
46 | parentElement.appendChild(selfElement);
47 | }
48 | renderSelf(
49 | ,
51 | selfElement,
52 | );
53 | }
54 | public scroll(scrollPos: number) {
55 | this.getRuler().scroll(scrollPos);
56 | }
57 | public resize() {
58 | this.getRuler().resize();
59 | }
60 | public getScrollPos() {
61 | return this.getRuler().getScrollPos();
62 | }
63 | public draw(options: DrawRulerOptions) {
64 | this.getRuler().draw(options);
65 | }
66 | /**
67 | * Remove Ruler
68 | */
69 | public destroy() {
70 | const selfElement = this.selfElement!;
71 |
72 | renderSelf(
73 | null,
74 | selfElement!,
75 | this.containerProvider,
76 | );
77 | if (!this._warp) {
78 | selfElement?.parentElement?.removeChild(selfElement);
79 | }
80 | this.selfElement = null;
81 | this.innerRuler = null;
82 | }
83 | private getRuler() {
84 | return this.innerRuler.ruler;
85 | }
86 | }
87 |
88 | export default Ruler;
89 |
--------------------------------------------------------------------------------
/packages/react-ruler/src/demo/App.css:
--------------------------------------------------------------------------------
1 | html,body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | overscroll-behavior: none;
6 | }
7 | html,
8 | body,
9 | #root {
10 | position: relative;
11 | height: 100%;
12 | margin: 0;
13 | padding: 0;
14 | }
15 |
16 | .page1 {
17 | position: relative;
18 | min-height: 300px;
19 | height: 100%;
20 | text-align: center;
21 | }
22 | .page1 .startAnimation {
23 | will-change: transform;
24 | -webkit-backface-visibility: hidden;
25 | -webkit-perspective: 1000;
26 | }
27 | .page {
28 | font-size: 0;
29 | }
30 | .container {
31 | position: relative;
32 | width: 100%;
33 | height: 100%;
34 | min-width: 300px;
35 | min-height: 600px;
36 | }
37 | .page1 .logo {
38 | position: absolute;
39 | top: 50%;
40 | left: 50%;
41 | transform: translate(-50%, -50%);
42 | width: 300px;
43 | height: 300px;
44 | overflow: hidden;
45 | }
46 |
47 | .logo .clapper {
48 | position: absolute;
49 | width: 200px;
50 | height: 110px;
51 | top: 50%;
52 | left: 50%;
53 | transform: translate(-50%, -50%) translateY(30px);
54 | }
55 |
56 | .logo .svg_circle {
57 | position: absolute;
58 | }
59 |
60 | .logo svg circle {
61 | stroke-dasharray: 0 1000;
62 | stroke-dashoffset: 0;
63 | }
64 |
65 | .logo .play-btn {
66 | width: 40px;
67 | position: absolute;
68 | top: 50%;
69 | left: 50%;
70 | transform: translate(-50%, -50%) translate(5px);
71 | transition: width ease 0.2s;
72 | z-index: 2;
73 | }
74 |
75 | .logo .background {
76 | position: absolute;
77 | top: 50%;
78 | left: 50%;
79 | width: 200px;
80 | height: 110px;
81 | border-radius: 5px;
82 | transform: translate(-50%, -50%);
83 | }
84 |
85 | .play-circle {
86 | position: absolute;
87 | top: 50%;
88 | left: 50%;
89 | width: 70px;
90 | height: 70px;
91 | background: #fff;
92 | border-radius: 50%;
93 | transform: translate(-50%, -50%);
94 | z-index: 1;
95 | }
96 |
97 | .clapper .stick {
98 | position: absolute;
99 | box-sizing: border-box;
100 | width: 200px;
101 | height: 32px;
102 | font-size: 0;
103 | overflow: hidden;
104 | white-space: nowrap;
105 | padding: 5px 8px;
106 | text-align: center;
107 | background: #333;
108 | }
109 |
110 | .clapper .stick1 {
111 | transform-origin: 0% 100%;
112 | border-radius: 5px 5px 0px 0px;
113 | top: -60px;
114 | }
115 | .clapper .stick2 {
116 | top: -30px;
117 | }
118 |
119 | .clapper .rect {
120 | position: relative;
121 | display: inline-block;
122 | height: 100%;
123 | width: 20px;
124 | background: white;
125 | vertical-align: top;
126 | margin: 0px 5px 0px;
127 | border-radius: 5px;
128 | }
129 |
130 | .clapper .stick1 .rect {
131 | transform: skew(15deg);
132 | }
133 |
134 | .clapper .stick2 .rect {
135 | transform: skew(-15deg);
136 | }
137 | .logo .bottom {
138 | position: absolute;
139 | top: 0;
140 | left: 0;
141 | width: 100%;
142 | height: 100%;
143 | background: #333;
144 | box-sizing: border-box;
145 | border-radius: 0px 0px 5px 5px;
146 | }
147 | .logo .shadow {
148 | position: absolute;
149 | box-sizing: border-box;
150 | background: #D6D6D6;
151 | margin-top: 10px;
152 | margin-left: 10px;
153 | z-index: -1;
154 | }
155 |
156 | .dash-line {
157 | position: absolute;
158 | width: 0px;
159 | height: 100%;
160 | top: 0;
161 | left: 40px;
162 | border-left: 3px dashed #4af;
163 | transform-origin: 110px 50%;
164 | }
165 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ruler-root",
3 | "private": true,
4 | "description": "A Vanilla Ruler component that can draw grids and scroll infinitely.",
5 | "keywords": [
6 | "scene",
7 | "scenejs",
8 | "scene.js",
9 | "scena",
10 | "ruler",
11 | "scroller"
12 | ],
13 | "repository": {
14 | "type": "git",
15 | "url": "git+https://github.com/daybrush/ruler.git"
16 | },
17 | "author": "Daybrush",
18 | "license": "MIT",
19 | "bugs": {
20 | "url": "https://github.com/daybrush/ruler/issues"
21 | },
22 | "homepage": "https://github.com/daybrush/ruler#readme",
23 | "scripts": {
24 | "build": "npm run build --prefix ./packages/ruler",
25 | "packages:update": "lerna-helper version && npm run update-type-consts",
26 | "update-type-consts": "node ./config/update-type-consts.js",
27 | "packages:build": "npm run build --prefix packages/react-ruler && npm run update-type-consts && lerna run build --ignore ngx-ruler --ignore @scena/react-ruler",
28 | "packages:publish": "lerna-helper publish --ignore ngx-ruler --commit 'chore: publish packages'",
29 | "demo:build": "npm run packages:build && npm run doc",
30 | "changelog": "lerna-helper changelog --type all --base @scena/ruler",
31 | "changelog:root": "lerna-helper changelog --type root --base @scena/ruler",
32 | "doc": "rm -rf ./doc && jsdoc -c jsdoc.json",
33 | "predeploy": "lerna-helper deploy --base @scena/ruler --pre",
34 | "deploy": "lerna-helper deploy --base @scena/ruler",
35 | "release": "lerna-helper release --base @scena/ruler"
36 | },
37 | "devDependencies": {
38 | "@daybrush/jsdoc": "^0.4.3",
39 | "@daybrush/release": "^0.7.0",
40 | "cpx": "1.5.0",
41 | "daybrush-jsdoc-template": "^1.10.0",
42 | "gh-pages": "^2.0.1",
43 | "intercept-stdout": "0.1.2",
44 | "lerna": "^4.0.0",
45 | "lerna-changelog": "2.2.0",
46 | "typescript": "^4.5.0 <4.6.0"
47 | },
48 | "workspaces": {
49 | "nohoist": [
50 | "**/@daybrush/builder",
51 | "**/@daybrush/builder/**",
52 | "**/rollup-plugin-vue",
53 | "**/rollup-plugin-vue/**",
54 | "**/karma",
55 | "**/karma/**",
56 | "**/karma-*",
57 | "**/karma-*/**",
58 | "**/@tyoes/chai",
59 | "**/@tyoes/chai/**",
60 | "**/@types/karma-chai",
61 | "**/@types/karma-chai/**",
62 | "**/@types/mocha",
63 | "**/@types/mocha/**",
64 | "**/@vue/*",
65 | "**/@vue/*/**",
66 | "**/vue",
67 | "**/vue/**"
68 | ],
69 | "packages": [
70 | "packages/*",
71 | "packages/ngx-ruler/projects/ngx-ruler"
72 | ]
73 | },
74 | "resolutions": {
75 | "@daybrush/utils": "^1.11.0",
76 | "@types/react": "^16.9.17",
77 | "typescript": "^4.5.0 <4.6.0",
78 | "@egjs/agent": "^2.2.1",
79 | "@egjs/children-differ": "^1.0.1",
80 | "@scena/dragscroll": "^1.2.0",
81 | "@scena/matrix": "^1.1.1",
82 | "css-to-mat": "^1.0.3",
83 | "framework-utils": "^1.1.0",
84 | "gesto": "^1.12.2",
85 | "overlap-area": "^1.1.0",
86 | "tslib": "^2.3.0"
87 | },
88 | "overrides": {
89 | "@daybrush/utils": "^1.11.0",
90 | "@types/react": "^16.9.17",
91 | "typescript": "^4.5.0 <4.6.0",
92 | "@egjs/agent": "^2.2.1",
93 | "@egjs/children-differ": "^1.0.1",
94 | "@scena/dragscroll": "^1.2.0",
95 | "@scena/matrix": "^1.1.1",
96 | "css-to-mat": "^1.0.3",
97 | "framework-utils": "^1.1.0",
98 | "gesto": "^1.12.2",
99 | "overlap-area": "^1.1.0",
100 | "tslib": "^2.3.0"
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/packages/ngx-ruler/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "ngx-ruler-project": {
7 | "projectType": "application",
8 | "schematics": {
9 | "@schematics/angular:application": {
10 | "strict": true
11 | }
12 | },
13 | "root": "",
14 | "sourceRoot": "src",
15 | "prefix": "app",
16 | "architect": {
17 | "build": {
18 | "builder": "@angular-devkit/build-angular:browser",
19 | "options": {
20 | "outputPath": "dist/ngx-ruler-project",
21 | "index": "src/index.html",
22 | "main": "src/main.ts",
23 | "polyfills": "src/polyfills.ts",
24 | "tsConfig": "tsconfig.app.json",
25 | "assets": [
26 | "src/favicon.ico",
27 | "src/assets"
28 | ],
29 | "styles": [
30 | "src/styles.css"
31 | ],
32 | "scripts": []
33 | },
34 | "configurations": {
35 | "production": {
36 | "budgets": [
37 | {
38 | "type": "initial",
39 | "maximumWarning": "500kb",
40 | "maximumError": "1mb"
41 | },
42 | {
43 | "type": "anyComponentStyle",
44 | "maximumWarning": "2kb",
45 | "maximumError": "4kb"
46 | }
47 | ],
48 | "fileReplacements": [
49 | {
50 | "replace": "src/environments/environment.ts",
51 | "with": "src/environments/environment.prod.ts"
52 | }
53 | ],
54 | "outputHashing": "all"
55 | },
56 | "development": {
57 | "buildOptimizer": false,
58 | "optimization": false,
59 | "vendorChunk": true,
60 | "extractLicenses": false,
61 | "sourceMap": true,
62 | "namedChunks": true
63 | }
64 | },
65 | "defaultConfiguration": "production"
66 | },
67 | "serve": {
68 | "builder": "@angular-devkit/build-angular:dev-server",
69 | "configurations": {
70 | "production": {
71 | "browserTarget": "ngx-ruler-project:build:production"
72 | },
73 | "development": {
74 | "browserTarget": "ngx-ruler-project:build:development"
75 | }
76 | },
77 | "defaultConfiguration": "development"
78 | },
79 | "extract-i18n": {
80 | "builder": "@angular-devkit/build-angular:extract-i18n",
81 | "options": {
82 | "browserTarget": "ngx-ruler-project:build"
83 | }
84 | },
85 | "test": {
86 | "builder": "@angular-devkit/build-angular:karma",
87 | "options": {
88 | "main": "src/test.ts",
89 | "polyfills": "src/polyfills.ts",
90 | "tsConfig": "tsconfig.spec.json",
91 | "karmaConfig": "karma.conf.js",
92 | "assets": [
93 | "src/favicon.ico",
94 | "src/assets"
95 | ],
96 | "styles": [
97 | "src/styles.css"
98 | ],
99 | "scripts": []
100 | }
101 | }
102 | }
103 | },
104 | "ngx-ruler": {
105 | "projectType": "library",
106 | "root": "projects/ngx-ruler",
107 | "sourceRoot": "projects/ngx-ruler/src",
108 | "prefix": "lib",
109 | "architect": {
110 | "build": {
111 | "builder": "@angular-devkit/build-angular:ng-packagr",
112 | "options": {
113 | "project": "projects/ngx-ruler/ng-package.json"
114 | },
115 | "configurations": {
116 | "production": {
117 | "tsConfig": "projects/ngx-ruler/tsconfig.lib.prod.json"
118 | },
119 | "development": {
120 | "tsConfig": "projects/ngx-ruler/tsconfig.lib.json"
121 | }
122 | },
123 | "defaultConfiguration": "production"
124 | },
125 | "test": {
126 | "builder": "@angular-devkit/build-angular:karma",
127 | "options": {
128 | "main": "projects/ngx-ruler/src/test.ts",
129 | "tsConfig": "projects/ngx-ruler/tsconfig.spec.json",
130 | "karmaConfig": "projects/ngx-ruler/karma.conf.js"
131 | }
132 | }
133 | }
134 | }
135 | },
136 | "defaultProject": "ngx-ruler-project"
137 | }
138 |
--------------------------------------------------------------------------------
/packages/svelte-ruler/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Svelte Ruler
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
18 |
19 | A Svelte Ruler component that can draw grids and scroll infinitely.
20 |
21 | Demo /
22 | API /
23 | Guides /
24 | Main Project
25 |
26 |
27 |
28 | ## ⚙️ Installation
29 | ### npm
30 | ```sh
31 | $ npm i svelte-ruler
32 | ```
33 |
34 | ## 🚀 How to use
35 | ```html
36 |
50 |
51 |
52 |
53 |
54 | ```
55 |
56 |
57 |
58 | ## ⚙️ Developments
59 | ### `npm run dev`
60 |
61 | Runs the app in the development mode.
62 | Open [http://localhost:5000](http://localhost:5000) to view it in the browser.
63 |
64 | The page will reload if you make edits.
65 | You will also see any lint errors in the console.
66 |
67 |
68 |
69 | ## ⭐️ Show Your Support
70 | Please give a ⭐️ if this project helped you!
71 |
72 | ## 👏 Contributing
73 |
74 | If you have any questions or requests or want to contribute to `ruler` or other packages, please write the [issue](https://github.com/daybrush/ruler/issues) or give me a Pull Request freely.
75 |
76 | ## 🐞 Bug Report
77 |
78 | If you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/ruler/issues) on GitHub.
79 |
80 |
81 | ## 📝 License
82 |
83 | This project is [MIT](https://github.com/daybrush/ruler/blob/master/LICENSE) licensed.
84 |
85 | ```
86 | MIT License
87 |
88 | Copyright (c) 2019 Daybrush
89 |
90 | Permission is hereby granted, free of charge, to any person obtaining a copy
91 | of this software and associated documentation files (the "Software"), to deal
92 | in the Software without restriction, including without limitation the rights
93 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
94 | copies of the Software, and to permit persons to whom the Software is
95 | furnished to do so, subject to the following conditions:
96 |
97 | The above copyright notice and this permission notice shall be included in all
98 | copies or substantial portions of the Software.
99 |
100 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
101 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
102 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
103 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
104 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
105 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
106 | SOFTWARE.
107 | ```
108 |
--------------------------------------------------------------------------------
/packages/vue-ruler/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Vue Ruler
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
18 |
19 | A Vue Ruler component that can draw grids and scroll infinitely.
20 |
21 | Demo /
22 | API /
23 | Guides /
24 | Main Project
25 |
26 |
27 |
28 | ## ⚙️ Installation
29 | ### npm
30 | ```sh
31 | $ npm i @scena/vue-ruler
32 | ```
33 |
34 | ## 🚀 How to use
35 | ```html
36 |
37 |
38 |
39 |
40 |
41 |
56 | ```
57 |
58 |
59 | ## ⚙️ Developments
60 | ### `npm run serve`
61 |
62 | Runs the app in the development mode.
63 | Open [http://localhost:8080](http://localhost:8080) to view it in the browser.
64 |
65 | The page will reload if you make edits.
66 | You will also see any lint errors in the console.
67 |
68 |
69 |
70 | ## ⭐️ Show Your Support
71 | Please give a ⭐️ if this project helped you!
72 |
73 | ## 👏 Contributing
74 |
75 | If you have any questions or requests or want to contribute to `ruler` or other packages, please write the [issue](https://github.com/daybrush/ruler/issues) or give me a Pull Request freely.
76 |
77 | ## 🐞 Bug Report
78 |
79 | If you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/ruler/issues) on GitHub.
80 |
81 |
82 | ## 📝 License
83 |
84 | This project is [MIT](https://github.com/daybrush/ruler/blob/master/LICENSE) licensed.
85 |
86 | ```
87 | MIT License
88 |
89 | Copyright (c) 2019 Daybrush
90 |
91 | Permission is hereby granted, free of charge, to any person obtaining a copy
92 | of this software and associated documentation files (the "Software"), to deal
93 | in the Software without restriction, including without limitation the rights
94 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
95 | copies of the Software, and to permit persons to whom the Software is
96 | furnished to do so, subject to the following conditions:
97 |
98 | The above copyright notice and this permission notice shall be included in all
99 | copies or substantial portions of the Software.
100 |
101 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
104 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107 | SOFTWARE.
108 | ```
109 |
110 |
--------------------------------------------------------------------------------
/packages/preact-ruler/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Preact Ruler
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
18 |
19 | A Preact Ruler component that can draw grids and scroll infinitely.
20 |
21 | Demo /
22 | API /
23 | Guides /
24 | Main Project
25 |
26 |
27 |
28 | ## ⚙️ Installation
29 | ### npm
30 | ```sh
31 | $ npm i preact-ruler
32 | ```
33 |
34 | ## 🚀 How to use
35 | ```tsx
36 |
37 | import * as Peact from "preact";
38 | import Ruler from "preact-ruler";
39 |
40 | export default class App extends Peact.Component {
41 | render() {
42 | return ( {
43 | this.ruler = e;
44 | }}/>);
45 | }
46 | componentDidMount() {
47 | this.ruler.resize();
48 |
49 | window.addEventListener("resize", () => {
50 | this.ruler.resize();
51 | });
52 | }
53 | }
54 |
55 | export interface RulerInterface {
56 | scroll(scrollPos: number): any;
57 | resize(): any;
58 | }
59 | export interface RulerProps {
60 | type?: "horizontal" | "vertical";
61 | width?: number;
62 | height?: number;
63 | unit?: number;
64 | zoom?: number;
65 | direction?: "start" | "end";
66 | style?: IObject;
67 | backgroundColor?: string;
68 | lineColor?: string;
69 | textColor?: string;
70 | textFormat?: (scale: number) => string;
71 | }
72 |
73 | ```
74 |
75 |
76 |
77 | ## ⚙️ Developments
78 | ### `npm start`
79 |
80 | Runs the app in the development mode.
81 | Open `demo/index.html` file.
82 |
83 |
84 | ## ⭐️ Show Your Support
85 | Please give a ⭐️ if this project helped you!
86 |
87 | ## 👏 Contributing
88 |
89 | If you have any questions or requests or want to contribute to `ruler` or other packages, please write the [issue](https://github.com/daybrush/ruler/issues) or give me a Pull Request freely.
90 |
91 | ## 🐞 Bug Report
92 |
93 | If you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/ruler/issues) on GitHub.
94 |
95 |
96 | ## 📝 License
97 |
98 | This project is [MIT](https://github.com/daybrush/ruler/blob/master/LICENSE) licensed.
99 |
100 | ```
101 | MIT License
102 |
103 | Copyright (c) 2019 Daybrush
104 |
105 | Permission is hereby granted, free of charge, to any person obtaining a copy
106 | of this software and associated documentation files (the "Software"), to deal
107 | in the Software without restriction, including without limitation the rights
108 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
109 | copies of the Software, and to permit persons to whom the Software is
110 | furnished to do so, subject to the following conditions:
111 |
112 | The above copyright notice and this permission notice shall be included in all
113 | copies or substantial portions of the Software.
114 |
115 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
116 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
117 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
118 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
119 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
120 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
121 | SOFTWARE.
122 | ```
123 |
--------------------------------------------------------------------------------
/packages/ruler/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Ruler
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
17 |
18 | A Ruler component that can draw grids and scroll infinitely.
19 |
20 | Demo /
21 | API /
22 | Guides /
23 | Main Project
24 |
25 |
26 |
27 | ## ⚙️ Installation
28 | ### npm
29 | ```sh
30 | $ npm i @scena/ruler
31 | ```
32 |
33 | ### scripts
34 | ```html
35 |
36 | ```
37 |
38 |
39 | ## 🚀 How to use
40 | ```ts
41 | import Ruler from "@scena/ruler";
42 |
43 | const ruler = new Ruler(document.body, {
44 | type: "horizontal",
45 | });
46 |
47 |
48 | window.addEventListener("resize", () => {
49 | ruler.resize();
50 | });
51 |
52 | export interface RulerInterface {
53 | scroll(scrollPos: number): any;
54 | resize(): any;
55 | }
56 | export interface RulerProps {
57 | type?: "horizontal" | "vertical";
58 | width?: number;
59 | height?: number;
60 | unit?: number;
61 | zoom?: number;
62 | direction?: "start" | "end";
63 | style?: IObject;
64 | backgroundColor?: string;
65 | lineColor?: string;
66 | textColor?: string;
67 | textFormat?: (scale: number) => string;
68 | }
69 | ```
70 | ### Ruler Units
71 |
72 | The default unit is px, and a line is drawn every 50px. If you want to use a different unit instead of the px unit, use it like this:
73 |
74 | * 1px (Default)
75 | * zoom: 1
76 | * unit: 50 (every 50px)
77 | * 1cm = 37.7952px
78 | * zoom: 37.7952
79 | * unit: 1 (every 1cm)
80 | * 1in = 96px = 2.54cm
81 | * zoom: 96
82 | * unit: 1 (every 1in)
83 |
84 | ## ⭐️ Show Your Support
85 | Please give a ⭐️ if this project helped you!
86 |
87 | ## 👏 Contributing
88 |
89 | If you have any questions or requests or want to contribute to `ruler` or other packages, please write the [issue](https://github.com/daybrush/ruler/issues) or give me a Pull Request freely.
90 |
91 | ## 🐞 Bug Report
92 |
93 | If you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/ruler/issues) on GitHub.
94 |
95 |
96 | ## 📝 License
97 |
98 | This project is [MIT](https://github.com/daybrush/ruler/blob/master/LICENSE) licensed.
99 |
100 | ```
101 | MIT License
102 |
103 | Copyright (c) 2019 Daybrush
104 |
105 | Permission is hereby granted, free of charge, to any person obtaining a copy
106 | of this software and associated documentation files (the "Software"), to deal
107 | in the Software without restriction, including without limitation the rights
108 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
109 | copies of the Software, and to permit persons to whom the Software is
110 | furnished to do so, subject to the following conditions:
111 |
112 | The above copyright notice and this permission notice shall be included in all
113 | copies or substantial portions of the Software.
114 |
115 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
116 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
117 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
118 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
119 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
120 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
121 | SOFTWARE.
122 | ```
123 |
--------------------------------------------------------------------------------
/packages/ngx-ruler/projects/ngx-ruler/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | ## [0.19.0](https://github.com/daybrush/ruler/compare/ngx-ruler@0.18.0...ngx-ruler@0.19.0) (2023-06-02)
7 |
8 |
9 | ### :mega: Other
10 |
11 | * publish packages ([6cb44f9](https://github.com/daybrush/ruler/commit/6cb44f944747a2ff008011bae638fa52cc860c93))
12 |
13 |
14 |
15 | ## [0.18.0](https://github.com/daybrush/ruler/compare/ngx-ruler@0.17.6...ngx-ruler@0.18.0) (2023-06-01)
16 |
17 |
18 | ### :mega: Other
19 |
20 | * publish packages ([2628b3d](https://github.com/daybrush/ruler/commit/2628b3db856e066d8ede8eaca3281de61c10c27b))
21 |
22 |
23 |
24 | ## [0.17.6](https://github.com/daybrush/ruler/compare/ngx-ruler@0.17.5...ngx-ruler@0.17.6) (2023-05-15)
25 |
26 |
27 | ### :mega: Other
28 |
29 | * update croact version ([852caef](https://github.com/daybrush/ruler/commit/852caef635a0cacf95b4702cd4c72fb6cac516c2))
30 |
31 |
32 |
33 | ## [0.17.5](https://github.com/daybrush/ruler/compare/ngx-ruler@0.17.3...ngx-ruler@0.17.5) (2023-05-15)
34 |
35 |
36 | ### :bug: Bug Fix
37 |
38 | * update dependency modules ([e2f4602](https://github.com/daybrush/ruler/commit/e2f4602432d64f316a2c41bb9421b7665f72d7f6))
39 |
40 |
41 | ### :mega: Other
42 |
43 | * update croact veresion ([f252b98](https://github.com/daybrush/ruler/commit/f252b9872924ad02e3d1efdf012bf6c55933408b))
44 |
45 |
46 |
47 | ## [0.17.3](https://github.com/daybrush/ruler/compare/ngx-ruler@0.17.2...ngx-ruler@0.17.3) (2023-04-11)
48 |
49 |
50 | ### :bug: Bug Fix
51 |
52 | * fix createElement canvas #40 ([8fe015c](https://github.com/daybrush/ruler/commit/8fe015ce7c6258c718f74747b6bc0431fcd22842))
53 |
54 |
55 |
56 | ## [0.17.2](https://github.com/daybrush/ruler/compare/ngx-ruler@0.17.1...ngx-ruler@0.17.2) (2023-04-10)
57 |
58 |
59 | ### :mega: Other
60 |
61 | * update packages ([c9ffdbb](https://github.com/daybrush/ruler/commit/c9ffdbb6524f80ed5213ff778dafa62f4a1f9353))
62 |
63 |
64 |
65 | ## [0.17.1](https://github.com/daybrush/ruler/compare/ngx-ruler@0.17.0...ngx-ruler@0.17.1) (2023-04-08)
66 |
67 |
68 | ### :mega: Other
69 |
70 | * publish packages ([2c6bfa0](https://github.com/daybrush/ruler/commit/2c6bfa0cda3df3a361f48163d9a7f1ada6cccb59))
71 |
72 |
73 |
74 | ## [0.17.0](https://github.com/daybrush/ruler/compare/ngx-ruler@0.16.0...ngx-ruler@0.17.0) (2023-04-08)
75 |
76 |
77 | ### :mega: Other
78 |
79 | * publish packages ([65c88e8](https://github.com/daybrush/ruler/commit/65c88e87316850f2cd0cd56a1c4a7f9d1131355b))
80 |
81 |
82 |
83 | ## [0.16.0](https://github.com/daybrush/ruler/compare/ngx-ruler@0.15.0...ngx-ruler@0.16.0) (2023-04-06)
84 |
85 |
86 | ### :rocket: New Features
87 |
88 | * add croact-ruler ([2d0361e](https://github.com/daybrush/ruler/commit/2d0361e403c0b51f135558add86296a509e3ec9b))
89 |
90 |
91 | ### :mega: Other
92 |
93 | * publish packages ([9775d43](https://github.com/daybrush/ruler/commit/9775d43ce6b04033141c394aa8c7ca3288238588))
94 |
95 |
96 |
97 | ## [0.15.0](https://github.com/daybrush/ruler/compare/ngx-ruler@0.14.2...ngx-ruler@0.15.0) (2023-03-04)
98 |
99 |
100 | ### :mega: Other
101 |
102 | * publish packages ([80d6f11](https://github.com/daybrush/ruler/commit/80d6f1176e755cce1b4bcc044b4e6574b8118c01))
103 |
104 |
105 |
106 | ## [0.14.2](https://github.com/daybrush/ruler/compare/ngx-ruler@0.14.1...ngx-ruler@0.14.2) (2023-01-27)
107 |
108 |
109 | ### :mega: Other
110 |
111 | * publish packages ([c9e29b5](https://github.com/daybrush/ruler/commit/c9e29b51d433abd63c4b684cab25c5319a0c4273))
112 |
113 |
114 |
115 | ## [0.14.1](https://github.com/daybrush/ruler/compare/ngx-ruler@0.14.0...ngx-ruler@0.14.1) (2023-01-20)
116 |
117 |
118 | ### :mega: Other
119 |
120 | * publish packages ([2d2d96a](https://github.com/daybrush/ruler/commit/2d2d96ac218d45278ebfecdd52424a60a2da1ec9))
121 |
122 |
123 |
124 | ## [0.14.0](https://github.com/daybrush/ruler/compare/ngx-ruler@0.13.0...ngx-ruler@0.14.0) (2023-01-20)
125 |
126 |
127 | ### :mega: Other
128 |
129 | * publish packages ([b7f8d2a](https://github.com/daybrush/ruler/commit/b7f8d2a3041202dd89c3da14a7e93cd6ace206bb))
130 |
131 |
132 |
133 | ## [0.13.0](https://github.com/daybrush/ruler/compare/ngx-ruler@0.12.2...ngx-ruler@0.13.0) (2023-01-12)
134 |
135 |
136 | ### :mega: Other
137 |
138 | * publish packages ([6e41e5f](https://github.com/daybrush/ruler/commit/6e41e5f910f84f68b8db80b493a8c683ab755381))
139 |
140 |
141 |
142 | ## [0.12.2](https://github.com/daybrush/ruler/compare/ngx-ruler@0.12.0...ngx-ruler@0.12.2) (2022-11-12)
143 |
144 |
145 | ### :mega: Other
146 |
147 | * publish packages ([3334cf1](https://github.com/daybrush/ruler/commit/3334cf1ad0f2bdd66d4a1a6fc26202f026077671))
148 | * publish packages ([4ceff62](https://github.com/daybrush/ruler/commit/4ceff62e5224779578e61a4e3b0362f6597feecf))
149 |
150 |
151 |
152 | ## [0.12.0](https://github.com/daybrush/ruler/compare/ngx-ruler@0.11.0...ngx-ruler@0.12.0) (2022-11-06)
153 |
154 |
155 | ### :mega: Other
156 |
157 | * publish packages ([de112ef](https://github.com/daybrush/ruler/commit/de112ef49f2b4063a0b8e810abff0d646da5c3d1))
158 |
159 |
160 |
161 | ## [0.11.0](https://github.com/daybrush/ruler/compare/ngx-ruler@0.10.0...ngx-ruler@0.11.0) (2022-09-21)
162 |
163 |
164 | ### :mega: Other
165 |
166 | * publish packages ([9dc9493](https://github.com/daybrush/ruler/commit/9dc9493020206310eb807d7c6d52e9b683f23723))
167 |
--------------------------------------------------------------------------------
/packages/react-ruler/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | React Ruler
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
18 |
19 | A React Ruler component that can draw grids and scroll infinitely.
20 |
21 | Demo /
22 | API /
23 | Guides /
24 | Main Project
25 |
26 |
27 |
28 | ## ⚙️ Installation
29 | ### npm
30 | ```sh
31 | $ npm i @scena/react-ruler
32 | ```
33 |
34 | ## 🚀 How to use
35 | ```tsx
36 |
37 | import * as React from "react";
38 | import Ruler from "@scena/react-ruler";
39 |
40 | export default class App extends React.Component {
41 | render() {
42 | return ( {
43 | this.ruler = e;
44 | }}/>);
45 | }
46 | componentDidMount() {
47 | this.ruler.resize();
48 |
49 | window.addEventListener("resize", () => {
50 | this.ruler.resize();
51 | });
52 | }
53 | }
54 |
55 | export interface RulerInterface {
56 | scroll(scrollPos: number): any;
57 | resize(): any;
58 | }
59 | export interface RulerProps {
60 | type?: "horizontal" | "vertical";
61 | width?: number;
62 | height?: number;
63 | unit?: number;
64 | zoom?: number;
65 | direction?: "start" | "end";
66 | style?: IObject;
67 | backgroundColor?: string;
68 | lineColor?: string;
69 | textColor?: string;
70 | textFormat?: (scale: number) => string;
71 | }
72 |
73 |
74 | ```
75 |
76 |
77 |
78 | ## ⚙️ Developments
79 | ### `npm run start`
80 |
81 | Runs the app in the development mode.
82 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
83 |
84 | The page will reload if you make edits.
85 | You will also see any lint errors in the console.
86 |
87 |
88 |
89 | ## ⭐️ Show Your Support
90 | Please give a ⭐️ if this project helped you!
91 |
92 | ## 👏 Contributing
93 |
94 | If you have any questions or requests or want to contribute to `ruler` or other packages, please write the [issue](https://github.com/daybrush/ruler/issues) or give me a Pull Request freely.
95 |
96 | ## 🐞 Bug Report
97 |
98 | If you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/ruler/issues) on GitHub.
99 |
100 |
101 | ## 📝 License
102 |
103 | This project is [MIT](https://github.com/daybrush/ruler/blob/master/LICENSE) licensed.
104 |
105 | ```
106 | MIT License
107 |
108 | Copyright (c) 2019 Daybrush
109 |
110 | Permission is hereby granted, free of charge, to any person obtaining a copy
111 | of this software and associated documentation files (the "Software"), to deal
112 | in the Software without restriction, including without limitation the rights
113 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
114 | copies of the Software, and to permit persons to whom the Software is
115 | furnished to do so, subject to the following conditions:
116 |
117 | The above copyright notice and this permission notice shall be included in all
118 | copies or substantial portions of the Software.
119 |
120 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
121 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
122 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
123 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
124 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
125 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
126 | SOFTWARE.
127 | ```
128 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Ruler
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
17 |
18 | A Ruler component that can draw grids and scroll infinitely.
19 |
20 | Demo /
21 | API /
22 | Guides /
23 | Main Project
24 |
25 |
26 |
27 | ## ⚙️ Installation
28 | ### npm
29 | ```sh
30 | $ npm i @scena/ruler
31 | ```
32 |
33 | ### scripts
34 | ```html
35 |
36 | ```
37 |
38 |
39 | ## 🚀 How to use
40 | ```ts
41 | import Ruler from "@scena/ruler";
42 |
43 | const ruler = new Ruler(document.body, {
44 | type: "horizontal",
45 | });
46 |
47 |
48 | window.addEventListener("resize", () => {
49 | ruler.resize();
50 | });
51 |
52 | export interface RulerInterface {
53 | scroll(scrollPos: number): any;
54 | resize(): any;
55 | }
56 | export interface RulerProps {
57 | type?: "horizontal" | "vertical";
58 | width?: number;
59 | height?: number;
60 | unit?: number;
61 | zoom?: number;
62 | direction?: "start" | "end";
63 | style?: IObject;
64 | backgroundColor?: string;
65 | lineColor?: string;
66 | textColor?: string;
67 | textFormat?: (scale: number) => string;
68 | }
69 | ```
70 | ### Ruler Units
71 |
72 | The default unit is px, and a line is drawn every 50px. If you want to use a different unit instead of the px unit, use it like this:
73 |
74 | * 1px (Default)
75 | * zoom: 1
76 | * unit: 50 (every 50px)
77 | * 1cm = 37.7952px
78 | * zoom: 37.7952
79 | * unit: 1 (every 1cm)
80 | * 1in = 96px = 2.54cm
81 | * zoom: 96
82 | * unit: 1 (every 1in)
83 |
84 |
85 |
86 | ## ⚙️ Developments
87 | The `ruler` repo is managed as a [monorepo](https://github.com/lerna/lerna) with `yarn`.
88 |
89 | ```sh
90 | yarn config set registry https://registry.npmjs.org/
91 | ```
92 |
93 | ## ⭐️ Show Your Support
94 | Please give a ⭐️ if this project helped you!
95 |
96 | ## 👏 Contributing
97 |
98 | If you have any questions or requests or want to contribute to `ruler` or other packages, please write the [issue](https://github.com/daybrush/ruler/issues) or give me a Pull Request freely.
99 |
100 | ## 🐞 Bug Report
101 |
102 | If you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/ruler/issues) on GitHub.
103 |
104 |
105 | ## 📝 License
106 |
107 | This project is [MIT](https://github.com/daybrush/ruler/blob/master/LICENSE) licensed.
108 |
109 | ```
110 | MIT License
111 |
112 | Copyright (c) 2019 Daybrush
113 |
114 | Permission is hereby granted, free of charge, to any person obtaining a copy
115 | of this software and associated documentation files (the "Software"), to deal
116 | in the Software without restriction, including without limitation the rights
117 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
118 | copies of the Software, and to permit persons to whom the Software is
119 | furnished to do so, subject to the following conditions:
120 |
121 | The above copyright notice and this permission notice shall be included in all
122 | copies or substantial portions of the Software.
123 |
124 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
125 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
126 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
127 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
128 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
129 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
130 | SOFTWARE.
131 | ```
132 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | A Ruler component that can draw grids and scroll infinitely.
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
Drag Screen!
31 |
32 |
33 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
43 |
44 |
47 |
50 |
53 |
55 |
58 |
59 |
A Ruler component that can draw grids and scroll infinitely.
60 |
65 |
66 |
67 |
68 |
69 |
70 |
93 |
94 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/packages/svelte-ruler/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["src/**/*"],
3 | "exclude": ["node_modules/*"],
4 | "compilerOptions": {
5 | /* Basic Options */
6 | "target": "ESNEXT", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
7 | "module": "ESNEXT", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
8 | // "lib": [], /* Specify library files to be included in the compilation. */
9 | // "allowJs": true, /* Allow javascript files to be compiled. */
10 | // "checkJs": true, /* Report errors in .js files. */
11 | // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
12 | // "declaration": true, /* Generates corresponding '.d.ts' file. */
13 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
14 | // "sourceMap": true, /* Generates corresponding '.map' file. */
15 | // "outFile": "./", /* Concatenate and emit output to single file. */
16 | // "outDir": "./", /* Redirect output structure to the directory. */
17 | // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
18 | // "composite": true, /* Enable project compilation */
19 | // "removeComments": true, /* Do not emit comments to output. */
20 | // "noEmit": true, /* Do not emit outputs. */
21 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */
22 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
23 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
24 |
25 | /* Strict Type-Checking Options */
26 | "strict": true, /* Enable all strict type-checking options. */
27 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
28 | // "strictNullChecks": true, /* Enable strict null checks. */
29 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */
30 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
31 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
32 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
33 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
34 |
35 | /* Additional Checks */
36 | // "noUnusedLocals": true, /* Report errors on unused locals. */
37 | // "noUnusedParameters": true, /* Report errors on unused parameters. */
38 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
39 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
40 |
41 | /* Module Resolution Options */
42 | "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
43 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
44 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
45 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
46 | // "typeRoots": [], /* List of folders to include type definitions from. */
47 | "types": ["svelte"], /* Type declaration files to be included in compilation. */
48 | "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
49 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
50 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
51 |
52 | /* Source Map Options */
53 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
54 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
55 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
56 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
57 |
58 | /* Experimental Options */
59 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
60 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/packages/svelte-ruler/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | ## [0.19.0](https://github.com/daybrush/ruler/compare/svelte-ruler@0.18.0...svelte-ruler@0.19.0) (2023-06-02)
7 |
8 |
9 | ### :mega: Other
10 |
11 | * publish packages ([6cb44f9](https://github.com/daybrush/ruler/commit/6cb44f944747a2ff008011bae638fa52cc860c93))
12 |
13 |
14 |
15 | ## [0.18.0](https://github.com/daybrush/ruler/compare/svelte-ruler@0.17.6...svelte-ruler@0.18.0) (2023-06-01)
16 |
17 |
18 | ### :rocket: New Features
19 |
20 | * support svelte types ([4498bc5](https://github.com/daybrush/ruler/commit/4498bc548ac2baa3eaca619b4e3d10463030abc3))
21 |
22 |
23 | ### :mega: Other
24 |
25 | * publish packages ([2628b3d](https://github.com/daybrush/ruler/commit/2628b3db856e066d8ede8eaca3281de61c10c27b))
26 |
27 |
28 |
29 | ## [0.17.6](https://github.com/daybrush/ruler/compare/svelte-ruler@0.17.5...svelte-ruler@0.17.6) (2023-05-15)
30 |
31 |
32 | ### :mega: Other
33 |
34 | * update croact version ([852caef](https://github.com/daybrush/ruler/commit/852caef635a0cacf95b4702cd4c72fb6cac516c2))
35 |
36 |
37 |
38 | ## [0.17.5](https://github.com/daybrush/ruler/compare/svelte-ruler@0.17.3...svelte-ruler@0.17.5) (2023-05-15)
39 |
40 |
41 | ### :bug: Bug Fix
42 |
43 | * update dependency modules ([e2f4602](https://github.com/daybrush/ruler/commit/e2f4602432d64f316a2c41bb9421b7665f72d7f6))
44 |
45 |
46 | ### :mega: Other
47 |
48 | * update croact veresion ([f252b98](https://github.com/daybrush/ruler/commit/f252b9872924ad02e3d1efdf012bf6c55933408b))
49 |
50 |
51 |
52 | ## [0.17.3](https://github.com/daybrush/ruler/compare/svelte-ruler@0.17.2...svelte-ruler@0.17.3) (2023-04-11)
53 |
54 |
55 | ### :bug: Bug Fix
56 |
57 | * fix createElement canvas #40 ([8fe015c](https://github.com/daybrush/ruler/commit/8fe015ce7c6258c718f74747b6bc0431fcd22842))
58 |
59 |
60 |
61 | ## [0.17.2](https://github.com/daybrush/ruler/compare/svelte-ruler@0.17.1...svelte-ruler@0.17.2) (2023-04-10)
62 |
63 |
64 | ### :mega: Other
65 |
66 | * update packages ([c9ffdbb](https://github.com/daybrush/ruler/commit/c9ffdbb6524f80ed5213ff778dafa62f4a1f9353))
67 |
68 |
69 |
70 | ## [0.17.1](https://github.com/daybrush/ruler/compare/svelte-ruler@0.17.0...svelte-ruler@0.17.1) (2023-04-08)
71 |
72 |
73 | ### :mega: Other
74 |
75 | * publish packages ([2c6bfa0](https://github.com/daybrush/ruler/commit/2c6bfa0cda3df3a361f48163d9a7f1ada6cccb59))
76 |
77 |
78 |
79 | ## [0.17.0](https://github.com/daybrush/ruler/compare/svelte-ruler@0.16.0...svelte-ruler@0.17.0) (2023-04-08)
80 |
81 |
82 | ### :mega: Other
83 |
84 | * publish packages ([65c88e8](https://github.com/daybrush/ruler/commit/65c88e87316850f2cd0cd56a1c4a7f9d1131355b))
85 |
86 |
87 |
88 | ## [0.16.0](https://github.com/daybrush/ruler/compare/svelte-ruler@0.15.0...svelte-ruler@0.16.0) (2023-04-06)
89 |
90 |
91 | ### :rocket: New Features
92 |
93 | * add croact-ruler ([2d0361e](https://github.com/daybrush/ruler/commit/2d0361e403c0b51f135558add86296a509e3ec9b))
94 |
95 |
96 | ### :mega: Other
97 |
98 | * publish packages ([9775d43](https://github.com/daybrush/ruler/commit/9775d43ce6b04033141c394aa8c7ca3288238588))
99 |
100 |
101 |
102 | ## [0.15.0](https://github.com/daybrush/ruler/compare/svelte-ruler@0.14.2...svelte-ruler@0.15.0) (2023-03-04)
103 |
104 |
105 | ### :mega: Other
106 |
107 | * publish packages ([80d6f11](https://github.com/daybrush/ruler/commit/80d6f1176e755cce1b4bcc044b4e6574b8118c01))
108 |
109 |
110 |
111 | ## [0.14.2](https://github.com/daybrush/ruler/compare/svelte-ruler@0.14.1...svelte-ruler@0.14.2) (2023-01-27)
112 |
113 |
114 | ### :mega: Other
115 |
116 | * publish packages ([c9e29b5](https://github.com/daybrush/ruler/commit/c9e29b51d433abd63c4b684cab25c5319a0c4273))
117 |
118 |
119 |
120 | ## [0.14.1](https://github.com/daybrush/ruler/compare/svelte-ruler@0.14.0...svelte-ruler@0.14.1) (2023-01-20)
121 |
122 |
123 | ### :mega: Other
124 |
125 | * publish packages ([2d2d96a](https://github.com/daybrush/ruler/commit/2d2d96ac218d45278ebfecdd52424a60a2da1ec9))
126 |
127 |
128 |
129 | ## [0.14.0](https://github.com/daybrush/ruler/compare/svelte-ruler@0.13.0...svelte-ruler@0.14.0) (2023-01-20)
130 |
131 |
132 | ### :mega: Other
133 |
134 | * publish packages ([b7f8d2a](https://github.com/daybrush/ruler/commit/b7f8d2a3041202dd89c3da14a7e93cd6ace206bb))
135 |
136 |
137 |
138 | ## [0.13.0](https://github.com/daybrush/ruler/compare/svelte-ruler@0.12.2...svelte-ruler@0.13.0) (2023-01-12)
139 |
140 |
141 | ### :mega: Other
142 |
143 | * publish packages ([6e41e5f](https://github.com/daybrush/ruler/commit/6e41e5f910f84f68b8db80b493a8c683ab755381))
144 |
145 |
146 |
147 | ## [0.12.2](https://github.com/daybrush/ruler/compare/svelte-ruler@0.12.0...svelte-ruler@0.12.2) (2022-11-12)
148 |
149 |
150 | ### :bug: Bug Fix
151 |
152 | * fix comments, files property ([d8bc095](https://github.com/daybrush/ruler/commit/d8bc095c5e25e630d720c7b255cf4b42ada6c582))
153 |
154 |
155 | ### :mega: Other
156 |
157 | * publish packages ([3334cf1](https://github.com/daybrush/ruler/commit/3334cf1ad0f2bdd66d4a1a6fc26202f026077671))
158 | * publish packages ([4ceff62](https://github.com/daybrush/ruler/commit/4ceff62e5224779578e61a4e3b0362f6597feecf))
159 |
160 |
161 |
162 | ## [0.12.0](https://github.com/daybrush/ruler/compare/svelte-ruler@0.11.0...svelte-ruler@0.12.0) (2022-11-06)
163 |
164 |
165 | ### :mega: Other
166 |
167 | * publish packages ([de112ef](https://github.com/daybrush/ruler/commit/de112ef49f2b4063a0b8e810abff0d646da5c3d1))
168 |
169 |
170 |
171 | ## [0.11.0](https://github.com/daybrush/ruler/compare/svelte-ruler@0.10.0...svelte-ruler@0.11.0) (2022-09-21)
172 |
173 |
174 | ### :mega: Other
175 |
176 | * publish packages ([9dc9493](https://github.com/daybrush/ruler/commit/9dc9493020206310eb807d7c6d52e9b683f23723))
177 |
--------------------------------------------------------------------------------
/packages/svelte-ruler/src/App.svelte:
--------------------------------------------------------------------------------
1 |
34 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
Drag Screen!
156 |
157 |
158 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
168 |
169 |
171 |
173 |
175 |
177 |
179 |
180 |
A Ruler component that can draw grids and scroll infinitely.
181 |
185 |
186 |
--------------------------------------------------------------------------------
/packages/vue-ruler/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | ## [0.18.0](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.17.0...@scena/vue-ruler@0.18.0) (2023-06-02)
7 |
8 |
9 | ### :mega: Other
10 |
11 | * publish packages ([6cb44f9](https://github.com/daybrush/ruler/commit/6cb44f944747a2ff008011bae638fa52cc860c93))
12 |
13 |
14 |
15 | ## [0.17.0](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.16.6...@scena/vue-ruler@0.17.0) (2023-06-01)
16 |
17 |
18 | ### :mega: Other
19 |
20 | * publish packages ([2628b3d](https://github.com/daybrush/ruler/commit/2628b3db856e066d8ede8eaca3281de61c10c27b))
21 |
22 |
23 |
24 | ## [0.16.6](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.16.5...@scena/vue-ruler@0.16.6) (2023-05-15)
25 |
26 |
27 | ### :mega: Other
28 |
29 | * update croact version ([852caef](https://github.com/daybrush/ruler/commit/852caef635a0cacf95b4702cd4c72fb6cac516c2))
30 |
31 |
32 |
33 | ## [0.16.5](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.16.3...@scena/vue-ruler@0.16.5) (2023-05-15)
34 |
35 |
36 | ### :bug: Bug Fix
37 |
38 | * update dependency modules ([e2f4602](https://github.com/daybrush/ruler/commit/e2f4602432d64f316a2c41bb9421b7665f72d7f6))
39 |
40 |
41 | ### :mega: Other
42 |
43 | * update croact veresion ([f252b98](https://github.com/daybrush/ruler/commit/f252b9872924ad02e3d1efdf012bf6c55933408b))
44 |
45 |
46 |
47 | ## [0.16.3](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.16.2...@scena/vue-ruler@0.16.3) (2023-04-11)
48 |
49 |
50 | ### :bug: Bug Fix
51 |
52 | * fix createElement canvas #40 ([8fe015c](https://github.com/daybrush/ruler/commit/8fe015ce7c6258c718f74747b6bc0431fcd22842))
53 |
54 |
55 |
56 | ## [0.16.2](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.16.1...@scena/vue-ruler@0.16.2) (2023-04-10)
57 |
58 |
59 | ### :mega: Other
60 |
61 | * update packages ([c9ffdbb](https://github.com/daybrush/ruler/commit/c9ffdbb6524f80ed5213ff778dafa62f4a1f9353))
62 |
63 |
64 |
65 | ## [0.16.1](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.16.0...@scena/vue-ruler@0.16.1) (2023-04-08)
66 |
67 |
68 | ### :mega: Other
69 |
70 | * publish packages ([2c6bfa0](https://github.com/daybrush/ruler/commit/2c6bfa0cda3df3a361f48163d9a7f1ada6cccb59))
71 |
72 |
73 |
74 | ## [0.16.0](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.15.0...@scena/vue-ruler@0.16.0) (2023-04-08)
75 |
76 |
77 | ### :mega: Other
78 |
79 | * publish packages ([65c88e8](https://github.com/daybrush/ruler/commit/65c88e87316850f2cd0cd56a1c4a7f9d1131355b))
80 |
81 |
82 |
83 | ## [0.15.0](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.14.0...@scena/vue-ruler@0.15.0) (2023-04-06)
84 |
85 |
86 | ### :rocket: New Features
87 |
88 | * add croact-ruler ([2d0361e](https://github.com/daybrush/ruler/commit/2d0361e403c0b51f135558add86296a509e3ec9b))
89 |
90 |
91 | ### :mega: Other
92 |
93 | * publish packages ([9775d43](https://github.com/daybrush/ruler/commit/9775d43ce6b04033141c394aa8c7ca3288238588))
94 |
95 |
96 |
97 | ## [0.14.0](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.13.2...@scena/vue-ruler@0.14.0) (2023-03-04)
98 |
99 |
100 | ### :mega: Other
101 |
102 | * publish packages ([80d6f11](https://github.com/daybrush/ruler/commit/80d6f1176e755cce1b4bcc044b4e6574b8118c01))
103 |
104 |
105 |
106 | ## [0.13.2](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.13.1...@scena/vue-ruler@0.13.2) (2023-01-27)
107 |
108 |
109 | ### :mega: Other
110 |
111 | * publish packages ([c9e29b5](https://github.com/daybrush/ruler/commit/c9e29b51d433abd63c4b684cab25c5319a0c4273))
112 |
113 |
114 |
115 | ## [0.13.1](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.13.0...@scena/vue-ruler@0.13.1) (2023-01-20)
116 |
117 |
118 | ### :mega: Other
119 |
120 | * publish packages ([2d2d96a](https://github.com/daybrush/ruler/commit/2d2d96ac218d45278ebfecdd52424a60a2da1ec9))
121 |
122 |
123 |
124 | ## [0.13.0](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.12.0...@scena/vue-ruler@0.13.0) (2023-01-20)
125 |
126 |
127 | ### :mega: Other
128 |
129 | * publish packages ([b7f8d2a](https://github.com/daybrush/ruler/commit/b7f8d2a3041202dd89c3da14a7e93cd6ace206bb))
130 |
131 |
132 |
133 | ## [0.12.0](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.11.2...@scena/vue-ruler@0.12.0) (2023-01-12)
134 |
135 |
136 | ### :mega: Other
137 |
138 | * publish packages ([6e41e5f](https://github.com/daybrush/ruler/commit/6e41e5f910f84f68b8db80b493a8c683ab755381))
139 |
140 |
141 |
142 | ## [0.11.2](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.11.0...@scena/vue-ruler@0.11.2) (2022-11-12)
143 |
144 |
145 | ### :bug: Bug Fix
146 |
147 | * fix comments, files property ([d8bc095](https://github.com/daybrush/ruler/commit/d8bc095c5e25e630d720c7b255cf4b42ada6c582))
148 | * fix files field in package.json #33 ([0cd0888](https://github.com/daybrush/ruler/commit/0cd0888f667621af308fa9f3e3f1b51aadac3a29))
149 |
150 |
151 | ### :mega: Other
152 |
153 | * publish packages ([3334cf1](https://github.com/daybrush/ruler/commit/3334cf1ad0f2bdd66d4a1a6fc26202f026077671))
154 | * publish packages ([4ceff62](https://github.com/daybrush/ruler/commit/4ceff62e5224779578e61a4e3b0362f6597feecf))
155 |
156 |
157 |
158 | ## [0.11.0](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.10.0...@scena/vue-ruler@0.11.0) (2022-11-06)
159 |
160 |
161 | ### :mega: Other
162 |
163 | * publish packages ([de112ef](https://github.com/daybrush/ruler/commit/de112ef49f2b4063a0b8e810abff0d646da5c3d1))
164 |
165 |
166 |
167 | ## [0.10.0](https://github.com/daybrush/ruler/compare/@scena/vue-ruler@0.9.0...@scena/vue-ruler@0.10.0) (2022-09-21)
168 |
169 |
170 | ### :mega: Other
171 |
172 | * publish packages ([9dc9493](https://github.com/daybrush/ruler/commit/9dc9493020206310eb807d7c6d52e9b683f23723))
173 |
--------------------------------------------------------------------------------
/packages/react-ruler/src/demo/serviceWorker.ts:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read https://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === "localhost" ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === "[::1]" ||
17 | // 127.0.0.1/8 is considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
20 | ),
21 | );
22 |
23 | interface Config {
24 | onSuccess?: (registration: ServiceWorkerRegistration) => void;
25 | onUpdate?: (registration: ServiceWorkerRegistration) => void;
26 | }
27 |
28 | export function register(config?: Config) {
29 | if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
30 | // The URL constructor is available in all browsers that support SW.
31 | const publicUrl = new URL(
32 | (process as { env: { [key: string]: string } }).env.PUBLIC_URL,
33 | window.location.href,
34 | );
35 | if (publicUrl.origin !== window.location.origin) {
36 | // Our service worker won't work if PUBLIC_URL is on a different origin
37 | // from what our page is served on. This might happen if a CDN is used to
38 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
39 | return;
40 | }
41 |
42 | window.addEventListener("load", () => {
43 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
44 |
45 | if (isLocalhost) {
46 | // This is running on localhost. Let's check if a service worker still exists or not.
47 | checkValidServiceWorker(swUrl, config);
48 |
49 | // Add some additional logging to localhost, pointing developers to the
50 | // service worker/PWA documentation.
51 | navigator.serviceWorker.ready.then(() => {
52 | console.log(
53 | "This web app is being served cache-first by a service " +
54 | "worker. To learn more, visit https://bit.ly/CRA-PWA",
55 | );
56 | });
57 | } else {
58 | // Is not localhost. Just register service worker
59 | registerValidSW(swUrl, config);
60 | }
61 | });
62 | }
63 | }
64 |
65 | function registerValidSW(swUrl: string, config?: Config) {
66 | navigator.serviceWorker
67 | .register(swUrl)
68 | .then(registration => {
69 | registration.onupdatefound = () => {
70 | const installingWorker = registration.installing;
71 | if (installingWorker == null) {
72 | return;
73 | }
74 | installingWorker.onstatechange = () => {
75 | if (installingWorker.state === "installed") {
76 | if (navigator.serviceWorker.controller) {
77 | // At this point, the updated precached content has been fetched,
78 | // but the previous service worker will still serve the older
79 | // content until all client tabs are closed.
80 | console.log(
81 | "New content is available and will be used when all " +
82 | "tabs for this page are closed. See https://bit.ly/CRA-PWA.",
83 | );
84 |
85 | // Execute callback
86 | if (config && config.onUpdate) {
87 | config.onUpdate(registration);
88 | }
89 | } else {
90 | // At this point, everything has been precached.
91 | // It's the perfect time to display a
92 | // "Content is cached for offline use." message.
93 | console.log("Content is cached for offline use.");
94 |
95 | // Execute callback
96 | if (config && config.onSuccess) {
97 | config.onSuccess(registration);
98 | }
99 | }
100 | }
101 | };
102 | };
103 | })
104 | .catch(error => {
105 | console.error("Error during service worker registration:", error);
106 | });
107 | }
108 |
109 | function checkValidServiceWorker(swUrl: string, config?: Config) {
110 | // Check if the service worker can be found. If it can't reload the page.
111 | fetch(swUrl)
112 | .then(response => {
113 | // Ensure service worker exists, and that we really are getting a JS file.
114 | const contentType = response.headers.get("content-type");
115 | if (
116 | response.status === 404 ||
117 | (contentType != null && contentType.indexOf("javascript") === -1)
118 | ) {
119 | // No service worker found. Probably a different app. Reload the page.
120 | navigator.serviceWorker.ready.then(registration => {
121 | registration.unregister().then(() => {
122 | window.location.reload();
123 | });
124 | });
125 | } else {
126 | // Service worker found. Proceed as normal.
127 | registerValidSW(swUrl, config);
128 | }
129 | })
130 | .catch(() => {
131 | console.log(
132 | "No internet connection found. App is running in offline mode.",
133 | );
134 | });
135 | }
136 |
137 | export function unregister() {
138 | if ("serviceWorker" in navigator) {
139 | navigator.serviceWorker.ready.then(registration => {
140 | registration.unregister();
141 | });
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/packages/ruler/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | ## [0.20.0](https://github.com/daybrush/ruler/compare/@scena/ruler@0.19.0...@scena/ruler@0.20.0) (2023-06-02)
7 |
8 |
9 | ### :mega: Other
10 |
11 | * publish packages ([6cb44f9](https://github.com/daybrush/ruler/commit/6cb44f944747a2ff008011bae638fa52cc860c93))
12 |
13 |
14 |
15 | ## [0.19.0](https://github.com/daybrush/ruler/compare/@scena/ruler@0.18.6...@scena/ruler@0.19.0) (2023-06-01)
16 |
17 |
18 | ### :mega: Other
19 |
20 | * publish packages ([2628b3d](https://github.com/daybrush/ruler/commit/2628b3db856e066d8ede8eaca3281de61c10c27b))
21 |
22 |
23 |
24 | ## [0.18.6](https://github.com/daybrush/ruler/compare/@scena/ruler@0.18.5...@scena/ruler@0.18.6) (2023-05-15)
25 |
26 |
27 | ### :mega: Other
28 |
29 | * update croact version ([852caef](https://github.com/daybrush/ruler/commit/852caef635a0cacf95b4702cd4c72fb6cac516c2))
30 |
31 |
32 |
33 | ## [0.18.5](https://github.com/daybrush/ruler/compare/@scena/ruler@0.18.3...@scena/ruler@0.18.5) (2023-05-15)
34 |
35 |
36 | ### :bug: Bug Fix
37 |
38 | * update dependency modules ([e2f4602](https://github.com/daybrush/ruler/commit/e2f4602432d64f316a2c41bb9421b7665f72d7f6))
39 |
40 |
41 | ### :mega: Other
42 |
43 | * update croact veresion ([f252b98](https://github.com/daybrush/ruler/commit/f252b9872924ad02e3d1efdf012bf6c55933408b))
44 |
45 |
46 |
47 | ## [0.18.3](https://github.com/daybrush/ruler/compare/@scena/ruler@0.18.2...@scena/ruler@0.18.3) (2023-04-11)
48 |
49 |
50 | ### :bug: Bug Fix
51 |
52 | * fix createElement canvas #40 ([8fe015c](https://github.com/daybrush/ruler/commit/8fe015ce7c6258c718f74747b6bc0431fcd22842))
53 |
54 |
55 |
56 | ## [0.18.2](https://github.com/daybrush/ruler/compare/@scena/ruler@0.18.1...@scena/ruler@0.18.2) (2023-04-10)
57 |
58 |
59 | ### :bug: Bug Fix
60 |
61 | * fix module name #40 ([c36f6fe](https://github.com/daybrush/ruler/commit/c36f6fe9c5b4eb04b3e0dbeca78dbaf126289178))
62 |
63 |
64 | ### :mega: Other
65 |
66 | * update packages ([c9ffdbb](https://github.com/daybrush/ruler/commit/c9ffdbb6524f80ed5213ff778dafa62f4a1f9353))
67 |
68 |
69 |
70 | ## [0.18.1](https://github.com/daybrush/ruler/compare/@scena/ruler@0.18.0...@scena/ruler@0.18.1) (2023-04-08)
71 |
72 |
73 | ### :mega: Other
74 |
75 | * publish packages ([2c6bfa0](https://github.com/daybrush/ruler/commit/2c6bfa0cda3df3a361f48163d9a7f1ada6cccb59))
76 |
77 |
78 |
79 | ## [0.18.0](https://github.com/daybrush/ruler/compare/@scena/ruler@0.17.0...@scena/ruler@0.18.0) (2023-04-08)
80 |
81 |
82 | ### :rocket: New Features
83 |
84 | * add defaultScrollPos prop ([abd585b](https://github.com/daybrush/ruler/commit/abd585bda548be8384a644cd251e6678635fa8b4))
85 |
86 |
87 | ### :mega: Other
88 |
89 | * publish packages ([65c88e8](https://github.com/daybrush/ruler/commit/65c88e87316850f2cd0cd56a1c4a7f9d1131355b))
90 |
91 |
92 |
93 | ## [0.17.0](https://github.com/daybrush/ruler/compare/@scena/ruler@0.16.0...@scena/ruler@0.17.0) (2023-04-06)
94 |
95 |
96 | ### :rocket: New Features
97 |
98 | * add croact-ruler ([2d0361e](https://github.com/daybrush/ruler/commit/2d0361e403c0b51f135558add86296a509e3ec9b))
99 |
100 |
101 | ### :mega: Other
102 |
103 | * publish packages ([9775d43](https://github.com/daybrush/ruler/commit/9775d43ce6b04033141c394aa8c7ca3288238588))
104 |
105 |
106 |
107 | ## [0.16.0](https://github.com/daybrush/ruler/compare/@scena/ruler@0.15.2...@scena/ruler@0.16.0) (2023-03-04)
108 |
109 |
110 | ### :mega: Other
111 |
112 | * publish packages ([80d6f11](https://github.com/daybrush/ruler/commit/80d6f1176e755cce1b4bcc044b4e6574b8118c01))
113 |
114 |
115 |
116 | ## [0.15.2](https://github.com/daybrush/ruler/compare/@scena/ruler@0.15.1...@scena/ruler@0.15.2) (2023-01-27)
117 |
118 |
119 | ### :mega: Other
120 |
121 | * publish packages ([c9e29b5](https://github.com/daybrush/ruler/commit/c9e29b51d433abd63c4b684cab25c5319a0c4273))
122 |
123 |
124 |
125 | ## [0.15.1](https://github.com/daybrush/ruler/compare/@scena/ruler@0.15.0...@scena/ruler@0.15.1) (2023-01-20)
126 |
127 |
128 | ### :mega: Other
129 |
130 | * publish packages ([2d2d96a](https://github.com/daybrush/ruler/commit/2d2d96ac218d45278ebfecdd52424a60a2da1ec9))
131 |
132 |
133 |
134 | ## [0.15.0](https://github.com/daybrush/ruler/compare/@scena/ruler@0.14.0...@scena/ruler@0.15.0) (2023-01-20)
135 |
136 |
137 | ### :mega: Other
138 |
139 | * publish packages ([b7f8d2a](https://github.com/daybrush/ruler/commit/b7f8d2a3041202dd89c3da14a7e93cd6ace206bb))
140 |
141 |
142 |
143 | ## [0.14.0](https://github.com/daybrush/ruler/compare/@scena/ruler@0.12.2...@scena/ruler@0.14.0) (2023-01-12)
144 |
145 |
146 | ### :mega: Other
147 |
148 | * publish packages ([6e41e5f](https://github.com/daybrush/ruler/commit/6e41e5f910f84f68b8db80b493a8c683ab755381))
149 |
150 |
151 |
152 | ## [0.12.2](https://github.com/daybrush/ruler/compare/@scena/ruler@0.12.0...@scena/ruler@0.12.2) (2022-11-12)
153 |
154 |
155 | ### :bug: Bug Fix
156 |
157 | * fix comments, files property ([d8bc095](https://github.com/daybrush/ruler/commit/d8bc095c5e25e630d720c7b255cf4b42ada6c582))
158 | * fix files field in package.json #33 ([0cd0888](https://github.com/daybrush/ruler/commit/0cd0888f667621af308fa9f3e3f1b51aadac3a29))
159 |
160 |
161 | ### :mega: Other
162 |
163 | * publish packages ([3334cf1](https://github.com/daybrush/ruler/commit/3334cf1ad0f2bdd66d4a1a6fc26202f026077671))
164 | * publish packages ([4ceff62](https://github.com/daybrush/ruler/commit/4ceff62e5224779578e61a4e3b0362f6597feecf))
165 |
166 |
167 |
168 | ## [0.12.0](https://github.com/daybrush/ruler/compare/@scena/ruler@0.11.0...@scena/ruler@0.12.0) (2022-11-06)
169 |
170 |
171 | ### :mega: Other
172 |
173 | * publish packages ([de112ef](https://github.com/daybrush/ruler/commit/de112ef49f2b4063a0b8e810abff0d646da5c3d1))
174 |
175 |
176 |
177 | ## [0.11.0](https://github.com/daybrush/ruler/compare/@scena/ruler@0.10.0...@scena/ruler@0.11.0) (2022-09-21)
178 |
179 |
180 | ### :mega: Other
181 |
182 | * publish packages ([9dc9493](https://github.com/daybrush/ruler/commit/9dc9493020206310eb807d7c6d52e9b683f23723))
183 |
--------------------------------------------------------------------------------
/packages/preact-ruler/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | ## [0.19.0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.18.0...preact-ruler@0.19.0) (2023-06-02)
7 |
8 |
9 | ### :mega: Other
10 |
11 | * publish packages ([6cb44f9](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/6cb44f944747a2ff008011bae638fa52cc860c93))
12 |
13 |
14 |
15 | ## [0.18.0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.17.1...preact-ruler@0.18.0) (2023-06-01)
16 |
17 |
18 | ### :mega: Other
19 |
20 | * publish packages ([2628b3d](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/2628b3db856e066d8ede8eaca3281de61c10c27b))
21 |
22 |
23 |
24 | ## [0.17.1](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.17.1...preact-ruler@0.17.1) (2023-05-15)
25 |
26 | **Note:** Version bump only for package preact-ruler
27 |
28 |
29 |
30 |
31 |
32 | ## [0.17.1](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.17.1...preact-ruler@0.17.1) (2023-05-15)
33 |
34 | **Note:** Version bump only for package preact-ruler
35 |
36 |
37 |
38 |
39 |
40 | ## [0.17.1](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.17.1...preact-ruler@0.17.1) (2023-04-11)
41 |
42 | **Note:** Version bump only for package preact-ruler
43 |
44 |
45 |
46 |
47 |
48 | ## [0.17.1](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.17.1...preact-ruler@0.17.1) (2023-04-10)
49 |
50 | **Note:** Version bump only for package preact-ruler
51 |
52 |
53 |
54 |
55 |
56 | ## [0.17.1](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.17.0...preact-ruler@0.17.1) (2023-04-08)
57 |
58 |
59 | ### :mega: Other
60 |
61 | * publish packages ([2c6bfa0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/2c6bfa0cda3df3a361f48163d9a7f1ada6cccb59))
62 |
63 |
64 |
65 | ## [0.17.0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.16.0...preact-ruler@0.17.0) (2023-04-08)
66 |
67 |
68 | ### :mega: Other
69 |
70 | * publish packages ([65c88e8](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/65c88e87316850f2cd0cd56a1c4a7f9d1131355b))
71 |
72 |
73 |
74 | ## [0.16.0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.15.0...preact-ruler@0.16.0) (2023-04-06)
75 |
76 |
77 | ### :mega: Other
78 |
79 | * publish packages ([9775d43](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/9775d43ce6b04033141c394aa8c7ca3288238588))
80 |
81 |
82 |
83 | ## [0.15.0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.14.2...preact-ruler@0.15.0) (2023-03-04)
84 |
85 |
86 | ### :mega: Other
87 |
88 | * publish packages ([80d6f11](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/80d6f1176e755cce1b4bcc044b4e6574b8118c01))
89 |
90 |
91 |
92 | ## [0.14.2](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.14.1...preact-ruler@0.14.2) (2023-01-27)
93 |
94 |
95 | ### :mega: Other
96 |
97 | * publish packages ([c9e29b5](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/c9e29b51d433abd63c4b684cab25c5319a0c4273))
98 |
99 |
100 |
101 | ## [0.14.1](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.14.0...preact-ruler@0.14.1) (2023-01-20)
102 |
103 |
104 | ### :mega: Other
105 |
106 | * publish packages ([2d2d96a](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/2d2d96ac218d45278ebfecdd52424a60a2da1ec9))
107 |
108 |
109 |
110 | ## [0.14.0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.13.0...preact-ruler@0.14.0) (2023-01-20)
111 |
112 |
113 | ### :mega: Other
114 |
115 | * publish packages ([b7f8d2a](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/b7f8d2a3041202dd89c3da14a7e93cd6ace206bb))
116 |
117 |
118 |
119 | ## [0.13.0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.12.2...preact-ruler@0.13.0) (2023-01-12)
120 |
121 |
122 | ### :mega: Other
123 |
124 | * publish packages ([6e41e5f](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/6e41e5f910f84f68b8db80b493a8c683ab755381))
125 |
126 |
127 |
128 | ## [0.12.2](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.12.0...preact-ruler@0.12.2) (2022-11-12)
129 |
130 |
131 | ### :bug: Bug Fix
132 |
133 | * fix comments, files property ([d8bc095](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/d8bc095c5e25e630d720c7b255cf4b42ada6c582))
134 | * fix files field in package.json #33 ([0cd0888](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/0cd0888f667621af308fa9f3e3f1b51aadac3a29))
135 |
136 |
137 | ### :mega: Other
138 |
139 | * publish packages ([3334cf1](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/3334cf1ad0f2bdd66d4a1a6fc26202f026077671))
140 | * publish packages ([4ceff62](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/4ceff62e5224779578e61a4e3b0362f6597feecf))
141 |
142 |
143 |
144 | ## [0.12.0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.11.0...preact-ruler@0.12.0) (2022-11-06)
145 |
146 |
147 | ### :mega: Other
148 |
149 | * publish packages ([de112ef](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/de112ef49f2b4063a0b8e810abff0d646da5c3d1))
150 |
151 |
152 |
153 | ## [0.11.0](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/compare/preact-ruler@0.10.0...preact-ruler@0.11.0) (2022-09-21)
154 |
155 |
156 | ### :mega: Other
157 |
158 | * publish packages ([9dc9493](https://github.com/daybrush/ruler/blob/master/packages/preact-ruler/commit/9dc9493020206310eb807d7c6d52e9b683f23723))
159 |
--------------------------------------------------------------------------------
/packages/react-ruler/src/react-ruler/types.ts:
--------------------------------------------------------------------------------
1 | import { IObject } from "@daybrush/utils";
2 |
3 | /**
4 | * @typedef
5 | * @memberof Ruler
6 | */
7 | export interface RulerInterface {
8 | /**
9 | * Scroll to that location. It can be used when the scrollPos prop is not used.
10 | * @param - scroll position
11 | */
12 | scroll(scrollPos: number): void;
13 | /**
14 | * Recalculate the style of the ruler.
15 | */
16 | resize(): void;
17 | /**
18 | * Gets the scroll position of the ruler.
19 | */
20 | getScrollPos(): number;
21 | /**
22 | * draw a ruler
23 | */
24 | draw(options?: DrawRulerOptions): void;
25 | }
26 |
27 | export interface DrawRulerOptions {
28 | scrollPos?: number;
29 | zoom?: number;
30 | selectedRanges?: number[][];
31 | marks?: number[];
32 | unit?: number;
33 | segment?: number;
34 | }
35 |
36 | /**
37 | * @typedef
38 | * @memberof Ruler
39 | */
40 | export interface RulerProps {
41 | /**
42 | * ruler's direction
43 | * @default "horizontal"
44 | */
45 | type?: "horizontal" | "vertical";
46 | /**
47 | * ruler's width
48 | * @default target's offsetWidth
49 | */
50 | width?: number;
51 | /**
52 | * ruler's height
53 | * @default target's offsetHeight
54 | */
55 | height?: number;
56 | /**
57 | * main scale unit
58 | * @default 50
59 | * @example
60 | * ```
61 | * 1px (Default) zoom: 1, unit: 50 (every 50px)
62 | * 1cm = 37.7952px zoom: 37.7952 unit: 1 (every 1cm)
63 | * 1in = 96px = 2.54cm zoom: 9 unit: 1 (every 1in)
64 | * ```
65 | */
66 | unit?: number;
67 | /**
68 | * zoom
69 | * @default 1
70 | * @example
71 | * ```
72 | * 1px (Default) zoom: 1, unit: 50 (every 50px)
73 | * 1cm = 37.7952px zoom: 37.7952 unit: 1 (every 1cm)
74 | * 1in = 96px = 2.54cm zoom: 9 unit: 1 (every 1in)
75 | * ```
76 | */
77 | zoom?: number;
78 | /**
79 | * line's direction (align)
80 | * @default "end"
81 | */
82 | direction?: "start" | "center" | "end";
83 | /**
84 | * text align
85 | * @default "start"
86 | */
87 | textAlign?: "left" | "center" | "right";
88 | /**
89 | * font and size
90 | * @default "10px sans-serif"
91 | */
92 | font?: string;
93 | /**
94 | * Number of areas to divide between two main lines
95 | * @default 10
96 | */
97 | segment?: number;
98 | /**
99 | * main line size
100 | * @default "100%"
101 | */
102 | mainLineSize?: string | number;
103 | /**
104 | * long line size
105 | * @default 10
106 | */
107 | longLineSize?: string | number;
108 | /**
109 | * short line size
110 | * @default 7
111 | */
112 | shortLineSize?: string | number;
113 | /**
114 | * line's position offset
115 | * @default [0, 0]
116 | */
117 | lineOffset?: number[];
118 | /**
119 | * text's position offset
120 | * @default [0, 0]
121 | */
122 | textOffset?: number[];
123 | /**
124 | * Whether to display the ruler in the negative direction.
125 | * @default true
126 | */
127 | negativeRuler?: boolean;
128 | /**
129 | * The range to show the ruler's scales
130 | * @default [-Infinity, Infinity]
131 | */
132 | range?: [number, number];
133 | /**
134 | * you can set scroll position by prop.
135 | * If you use the scrollPos prop, you can't use the scroll method.
136 | * @default undefined
137 | */
138 | scrollPos?: number;
139 | /**
140 | * you can set scroll position by prop for init.
141 | * don't use `scrollPos` prop
142 | * @default 0
143 | */
144 | defaultScrollPos?: number;
145 | /**
146 | * ruler canvas style
147 | */
148 | style?: IObject;
149 | /**
150 | * ruler's background color
151 | * @default "#333333"
152 | */
153 | backgroundColor?: string;
154 | /**
155 | * background color within range in ruler
156 | * @default "transparent"
157 | */
158 | rangeBackgroundColor?: string;
159 | /**
160 | * ruler's line color
161 | * @default "#777777"
162 | */
163 | lineColor?: string;
164 | /**
165 | * ruler's text color
166 | * @default "#ffffff"
167 | */
168 | textColor?: string;
169 | /**
170 | * The background color that wraps the text
171 | * @default "transparent"
172 | */
173 | textBackgroundColor?: string;
174 | /**
175 | * text foramt
176 | * @default ownself
177 | */
178 | textFormat?: (scale: number) => string;
179 | /**
180 | * positions to mark
181 | * @default []
182 | */
183 | marks?: number[];
184 | /**
185 | * @default "#f55"
186 | *
187 | */
188 | markColor?: string;
189 | /**
190 | * Ruler's line width
191 | * @default 1
192 | */
193 | lineWidth?: number;
194 | /**
195 | * Whether to warp self
196 | */
197 | warpSelf?: boolean;
198 | /**
199 | * You can paint the selected area(selectedranges) with the `selectedBackgroundColor` color.
200 | */
201 | selectedRanges?: number[][];
202 | /**
203 | * background color within selected range in ruler with `selectedRanges` area
204 | * @default "#555555"
205 | */
206 | selectedBackgroundColor?: string;
207 | /**
208 | * Text is displayed in the selected ranges. If it overlaps existing text, only the selected range text is visible.
209 | * @since 0.16.0
210 | * @default false
211 | */
212 | selectedRangesText?: boolean;
213 | /**
214 | * Position offset of text in selected ranges
215 | * @since 0.16.0
216 | * @default "0, 0"
217 | */
218 | selectedRangesTextOffset?: number[];
219 | /**
220 | * Color of text in selected ranges
221 | * @since 0.16.0
222 | * @default "#44aaff"
223 | */
224 | selectedRangesTextColor?: string;
225 | /**
226 | * Scale value of canvase when device high density is 1.
227 | * Less than 2 may cause pixels to blur.
228 | * If device high density is greater than 1, it is forcibly set to 3.
229 | * @default 2
230 | */
231 | defaultPixelScale?: number;
232 | /**
233 | * Whether to use the resize observer. When the size changes, the resize method is automatically called.
234 | */
235 | useResizeObserver?: boolean;
236 | }
237 |
--------------------------------------------------------------------------------