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
Sometimes when building an app you need to have access to the screen's dimensions. Usually that's going to be done in the css using `@media` - but sometimes you need to access that info right in your JavaScript.
40
38
41
39
The issue with this is you have to worry about adding event listeners and then removing them later. We wanted to just be able to import something quickly and then be able to forget about it later. So this `mixin` does just that - just use `Vue.use()` or `mixins: [],` and you're off.
42
40
43
41
There is something to consider - where and how you include this library. There are two ways, make sure to be aware of the differences:
44
42
45
-
###Usage Example 1 - Whole app has access (Not Recommended)
43
+
## Usage Example 1 - Whole app has access (Not Recommended)
46
44
47
45
In this usage - your whole app - and every child component - has access to the `$vssWidth`, `$vssHeight`, and `$vssEvent` variables. This is sorta pollutive though, as multiple instances of the mixin are initialized and it's kinda wasteful. The is due to the way Vue mixins are passed down to child components. You can read more about this [here](https://vuejs.org/v2/guide/mixins.html#Global-Mixin). The second example is recommended.
// Access `this.$vssWidth`, `this.$vssHeight`, and `this.$vssEvent` anywhere in your app.
54
53
```
55
54
56
-
###Usage Example 2 - Just the component you install it on has access - (Recommended)
55
+
## Usage Example 2 - Just the component you install it on has access - (Recommended)
57
56
58
57
In this usage - the component you install it on will have access to the `$vssWidth`, `$vssHeight`, and `$vssEvent` variables. This may be a bit more restrictive, but it's less wasteful and should give you better performance.
| $vssDestroyListener | none | Force the removal of the attached event listener |
82
+
83
+
## Development
86
84
87
85
```bash
88
-
#install dependencies
89
-
npm install
86
+
#Install dependencies
87
+
yarn
90
88
91
-
#serve with hot reload
92
-
npm run watch
89
+
#Serve with hot reload
90
+
yarn dev
93
91
94
-
#run the tests
95
-
npm runtest
92
+
#Run the tests
93
+
yarntest
96
94
97
-
#build demo page
98
-
npm run build:example
95
+
#Build demo page
96
+
yarn build:example
99
97
100
-
#build
101
-
npm run build
98
+
#Build library
99
+
yarn build:library
102
100
103
-
#publish to npm
104
-
npm publish
101
+
#Build everything and run tests
102
+
yarn build
105
103
```
106
104
107
-
###Other
105
+
## Other
108
106
109
107
Go ahead and fork the project! Submit an issue if needed. Have fun!
110
108
111
-
###License
109
+
## License
112
110
113
111
[MIT](http://opensource.org/licenses/MIT)
114
-
115
-
Packaged with a mixture of [vue-lib-template](https://github.com/biigpongsatorn/vue-lib-template) and [vue-sfc-rollup](https://github.com/team-innovation/vue-sfc-rollup).
0 commit comments