perfect-gui 4.12.4 → 4.12.5

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,7 +1,7 @@
1
1
  {
2
2
  "name": "perfect-gui",
3
3
  "type": "module",
4
- "version": "4.12.4",
4
+ "version": "4.12.5",
5
5
  "description": "GUI for JavaScript",
6
6
  "main": "src/index.js",
7
7
  "scripts": {
@@ -115,13 +115,25 @@ export default class Vector2 {
115
115
  dot.className = 'p-gui__vector2-dot';
116
116
  area.append(dot);
117
117
 
118
- dot.style.left = this.parent._mapLinear(objectX[propX], minX, maxX, 0, area.clientWidth) + 'px';
119
- dot.style.top = this.parent._mapLinear(objectY[propY], minY, maxY, area.clientHeight, 0) + 'px';
118
+ // Function to update dot position based on current values
119
+ const updateDotPosition = () => {
120
+ dot.style.left = this.parent._mapLinear(objectX[propX], minX, maxX, 0, area.clientWidth) + 'px';
121
+ dot.style.top = this.parent._mapLinear(objectY[propY], minY, maxY, area.clientHeight, 0) + 'px';
122
+ };
123
+
124
+ // Initial position
125
+ updateDotPosition();
126
+
127
+ // Observe area resize (e.g., when scrollbars appear/disappear)
128
+ const resizeObserver = new ResizeObserver(() => {
129
+ updateDotPosition();
130
+ });
131
+ resizeObserver.observe(area);
120
132
 
121
133
  Object.defineProperty( objectX, propX, {
122
134
  set: val => {
123
135
  this.parent.propReferences[propXReferenceIndex] = val;
124
- dot.style.left = this.parent._mapLinear(val, minX, maxX, 0, area.clientWidth) + 'px';
136
+ updateDotPosition();
125
137
  vector_value.textContent = String( val ) + ', ' + objectY[propY];
126
138
  },
127
139
  get: () => {
@@ -132,7 +144,7 @@ export default class Vector2 {
132
144
  Object.defineProperty( objectY, propY, {
133
145
  set: val => {
134
146
  this.parent.propReferences[propYReferenceIndex] = val;
135
- dot.style.top = this.parent._mapLinear(val, minY, maxY, area.clientHeight, 0) + 'px';
147
+ updateDotPosition();
136
148
  vector_value.textContent = objectX[propX] + ', ' + String( val );
137
149
  },
138
150
  get: () => {