2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-10 07:52:23 +03:00

Fix code style issues

This commit is contained in:
Lexxus
2017-12-29 12:07:15 +02:00
parent a54c4123e9
commit 4bf6c0ce44
7 changed files with 1353 additions and 1340 deletions
+21 -14
View File
@@ -2,7 +2,7 @@
module.exports = {
watch: {
typeAheadPointer() {
typeAheadPointer () {
this.maybeAdjustScroll()
}
},
@@ -14,14 +14,14 @@ module.exports = {
* overflow bounds.
* @returns {*}
*/
maybeAdjustScroll() {
maybeAdjustScroll () {
let pixelsToPointerTop = this.pixelsToPointerTop()
let pixelsToPointerBottom = this.pixelsToPointerBottom()
if ( pixelsToPointerTop <= this.viewport().top) {
return this.scrollTo( pixelsToPointerTop )
if (pixelsToPointerTop <= this.viewport().top) {
return this.scrollTo(pixelsToPointerTop)
} else if (pixelsToPointerBottom >= this.viewport().bottom) {
return this.scrollTo( this.viewport().top + this.pointerHeight() )
return this.scrollTo(this.viewport().top + this.pointerHeight())
}
},
@@ -30,9 +30,10 @@ module.exports = {
* list to the top of the current pointer element.
* @returns {number}
*/
pixelsToPointerTop() {
pixelsToPointerTop () {
let pixelsToPointerTop = 0
if( this.$refs.dropdownMenu ) {
if (this.$refs.dropdownMenu) {
for (let i = 0; i < this.typeAheadPointer; i++) {
pixelsToPointerTop += this.$refs.dropdownMenu.children[i].offsetHeight
}
@@ -45,7 +46,7 @@ module.exports = {
* list to the bottom of the current pointer element.
* @returns {*}
*/
pixelsToPointerBottom() {
pixelsToPointerBottom () {
return this.pixelsToPointerTop() + this.pointerHeight()
},
@@ -53,7 +54,7 @@ module.exports = {
* The offsetHeight of the current pointer element.
* @returns {number}
*/
pointerHeight() {
pointerHeight () {
let element = this.$refs.dropdownMenu ? this.$refs.dropdownMenu.children[this.typeAheadPointer] : false
return element ? element.offsetHeight : 0
},
@@ -62,9 +63,9 @@ module.exports = {
* The currently viewable portion of the dropdownMenu.
* @returns {{top: (string|*|number), bottom: *}}
*/
viewport() {
viewport () {
return {
top: this.$refs.dropdownMenu ? this.$refs.dropdownMenu.scrollTop: 0,
top: this.$refs.dropdownMenu ? this.$refs.dropdownMenu.scrollTop : 0,
bottom: this.$refs.dropdownMenu ? this.$refs.dropdownMenu.offsetHeight + this.$refs.dropdownMenu.scrollTop : 0
}
},
@@ -74,8 +75,14 @@ module.exports = {
* @param position
* @returns {*}
*/
scrollTo(position) {
return this.$refs.dropdownMenu ? this.$refs.dropdownMenu.scrollTop = position : null
},
scrollTo (position) {
let result = null
if (this.$refs.dropdownMenu) {
result = this.$refs.dropdownMenu.scrollTop = position
}
return result
}
}
}