This commit is contained in:
cookfront 2017-03-03 16:42:53 +08:00
parent 0637c6eeeb
commit 082b23927b
2 changed files with 13 additions and 13 deletions

View File

@ -54,14 +54,14 @@ export default {
set(val) { set(val) {
if (this.isGroup && this.parentGroup) { if (this.isGroup && this.parentGroup) {
let parentValue = this.parentGroup.value.slice(); const parentValue = this.parentGroup.value.slice();
if (val) { if (val) {
if (parentValue.indexOf(this.name) === -1) { if (parentValue.indexOf(this.name) === -1) {
parentValue.push(this.name); parentValue.push(this.name);
this.parentGroup.$emit('input', parentValue); this.parentGroup.$emit('input', parentValue);
} }
} else { } else {
let index = parentValue.indexOf(this.name); const index = parentValue.indexOf(this.name);
if (index !== -1) { if (index !== -1) {
parentValue.splice(index, 1); parentValue.splice(index, 1);
this.parentGroup.$emit('input', parentValue); this.parentGroup.$emit('input', parentValue);

View File

@ -104,7 +104,7 @@ export default {
var visibileColumnCount = this.visibileColumnCount; var visibileColumnCount = this.visibileColumnCount;
var itemHeight = this.itemHeight; var itemHeight = this.itemHeight;
return [ -itemHeight * (values.length - Math.ceil(visibileColumnCount / 2)), itemHeight * Math.floor(visibileColumnCount / 2) ]; return [-itemHeight * (values.length - Math.ceil(visibileColumnCount / 2)), itemHeight * Math.floor(visibileColumnCount / 2)];
}, },
/** /**
@ -125,10 +125,10 @@ export default {
* 将当前`value`值转换成需要垂直方向需要`translate`的值 * 将当前`value`值转换成需要垂直方向需要`translate`的值
*/ */
value2Translate(value) { value2Translate(value) {
let values = this.currentValues; const values = this.currentValues;
let valueIndex = values.indexOf(value); const valueIndex = values.indexOf(value);
let offset = Math.floor(this.visibileColumnCount / 2); const offset = Math.floor(this.visibileColumnCount / 2);
let itemHeight = this.itemHeight; const itemHeight = this.itemHeight;
if (valueIndex !== -1) { if (valueIndex !== -1) {
return (valueIndex - offset) * (-itemHeight); return (valueIndex - offset) * (-itemHeight);
@ -139,10 +139,10 @@ export default {
* 根据当前`translate`的值转换成当前选中的`value` * 根据当前`translate`的值转换成当前选中的`value`
*/ */
translate2Value(translate) { translate2Value(translate) {
let itemHeight = this.itemHeight; const itemHeight = this.itemHeight;
translate = Math.round(translate / itemHeight) * itemHeight; translate = Math.round(translate / itemHeight) * itemHeight;
let index = -(translate - Math.floor(this.visibileColumnCount / 2) * itemHeight) / itemHeight; const index = -(translate - Math.floor(this.visibileColumnCount / 2) * itemHeight) / itemHeight;
return this.currentValues[index]; return this.currentValues[index];
}, },
@ -177,8 +177,8 @@ export default {
dragState.left = event.pageX; dragState.left = event.pageX;
dragState.top = event.pageY; dragState.top = event.pageY;
let deltaY = dragState.top - dragState.startTop; const deltaY = dragState.top - dragState.startTop;
let translate = dragState.startTranslateTop + deltaY; const translate = dragState.startTranslateTop + deltaY;
translateUtil.translateElement(el, null, translate); translateUtil.translateElement(el, null, translate);
@ -229,8 +229,8 @@ export default {
* `value`改变时调用 * `value`改变时调用
*/ */
doOnValueChange() { doOnValueChange() {
let value = this.currentValue; const value = this.currentValue;
let wrapper = this.$refs.wrapper; const wrapper = this.$refs.wrapper;
this.$emit('input', this.currentValue); this.$emit('input', this.currentValue);