Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
f86427f2
Commit
f86427f2
authored
Mar 10, 2017
by
Gabriel Oliveira
Committed by
杨奕
Mar 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slider: add show-tooltip prop
parent
cf909dda
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
22 deletions
+56
-22
examples/docs/en-US/slider.md
examples/docs/en-US/slider.md
+24
-17
packages/slider/src/button.vue
packages/slider/src/button.vue
+9
-5
packages/slider/src/main.vue
packages/slider/src/main.vue
+4
-0
test/unit/specs/slider.spec.js
test/unit/specs/slider.spec.js
+19
-0
No files found.
examples/docs/en-US/slider.md
View file @
f86427f2
...
...
@@ -4,11 +4,12 @@
return {
value1: 0,
value2: 50,
value3:
42
,
value4:
0
,
value3:
36
,
value4:
42
,
value5: 0,
value6: 0,
value7:
[
4, 8
]
value7: 0,
value8:
[
4, 8
]
};
}
}
...
...
@@ -34,9 +35,13 @@ The current value is displayed when the slider is being dragged.
<span
class=
"demonstration"
>
Customized initial value
</span>
<el-slider
v-model=
"value2"
></el-slider>
</div>
<div
class=
"block"
>
<span
class=
"demonstration"
>
Hide Tooltip
</span>
<el-slider
v-model=
"value3"
:show-tooltip=
"false"
></el-slider>
</div>
<div
class=
"block"
>
<span
class=
"demonstration"
>
Disabled
</span>
<el-slider
v-model=
"value
3
"
disabled
></el-slider>
<el-slider
v-model=
"value
4
"
disabled
></el-slider>
</div>
</template>
...
...
@@ -46,7 +51,8 @@ The current value is displayed when the slider is being dragged.
return
{
value1
:
0
,
value2
:
50
,
value3
:
42
value3
:
36
,
value4
:
42
}
}
}
...
...
@@ -65,14 +71,14 @@ The options can be discrete.
<div
class=
"block"
>
<span
class=
"demonstration"
>
Breakpoints not displayed
</span>
<el-slider
v-model=
"value
4
"
v-model=
"value
5
"
:step=
"10"
>
</el-slider>
</div>
<div
class=
"block"
>
<span
class=
"demonstration"
>
Breakpoints displayed
</span>
<el-slider
v-model=
"value
5
"
v-model=
"value
6
"
:step=
"10"
show-stops
>
</el-slider>
...
...
@@ -83,8 +89,8 @@ The options can be discrete.
export
default
{
data
()
{
return
{
value
4
:
0
,
value
5
:
0
value
5
:
0
,
value
6
:
0
}
}
}
...
...
@@ -102,7 +108,7 @@ Set value via a input box.
<template>
<div
class=
"block"
>
<el-slider
v-model=
"value
6
"
v-model=
"value
7
"
show-input
>
</el-slider>
</div>
...
...
@@ -112,7 +118,7 @@ Set value via a input box.
export
default
{
data
()
{
return
{
value
6
:
0
value
7
:
0
}
}
}
...
...
@@ -129,7 +135,7 @@ Selecting a range of values is supported.
<template>
<div
class=
"block"
>
<el-slider
v-model=
"value
7
"
v-model=
"value
8
"
range
show-stops
:max=
"10"
>
...
...
@@ -141,7 +147,7 @@ Selecting a range of values is supported.
export
default
{
data
()
{
return
{
value
7
:
[
4
,
8
]
value
8
:
[
4
,
8
]
}
}
}
...
...
@@ -159,6 +165,7 @@ Selecting a range of values is supported.
| show-input | whether to display an input box, works when
`range`
is false | boolean | — | false |
| show-input-controls | whether to display control buttons when
`show-input`
is true | boolean | — | true |
| show-stops | whether to display breakpoints | boolean | — | false |
| show-tooltip | whether to display tooltip value | boolean | — | true |
| range | whether to select a range | boolean | — | false |
## Events
...
...
packages/slider/src/button.vue
View file @
f86427f2
...
...
@@ -7,7 +7,7 @@
:class=
"
{ 'hover': hovering, 'dragging': dragging }"
:style="{ left: currentPosition }"
ref="button">
<el-tooltip
placement=
"top"
ref=
"tooltip"
>
<el-tooltip
placement=
"top"
ref=
"tooltip"
:disabled=
"!showTooltip"
>
<span
slot=
"content"
>
{{
value
}}
</span>
<div
class=
"el-slider__button"
:class=
"
{ 'hover': hovering, 'dragging': dragging }">
</div>
</el-tooltip>
...
...
@@ -60,6 +60,10 @@
return
this
.
$parent
.
step
;
},
showTooltip
()
{
return
this
.
$parent
.
showTooltip
;
},
precision
()
{
return
this
.
$parent
.
precision
;
},
...
...
@@ -76,7 +80,7 @@
},
methods
:
{
show
Tooltip
()
{
display
Tooltip
()
{
this
.
$refs
.
tooltip
&&
(
this
.
$refs
.
tooltip
.
showPopper
=
true
);
},
...
...
@@ -86,7 +90,7 @@
handleMouseEnter
()
{
this
.
hovering
=
true
;
this
.
show
Tooltip
();
this
.
display
Tooltip
();
},
handleMouseLeave
()
{
...
...
@@ -111,7 +115,7 @@
onDragging
(
event
)
{
if
(
this
.
dragging
)
{
this
.
show
Tooltip
();
this
.
display
Tooltip
();
this
.
currentX
=
event
.
clientX
;
const
diff
=
(
this
.
currentX
-
this
.
startX
)
/
this
.
$parent
.
$sliderWidth
*
100
;
this
.
newPosition
=
this
.
startPosition
+
diff
;
...
...
packages/slider/src/main.vue
View file @
f86427f2
...
...
@@ -79,6 +79,10 @@
type
:
Boolean
,
default
:
false
},
showTooltip
:
{
type
:
Boolean
,
default
:
true
},
disabled
:
{
type
:
Boolean
,
default
:
false
...
...
test/unit/specs/slider.spec.js
View file @
f86427f2
...
...
@@ -62,6 +62,25 @@ describe('Slider', () => {
expect
(
slider
.
$refs
.
tooltip
.
showPopper
).
to
.
false
;
});
it
(
'
hide tooltip
'
,
()
=>
{
vm
=
createVue
({
template
:
`
<div>
<el-slider v-model="value" :show-tooltip="false">
</el-slider>
</div>
`
,
data
()
{
return
{
value
:
0
};
}
},
true
);
const
slider
=
vm
.
$children
[
0
].
$children
[
0
];
expect
(
slider
.
$refs
.
tooltip
.
disabled
).
to
.
true
;
});
it
(
'
drag
'
,
done
=>
{
vm
=
createVue
({
template
:
`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment