一个可以绘制直尺和管理指导线的 Guides 组件。
Guides
A Guides component that can draw ruler and manage guidelines.
Demo /
API /
Ruler /
Main Project$ npm i @scena/guides
import Guides from "@scena/guides";
const guides = new Guides(document.body, {
type: "horizontal",
}).on("changeGuides", e => {
console.log(e.guides);
});
let scrollX = 0;
let scrollY = 0;
window.addEventListener("resize", () => {
guides.resize();
});
window.addEventListener("wheel", e => {
scrollX += e.deltaX;
scrollY += e.deltaY;
guides.scrollGuides(scrollY);
guides.scroll(scrollX);
});
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:
See:
The guides repo is managed as a monorepo with yarn.
yarn config set registry https://registry.npmjs.org/Please give a ⭐️ if this project helped you!
If you have any questions or requests or want to contribute to guides or other packages, please write the issue or give me a Pull Request freely.
If you find a bug, please report to us opening a new Issue on GitHub.
This project is MIT licensed.
…暂无开放 Issues,或尚未同步最近议题。