remove Array.find to make IE11 happy

This commit is contained in:
Sergio Crisostomo 2017-09-26 22:50:57 +02:00
parent a65aef1a56
commit d5e4481451

View file

@ -171,30 +171,26 @@
const times = ['hours', 'minutes', 'seconds']; const times = ['hours', 'minutes', 'seconds'];
this.$nextTick(() => { this.$nextTick(() => {
times.forEach(type => { times.forEach(type => {
this.$refs[type].scrollTop = 24 * this.getItemIndex(type, this[type]); this.$refs[type].scrollTop = 24 * this[`${type}List`].findIndex(obj => obj.text == this[type]);
}); });
}); });
}, },
formatTime (text) { formatTime (text) {
return text < 10 ? '0' + text : text; return text < 10 ? '0' + text : text;
},
getItemIndex(type, val){
const item = this[`${type}List`].find(obj => obj.text == val);
return this[`${type}List`].indexOf(item);
} }
}, },
watch: { watch: {
hours (val) { hours (val) {
if (!this.compiled) return; if (!this.compiled) return;
this.scroll('hours', this.getItemIndex('hours', val)); this.scroll('hours', this.hoursList.findIndex(obj => obj.text == val));
}, },
minutes (val) { minutes (val) {
if (!this.compiled) return; if (!this.compiled) return;
this.scroll('minutes', this.getItemIndex('minutes', val)); this.scroll('minutes', this.minutesList.findIndex(obj => obj.text == val));
}, },
seconds (val) { seconds (val) {
if (!this.compiled) return; if (!this.compiled) return;
this.scroll('seconds', this.getItemIndex('seconds', val)); this.scroll('seconds', this.secondsList.findIndex(obj => obj.text == val));
} }
}, },
mounted () { mounted () {