diff --git a/src/slider/index.js b/src/slider/index.js
index 9cbda38c5..d04f19605 100644
--- a/src/slider/index.js
+++ b/src/slider/index.js
@@ -148,16 +148,16 @@ export default createComponent({
render() {
const { vertical } = this;
- const style = {
- background: this.inactiveColor,
- };
-
const mainAxis = vertical ? 'height' : 'width';
const crossAxis = vertical ? 'width' : 'height';
+ const wrapperStyle = {
+ background: this.inactiveColor,
+ [crossAxis]: addUnit(this.barHeight),
+ };
+
const barStyle = {
[mainAxis]: `${((this.value - this.min) * 100) / this.range}%`,
- [crossAxis]: addUnit(this.barHeight),
background: this.activeColor,
};
@@ -167,7 +167,7 @@ export default createComponent({
return (
diff --git a/src/slider/index.less b/src/slider/index.less
index 32c8d7419..6919ffe0c 100644
--- a/src/slider/index.less
+++ b/src/slider/index.less
@@ -3,6 +3,7 @@
.van-slider {
position: relative;
width: 100%;
+ height: @slider-bar-height;
background-color: @slider-inactive-background-color;
border-radius: @border-radius-max;
cursor: pointer;
@@ -19,7 +20,8 @@
&__bar {
position: relative;
- height: @slider-bar-height;
+ width: 100%;
+ height: 100%;
background-color: @slider-active-background-color;
border-radius: inherit;
transition: width @animation-duration-fast;
@@ -57,8 +59,17 @@
.van-slider__button-wrapper {
top: auto;
+ right: 50%;
bottom: 0;
transform: translate3d(50%, 50%, 0);
}
+
+ // use pseudo element to expand click area
+ &::before {
+ top: 0;
+ right: -@padding-xs;
+ bottom: 0;
+ left: -@padding-xs;
+ }
}
}
diff --git a/src/slider/test/__snapshots__/demo.spec.js.snap b/src/slider/test/__snapshots__/demo.spec.js.snap
index cd3c5207c..e1a65f6e5 100644
--- a/src/slider/test/__snapshots__/demo.spec.js.snap
+++ b/src/slider/test/__snapshots__/demo.spec.js.snap
@@ -39,8 +39,8 @@ exports[`renders demo correctly 1`] = `
-
-
+
+
diff --git a/src/slider/test/__snapshots__/index.spec.js.snap b/src/slider/test/__snapshots__/index.spec.js.snap
index cf80160ac..e63f4f6d0 100644
--- a/src/slider/test/__snapshots__/index.spec.js.snap
+++ b/src/slider/test/__snapshots__/index.spec.js.snap
@@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`bar-height prop 1`] = `
-