You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-5Lines changed: 27 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,16 @@ Add it globally:
32
32
```
33
33
import ConnectionAware from 'vue-connection-aware';
34
34
35
-
Vue.use(ConnectionAware);
35
+
// Using default options.
36
+
Vue.use(ConnectionAware);
37
+
38
+
// Or specifying the different category thresholds.
39
+
Vue.use(ConnectionAware, {
40
+
connectionCategoryThreshold: {
41
+
slow: 1,
42
+
medium: 3
43
+
}
44
+
});
36
45
```
37
46
38
47
or import it directly into your component:
@@ -48,6 +57,19 @@ export default {
48
57
};
49
58
```
50
59
60
+
### Connection category thresholds
61
+
62
+
The default connection category thresholds, in Mbps, are:
63
+
```
64
+
slow: 2,
65
+
medium: 6,
66
+
fast: Number.MAX_SAFE_INTEGER
67
+
```
68
+
69
+
This means that any download speed up to 2 Mbps, will be considered as `slow`. Any connection above 2 Mbps up to 6 Mbps will be considered as `medium`. Anything above that will be `fast`. You can override these defaults by specifying the defaults when installing the component as a plugin.
70
+
71
+
Each web application will have different requirements, and that's why you can configure the different thresholds.
72
+
51
73
## ⌨️ Usage
52
74
53
75
Wrap the DOM element you want to render for a specific effective connection type with the component markup:
@@ -66,10 +88,10 @@ _Note: if no speed prop (i.e. `slow`, `medium` or `fast`) is specified, the comp
66
88
67
89
| Name | Type | Required | Default | Description |
|`fast`|`Boolean`|`false`|`false`| Render the component when the effective type is `4g`|
70
-
|`medium`|`Boolean`|`false`|`false`| Render the component when the effective type is `3g`|
71
-
|`slow`|`Boolean`|`false`|`false`| Render the component when the effective type is `2g`or `slow-2g`|
72
-
|`reactive`|`Boolean`|`false`|`true`| The component reacts to changes in the connection (e.g. if a component was initially rendered with a `4g` connection, hide it if the connection drops to `3g`) |
91
+
|`fast`|`Boolean`|`false`|`false`| Render the component when the download speed is greater than the `medium` connection threshold|
92
+
|`medium`|`Boolean`|`false`|`false`| Render the component when the download speed is greater than the `slow` connection threshold and less than or equal to the `medium` connection threshold|
93
+
|`slow`|`Boolean`|`false`|`false`| Render the component when the download speed is less than or equal to the `slow` connection threshold|
94
+
|`reactive`|`Boolean`|`false`|`true`| The component reacts to changes in the connection (e.g. if a component was initially rendered with a `fast` connection, hide it if the connection drops to `medium`) |
73
95
|`online`|`Boolean`|`false`|`true`| Render the component when its online status matches this property (e.g. if `false`, the component will render only when the browser is offline) |
0 commit comments