Skip to content

Commit

Permalink
fix: fix not triggered events #80
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed May 7, 2023
1 parent 2fd28db commit a8acea3
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/guides/src/GuidesManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Guides extends EventEmitter<GuidesEvents> {
}
renderSelf(
<InnerGuides ref={ref(this, "innerGuides")}
{...events}
{...options} />,
selfElement,
);
Expand Down
177 changes: 177 additions & 0 deletions packages/guides/test/manual/guides.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<style>
html,
body,
#root,
.app {
position: relative;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
color: #333;
background: #fdfdfd;
}

.app {
transform-style: preserve-3d;
}

.viewer {
position: relative;
width: 100%;
height: 100%;
}

.viewport {
width: 600px;
height: 800px;
/* height: 600px; */
border: 1px solid #eee;
box-sizing: border-box;
}

.reset {
position: absolute !important;
background: #333;
width: 30px;
height: 30px;
z-index: 1;
border-right: 1px solid #444;
border-bottom: 1px solid #444;
box-sizing: border-box;
cursor: pointer;
}

.guides {
position: absolute !important;
top: 0;
left: 0;
transform: translateZ(1px);
}

.guides.horizontal {
left: 30px;
width: calc(100% - 30px);
height: 30px !important;
}

.guides.vertical {
top: 30px;
height: calc(100% - 30px);
width: 30px !important;
}

/*
.scena-vertical .scena-guide {
height: calc(100% + 30px)!important;
top: -30px;
}
.scena-horizontal .scena-guide {
width: calc(100% + 30px)!important;
top: -30px;
} */
.viewer {
position: absolute !important;
left: 30px;
top: 30px;
width: calc(100% - 30px);
height: calc(100% - 30px);
}

.viewport {
text-align: center;
}

.viewport p {
padding: 0;
margin: 0;
}

.buttons {
padding: 5px;
}

.button {
display: inline-block;
padding: 10px 20px;
border: 2px solid #333;
color: #333;
font-weight: bold;
text-decoration: none;
font-size: 14px;
letter-spacing: 1px;
margin: 2px;
}

.viewport p.description {
text-align: left;
padding: 5px 20px;
box-sizing: border-box;
}

.component {
display: inline-block;
padding: 5px;
margin-bottom: 10px;
}

.component p {
padding: 0;
margin: 0;
}

.component .logo {
position: relative;
width: 150px;
height: 150px;
}

.component img {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: auto;
max-height: 100%;
transform: translate(-50%, -50%);
box-sizing: border-box;
}

.component a {
color: black;
font-weight: bold;
}
</style>
<div class="app">
<div class="reset"></div>
<div class="guides horizontal"></div>
<div class="guides vertical"></div>

</div>
<script src ="../../dist/guides.js"></script>
<script>

const horizontalGuides = new Guides(document.querySelector(".guides.horizontal"), {
snapThreshold: 5,
snaps: [0, 300, 600],
displayDragPos: true,
dragPosFormat: v => `${v}px`,
}).on("changeGuides", ({ guides }) => {
console.log("ho", guides);
// moveable.horizontalGuidelines = guides;
});

const verticalGuides = new Guides(document.querySelector(".guides.vertical"), {
type: "vertical",
snapThreshold: 5,
snaps: [0, 200, 400],
displayDragPos: true,
dragPosFormat: v => `${v}px`,
}).on("changeGuides", ({ guides }) => {
console.log("ver", guides);
});

</script>

0 comments on commit a8acea3

Please sign in to comment.