Skip to content

Commit 13ee074

Browse files
committed
Merge branch 'release/1.0.0' into new/simulator-fixes
2 parents 7e708a5 + cdb3a6d commit 13ee074

File tree

9 files changed

+283
-162
lines changed

9 files changed

+283
-162
lines changed

docs/view-default.md

+35-9
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ interface IOrbViewSettings {
6363
};
6464
// For canvas rendering and events
6565
render: {
66+
devicePixelRatio: number | null;
6667
fps: number;
6768
minZoom: number;
6869
maxZoom: number;
@@ -74,6 +75,7 @@ interface IOrbViewSettings {
7475
contextAlphaOnEvent: number;
7576
contextAlphaOnEventIsEnabled: boolean;
7677
backgroundColor: Color | string | null;
78+
areCollapsedContainerDimensionsAllowed: boolean;
7779
};
7880
// For select and hover look-and-feel
7981
strategy: {
@@ -137,6 +139,7 @@ const defaultSettings = {
137139
},
138140
},
139141
render: {
142+
devicePixelRatio: window.devicePixelRatio,
140143
fps: 60,
141144
minZoom: 0.25,
142145
maxZoom: 8,
@@ -148,6 +151,7 @@ const defaultSettings = {
148151
contextAlphaOnEvent: 0.3,
149152
contextAlphaOnEventIsEnabled: true,
150153
backgroundColor: null,
154+
areCollapsedContainerDimensionsAllowed: false,
151155
},
152156
strategy: {
153157
isDefaultSelectEnabled: true,
@@ -267,26 +271,46 @@ Here you can use your original properties to indicate which ones represent your
267271
Optional property `render` has several rendering options that you can tweak. Read more about them
268272
on [Styling guide](./styles.md).
269273

274+
#### Property `render.devicePixelRatio`
275+
276+
`devicePixelRatio` is useful when dealing with the difference between rendering on a standard
277+
display versus a HiDPI or Retina display, which uses more screen pixels to draw the same
278+
objects, resulting in a sharper image. ([Reference: MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio)).
279+
Orb will listen for `devicePixelRatio` changes and handles them by default. You can override the
280+
value with a settings property `render.devicePixelRatio`. Once a custom value is provided, Orb will
281+
stop listening for `devicePixelRatio` changes.
282+
If you want to return automatic `devicePixelRatio` handling, just set `render.devicePixelRatio`
283+
to `null`.
284+
285+
#### Property `render.areCollapsedContainerDimensionsAllowed`
286+
287+
Enables setting the dimensions of the Orb container element to zero.
288+
If the container element of Orb has collapsed dimensions (`width: 0;` or `height: 0;`),
289+
Orb will expand the container by setting the values to `100%`.
290+
If that doesn't work (the parent of the container also has collapsed dimensions),
291+
Orb will set an arbitrary fixed dimension to the container.
292+
Disabled by default (`false`).
293+
270294
### Property `strategy`
271295

272296
The optional property `strategy` has two properties that you can enable/disable:
273297

274-
* `isDefaultSelectEnabled` - when `true`, the default selection strategy is used on mouse click:
275-
* If there is a node at the mouse click point, the node, its edges, and adjacent nodes will change
298+
- `isDefaultSelectEnabled` - when `true`, the default selection strategy is used on mouse click:
299+
- If there is a node at the mouse click point, the node, its edges, and adjacent nodes will change
276300
its state to `GraphObjectState.SELECTED`. Style properties that end with `...Selected` will be
277301
applied to all the selected objects (e.g. `borderColorSelected`).
278-
* If there is an edge at the mouse click point, the edge and its starting and ending nodes will change
302+
- If there is an edge at the mouse click point, the edge and its starting and ending nodes will change
279303
its state to `GraphObjectState.SELECTED`.
280-
* `isDefaultHoverEnabled` - when `true`, the default hover strategy is used on mouse move:
281-
* If there is a node at the mouse pointer, the node, its edges, and adjacent nodes will change its state to
304+
- `isDefaultHoverEnabled` - when `true`, the default hover strategy is used on mouse move:
305+
- If there is a node at the mouse pointer, the node, its edges, and adjacent nodes will change its state to
282306
`GraphObjectState.HOVERED`. Style properties that end with `...Hovered` will be applied to all the
283307
hovered objects (e.g. `borderColorHovered`).
284308

285309
With property `strategy` you can disable the above behavior and implement your select/hover strategy on
286310
top of events `OrbEventType.MOUSE_CLICK` and `OrbEventType.MOUSE_MOVE`, e.g:
287311

288312
```typescript
289-
import { isNode, OrbEventType, GraphObjectState } from '@memgraph/orb';
313+
import { isNode, OrbEventType, GraphObjectState } from "@memgraph/orb";
290314

291315
// Disable default select and hover strategy
292316
orb.setSettings({
@@ -311,7 +335,9 @@ orb.events.on(OrbEventType.MOUSE_CLICK, (event) => {
311335
// Clicked on unselected node
312336
if (event.subject && isNode(event.subject) && !event.subject.isSelected()) {
313337
// Deselect the previously selected nodes
314-
orb.data.getNodes((node) => node.isSelected()).forEach((node) => node.clearState());
338+
orb.data
339+
.getNodes((node) => node.isSelected())
340+
.forEach((node) => node.clearState());
315341
// Select the new node
316342
event.subject.state = GraphObjectState.SELECTED;
317343
orb.render();
@@ -323,9 +349,9 @@ orb.events.on(OrbEventType.MOUSE_CLICK, (event) => {
323349

324350
The optional property `interaction` has two properties that you can enable/disable:
325351

326-
* `isDragEnabled` - property controls the dragging behavior within the application. When it is set to `true`, dragging is enabled, allowing users to interact with nodes and edges by dragging them to different positions within the graph. On the other hand, when `isDragEnabled`` is set to false, dragging functionality is disabled, preventing users from moving or repositioning nodes and edges through dragging interactions.
352+
- `isDragEnabled` - property controls the dragging behavior within the application. When it is set to `true`, dragging is enabled, allowing users to interact with nodes and edges by dragging them to different positions within the graph. On the other hand, when `isDragEnabled`` is set to false, dragging functionality is disabled, preventing users from moving or repositioning nodes and edges through dragging interactions.
327353

328-
* `isZoomEnabled` - This property controls the zooming behavior within the application. Setting it to `true` enables zooming, allowing users to interactively zoom in and out of the graph. Setting it to `false` disables zooming, restricting the user's ability to change the zoom level.
354+
- `isZoomEnabled` - This property controls the zooming behavior within the application. Setting it to `true` enables zooming, allowing users to interactively zoom in and out of the graph. Setting it to `false` disables zooming, restricting the user's ability to change the zoom level.
329355

330356
These properties provide a straightforward way to enable or disable dragging and zooming features based on the needs and requirements of your application. By toggling the values of isDragEnabled and isZoomEnabled, you can easily control the interactivity options available to users. e.g:
331357

docs/view-map.md

+22-9
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ interface IOrbMapViewSettings {
116116
getGeoPosition(node: INode): { lat: number; lng: number } | undefined;
117117
// For canvas rendering and events
118118
render: {
119+
devicePixelRatio: number | null;
119120
fps: number;
120121
minZoom: number;
121122
maxZoom: number;
@@ -147,6 +148,7 @@ The default settings that `OrbMapView` uses is:
147148
```typescript
148149
const defaultSettings = {
149150
render: {
151+
devicePixelRatio: window.devicePixelRatio,
150152
fps: 60,
151153
minZoom: 0.25,
152154
maxZoom: 8,
@@ -191,6 +193,26 @@ Optional property `map` has two properties that you can set which are:
191193
Optional property `render` has several rendering options that you can tweak. Read more about them
192194
on [Styling guide](./styles.md).
193195

196+
#### Property `render.devicePixelRatio`
197+
198+
`devicePixelRatio` is useful when dealing with the difference between rendering on a standard
199+
display versus a HiDPI or Retina display, which uses more screen pixels to draw the same
200+
objects, resulting in a sharper image. ([Reference: MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio)).
201+
Orb will listen for `devicePixelRatio` changes and handles them by default. You can override the
202+
value with a settings property `render.devicePixelRatio`. Once a custom value is provided, Orb will
203+
stop listening for `devicePixelRatio` changes.
204+
If you want to return automatic `devicePixelRatio` handling, just set `render.devicePixelRatio`
205+
to `null`.
206+
207+
#### Property `render.areCollapsedContainerDimensionsAllowed`
208+
209+
Enables setting the dimensions of the Orb container element to zero.
210+
If the container element of Orb has collapsed dimensions (`width: 0;` or `height: 0;`),
211+
Orb will expand the container by setting the values to `100%`.
212+
If that doesn't work (the parent of the container also has collapsed dimensions),
213+
Orb will set an arbitrary fixed dimension to the container.
214+
Disabled by default (`false`).
215+
194216
### Property `strategy`
195217

196218
The optional property `strategy` has two properties that you can enable/disable:
@@ -243,15 +265,6 @@ orb.events.on(OrbEventType.MOUSE_CLICK, (event) => {
243265
});
244266
```
245267

246-
### Property `areCollapsedContainerDimensionsAllowed`
247-
248-
Enables setting the dimensions of the Orb container element to zero.
249-
If the container element of Orb has collapsed dimensions (`width: 0;` or `height: 0;`),
250-
Orb will expand the container by setting the values to `100%`.
251-
If that doesn't work (the parent of the container also has collapsed dimensions),
252-
Orb will set an arbitrary fixed dimension to the container.
253-
Disabled by default (`false`).
254-
255268
## Settings
256269

257270
The above settings of `OrbMapView` can be defined on view initialization, but also anytime after the

0 commit comments

Comments
 (0)