fader's pips reworked: now using tricky gradient instead of 100x small elements
This commit is contained in:
parent
3df3b18193
commit
d0807097e8
3 changed files with 60 additions and 46 deletions
File diff suppressed because one or more lines are too long
|
|
@ -103,14 +103,18 @@ module.exports.create = function(widgetData,container) {
|
|||
|
||||
var pipsInner = ''
|
||||
for (var i=0;i<=100;i++) {
|
||||
if (range[i]==undefined) continue
|
||||
|
||||
var piptext = range[i]!=undefined?`<span>${Math.abs(range[i])>=1000?range[i]/1000+'k':range[i]}</span>`:'',
|
||||
add = `
|
||||
<div class="pip ${range[i]!=undefined?'val':''}">${piptext}${piptext}</div>
|
||||
var pos = dimension=='height'?'bottom':'left';
|
||||
|
||||
var piptext = `<span>${Math.abs(range[i])>=1000?range[i]/1000+'k':range[i]}</span>`
|
||||
|
||||
if (dimension=='height') piptext = piptext+ piptext
|
||||
|
||||
var add = `
|
||||
<div class="pip val" style="${pos}:${i}%">${piptext}</div>
|
||||
`
|
||||
pipsInner = dimension=='height'?
|
||||
add + pipsInner:
|
||||
pipsInner + add
|
||||
pipsInner = pipsInner + add
|
||||
}
|
||||
pips[0].innerHTML = pipsInner
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
@mixin pips($direction: "to bottom") {
|
||||
$color: var(--color-text-fade);
|
||||
$gradient: $color, $color 1rem, transparent 1rem,transparent 1%;
|
||||
@for $i from 1 through 100 {
|
||||
$dump: ();
|
||||
|
||||
$dump: $color + ' '+ $i+'%, ' + $color +' calc('+$i+'% + 1rem),transparent calc('+$i+'% + 1rem),transparent '+($i+1)+'%';
|
||||
|
||||
|
||||
$gradient: join($gradient, unquote($dump), comma);
|
||||
}
|
||||
|
||||
background: linear-gradient(unquote($direction), $gradient);
|
||||
}
|
||||
|
||||
.fader-container {
|
||||
width:100rem;
|
||||
min-height: 200rem;
|
||||
|
|
@ -140,30 +155,29 @@
|
|||
bottom:0;
|
||||
left:50%;
|
||||
z-index: 0;
|
||||
width: 38rem;
|
||||
margin-left: -19rem;
|
||||
@include pips;
|
||||
|
||||
.pip {
|
||||
height:1%;
|
||||
width:38rem;
|
||||
margin-left:-19rem;
|
||||
background: linear-gradient(var(--color-text),transparent 1rem);
|
||||
|
||||
&.val {
|
||||
position: relative;
|
||||
width:44rem;
|
||||
margin-left:-22rem;
|
||||
span {
|
||||
position: absolute;
|
||||
width:30rem;
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size:11rem;
|
||||
line-height: 12rem;
|
||||
left:44rem;
|
||||
top:-5.5rem;
|
||||
color:var(--color-text-fade);
|
||||
&:last-child {
|
||||
left:auto;
|
||||
right:44rem;
|
||||
}
|
||||
background: linear-gradient(var(--color-text-fade), var(--color-text-fade) 1rem,transparent 1rem);
|
||||
position: absolute;
|
||||
width:44rem;
|
||||
margin-left:-3rem;
|
||||
span {
|
||||
position: absolute;
|
||||
width:30rem;
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size:11rem;
|
||||
line-height: 12rem;
|
||||
left:44rem;
|
||||
top:-5.5rem;
|
||||
color:var(--color-text-fade);
|
||||
&:last-child {
|
||||
left:auto;
|
||||
right:44rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -228,29 +242,25 @@
|
|||
}
|
||||
}
|
||||
.pips {
|
||||
top:14rem;left:0;
|
||||
top:15rem;left:0;
|
||||
right:0;
|
||||
font-size: 0;
|
||||
height:4rem;
|
||||
width:100%;
|
||||
margin:0;
|
||||
@include pips('to right');
|
||||
}
|
||||
.pip {
|
||||
width:1%;
|
||||
display: inline-block;
|
||||
height:4rem;
|
||||
margin-bottom:5rem;
|
||||
margin-left:0;
|
||||
background: linear-gradient(90deg,var(--color-text),transparent 1rem );
|
||||
&.val {
|
||||
width:1%;
|
||||
height:10rem;
|
||||
margin-left:0;
|
||||
margin-bottom:0;
|
||||
background: linear-gradient(90deg,var(--color-text-fade),var(--color-text-fade) 1rem,transparent 1rem );
|
||||
height:6rem;
|
||||
margin: 0;
|
||||
|
||||
span {
|
||||
top:15rem;
|
||||
left:-15rem;
|
||||
&:last-child {
|
||||
display: none;
|
||||
}
|
||||
span {
|
||||
top:15rem;
|
||||
left:-15rem!important;
|
||||
&:last-child {
|
||||
right:auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue