@rpg-engine/long-bow 0.1.792 → 0.1.794

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.1.792",
3
+ "version": "0.1.794",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -130,7 +130,7 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = observer(
130
130
  cancelDrag=".equipment-container-body"
131
131
  onPositionChange={({ x, y }) => {
132
132
  setDraggablePosition({ x, y });
133
- // uiStore.setDraggablePosition({ x, y });
133
+ console.log(draggablePosition)
134
134
  }}
135
135
  onOutsideClick={() => {
136
136
  uiStore.clearContextMenu();
@@ -145,8 +145,8 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = observer(
145
145
 
146
146
  {uiStore.contextMenu?.visible ? (
147
147
  <ListMenu
148
- x={uiStore.contextMenu.posX - draggablePosition.x}
149
- y={uiStore.contextMenu.posY - draggablePosition.y}
148
+ x={uiStore.contextMenu.posX - uiStore.draggablePosition.x}
149
+ y={uiStore.contextMenu.posY - uiStore.draggablePosition.y}
150
150
  options={uiStore.contextMenu.contextActions}
151
151
  onSelected={onSelected}
152
152
  />
@@ -122,6 +122,9 @@ class UIStore {
122
122
  this.clearItemHoverDetail();
123
123
  return;
124
124
  }
125
+
126
+ this.setDraggablePosition(this.getOffsets())
127
+
125
128
  switch (slotContainerType) {
126
129
  case SlotContainerType.EQUIPMENT_SET:
127
130
  this.setEquipContextMenu(
@@ -170,10 +173,11 @@ class UIStore {
170
173
  onMouseOver: any
171
174
  ): void => {
172
175
  if (item) {
176
+ this.setDraggablePosition(this.getOffsets())
173
177
  this.setItemHoverDetail({
174
178
  visible: true,
175
- posX,
176
- posY,
179
+ posX: posX,
180
+ posY: posY,
177
181
  item: item,
178
182
  });
179
183
  }
@@ -196,9 +200,32 @@ class UIStore {
196
200
  this.clearContextMenu!();
197
201
  }
198
202
 
199
- public setDraggablePosition(currentPosition: IPosition){
200
- this.draggablePosition = { ...currentPosition }
201
- }
203
+ public setDraggablePosition(currentPosition: IPosition){
204
+ this.draggablePosition = { ...currentPosition }
205
+ }
206
+
207
+ private getOffsets = () => {
208
+ const p = { x: 0, y: 0};
209
+ // const body = document.getElementsByTagName('body')
210
+ let body = document.querySelector('body') as any | null;
211
+
212
+ if( body != null){
213
+ p.x = body.offsetLeft;
214
+ p.y = body.offsetTop;
215
+ while(body!.offsetParent){
216
+ console.log(`offsetParent: ${body!.offsetParent}`)
217
+ p.x = p.x + body!.offsetLeft
218
+ p.y = p.y + body!.offsetTop;
219
+ if (body == document.getElementsByTagName("body")[0]) {
220
+ break;
221
+ }
222
+ else {
223
+ body = body!.offsetParent;
224
+ }
225
+ }
226
+ }
227
+ return p;
228
+ }
202
229
 
203
230
  }
204
231