Skip to content
This repository was archived by the owner on Feb 24, 2023. It is now read-only.

Commit 7801a15

Browse files
author
Łukasz Florczak
committed
Helpers methods mixin
1 parent d28c3ab commit 7801a15

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/mixins/helpers.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Helpers methods
3+
*/
4+
const mixin = {
5+
methods: {
6+
/**
7+
* Convert HTML Collection to JS Array
8+
*/
9+
htmlCollectionToArray (collection) {
10+
return Array.prototype.slice.call(collection, 0)
11+
},
12+
13+
/**
14+
* Compare elements for breakpoints sorting
15+
*/
16+
compare (a, b) {
17+
if (a.breakpoint < b.breakpoint) {
18+
return (this.initialSettings.mobileFirst) ? -1 : 1
19+
} else if (a.breakpoint > b.breakpoint) {
20+
return (this.initialSettings.mobileFirst) ? 1 : -1
21+
} else {
22+
return 0
23+
}
24+
},
25+
26+
/**
27+
* Set window & container width
28+
*/
29+
getWidth () {
30+
this.widthWindow = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
31+
this.widthContainer = this.$refs.list.clientWidth
32+
}
33+
}
34+
}
35+
36+
export default mixin

0 commit comments

Comments
 (0)