range: add input (issue #114)
fader: fix vertical+compact focused input size
This commit is contained in:
parent
2af36b84e0
commit
e8610b5054
2 changed files with 138 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
|||
var _widgets_base = require('../common/_widgets_base'),
|
||||
Fader = require('../pads/_fake_fader')
|
||||
Fader = require('../pads/_fake_fader'),
|
||||
Input = require('../inputs/input')
|
||||
|
||||
var faderDefaults = Fader.defaults()
|
||||
|
||||
|
|
@ -29,8 +30,9 @@ module.exports = class Range extends _widgets_base {
|
|||
|
||||
horizontal:false,
|
||||
alignRight:false,
|
||||
pips:true,
|
||||
input: true,
|
||||
compact:false,
|
||||
pips:true,
|
||||
snap:false,
|
||||
spring:false,
|
||||
range:{min:0,max:1},
|
||||
|
|
@ -177,7 +179,46 @@ module.exports = class Range extends _widgets_base {
|
|||
|
||||
})
|
||||
|
||||
if (this.getProp('input')) {
|
||||
|
||||
this.input = new Input({
|
||||
props:{...Input.defaults(),
|
||||
precision:this.getProp('precision'),
|
||||
unit:this.getProp('unit'),
|
||||
horizontal: this.getProp('compact') && !this.getProp('horizontal')
|
||||
},
|
||||
parent:this, parentNode:this.widget,
|
||||
})
|
||||
this.widget.append(this.input.widget)
|
||||
this.input.widget.on('change', (e)=>{
|
||||
e.stopPropagation()
|
||||
this.setValue(this.input.getValue(), {sync:true, send:true})
|
||||
this.showValue()
|
||||
})
|
||||
|
||||
this.widget.on('fake-right-click',function(e){
|
||||
if (!EDITING) {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
this.input.canvas.focus()
|
||||
}
|
||||
}.bind(this))
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (this.getProp('horizontal')) {
|
||||
this.widget.add(this.container).addClass('horizontal')
|
||||
}
|
||||
if (this.getProp('alignRight') && !this.getProp('horizontal')) {
|
||||
this.widget.addClass('align-right')
|
||||
}
|
||||
if (this.getProp('compact')) {
|
||||
this.widget.addClass('compact')
|
||||
}
|
||||
if (this.getProp('pips')) {
|
||||
this.widget.addClass('has-pips')
|
||||
}
|
||||
|
||||
var _this = this
|
||||
this.faders[1].draw = function() {
|
||||
|
|
@ -339,11 +380,20 @@ module.exports = class Range extends _widgets_base {
|
|||
this.faders[1].getValue()
|
||||
]
|
||||
|
||||
this.faders[1].draw()
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.widget.trigger({type:'change', id:this.getProp('id'),widget:this, linkId:this.getProp('linkId'), options:options})
|
||||
|
||||
this.faders[1].draw()
|
||||
|
||||
this.showValue()
|
||||
|
||||
|
||||
}
|
||||
|
||||
showValue() {
|
||||
|
||||
if (this.getProp('input')) this.input.setValue(this.value)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -335,9 +335,9 @@
|
|||
&:not(.horizontal) {
|
||||
.input {
|
||||
height: 100rem;
|
||||
width: 24rem;
|
||||
width: 100rem;
|
||||
margin-top: -50rem;
|
||||
margin-left: calc(-1 * 12rem + var(--input-margin));
|
||||
margin-left: calc(-1 * 50rem + var(--input-margin));
|
||||
z-index: 3;
|
||||
input {
|
||||
transform: rotate(-90deg);
|
||||
|
|
@ -347,7 +347,7 @@
|
|||
|
||||
&.align-right {
|
||||
.input {
|
||||
margin-left: calc(-1 * 12rem - var(--input-margin));
|
||||
margin-left: calc(-1 * 50rem - var(--input-margin));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -367,8 +367,12 @@
|
|||
|
||||
|
||||
.range-container {
|
||||
width:200rem;
|
||||
height:230rem;
|
||||
width:100rem;
|
||||
height:300rem;
|
||||
&.horizontal {
|
||||
height:130rem;
|
||||
width:300rem
|
||||
}
|
||||
padding: 1rem;
|
||||
--color-pips: var(--color-custom);
|
||||
--color-gauge: var(--color-custom);
|
||||
|
|
@ -378,13 +382,25 @@
|
|||
overflow: hidden;
|
||||
display: flex;
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
> .input {
|
||||
height: 25rem;
|
||||
flex:initial!important;
|
||||
flex-shrink: 0!important;
|
||||
// display: block;
|
||||
background: transparent!important;
|
||||
border: 0!important;
|
||||
}
|
||||
> .wrapper {
|
||||
height:100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex: 1 1 100%;
|
||||
max-height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
flex:1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
border-radius: inherit;
|
||||
.handle {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
|
@ -415,6 +431,67 @@
|
|||
background: var(--color-track);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
&.compact {
|
||||
|
||||
--input-margin:0rem;
|
||||
&.has-meter {
|
||||
--input-margin:-3rem;
|
||||
}
|
||||
&.has-pips {
|
||||
--input-margin:-1rem;
|
||||
}
|
||||
&.has-meter.has-pips {
|
||||
--input-margin:-4rem;
|
||||
}
|
||||
|
||||
.input {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
border:0;
|
||||
background:transparent;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
top:50%;
|
||||
left:50%;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
&.horizontal {
|
||||
|
||||
.input {
|
||||
width: 100rem;
|
||||
height: 24rem;
|
||||
margin-left: -50rem;
|
||||
margin-top: calc(-1 * 12rem + var(--input-margin));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
&:not(.horizontal) {
|
||||
.input {
|
||||
height: 100rem;
|
||||
width: 100rem;
|
||||
margin-top: -50rem;
|
||||
margin-left: calc(-1 * 50rem + var(--input-margin));
|
||||
z-index: 3;
|
||||
input {
|
||||
transform: rotate(-90deg);
|
||||
width: 100rem;
|
||||
}
|
||||
}
|
||||
|
||||
&.align-right {
|
||||
.input {
|
||||
margin-left: calc(-1 * 50rem - var(--input-margin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue