Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
Update Slider
Browse files Browse the repository at this point in the history
  • Loading branch information
okoala committed Dec 7, 2015
1 parent 2634b2f commit ad31fd8
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions components/base/slider/Dots.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<div :class="prefixCls + '-step"}>
<span v-for="item in dotsArr" :class="item.pointClass" :style="item.style" :key="item.point"></span>
</div>
</template>
<script>
import { cx } from '../../../utils'
const calcPoints = function (marks, dots, step, min, max) {
const points = Object.keys(marks).map(parseFloat)
if (dots) {
for (let i = min; i <= max; i = i + step) {
points.push(i)
}
}
return points
}
export default {
props: ['prefixCls', 'marks', 'dots', 'step', 'included',
'lowerBound', 'upperBound', 'max', 'min'],
computed: {
dotsArr () {
calcPoints(this.marks, this.dots, this.step, this.min, this.max).map((point) => {
const res = {}
const offset = (point - this.min) / this.range * 100 + '%'
res.point = point
res.style = {left: offset}
res.isActived = (!this.included && point === this.upperBound) ||
(this.included && point <= this.upperBound && point >= this.lowerBound)
res.pointClass = cx({
[`${prefixCls} + '-dot'`]: 1,
[`${prefixCls} + '-dot-active'`]: res.isActived
})
return res
})
}
}
}
</script>

0 comments on commit ad31fd8

Please sign in to comment.