数値コントロールでは、左右に移動するスライダーを使って値を選択することができます。また、スライダーの表示位置を設定できます。
スライダー入力の設定
スライダー入力を有効にするには、sliderConfigプロパティにスライダー表示のオプションを設定する必要があります。visibleプロパティをtrueに設定すると、スライダーを表示します。
また、positionプロパティを設定することでスライダーの表示位置を変更します。スライダーを数値コントロールの下側の境界線に表示するほか、左側または右側に配置することができます。
次のサンプルコードは、数値コントロールの左側にスライダーを追加することを示しています。
positionプロパティに設定できる値は以下のとおりで、既定値はSliderPosition.BottomBorderです。
値
説明
BottomBorder
既定値。スライダーをコントロールの下枠線に配置します。
Left
スライダーをコントロールの左側に配置します。
Right
スライダーをコントロールの右側に配置します。
注意事項
コントロールの左側/右側に十分な空白がない場合は、スライダーが表示できない場合があります。
import '@mescius/inputman/CSS/gc.inputman-js.css';
import { InputMan } from '@mescius/inputman';
import './styles.css';
InputMan.appearanceStyle = InputMan.AppearanceStyle.Modern;
const gcNumber1 = new InputMan.GcNumber(document.getElementById('gcNumber1'), {
minValue: 0,
maxValue: 100,
value: 50,
sliderConfig: {
visible: true,
},
});
const gcNumber2 = new InputMan.GcNumber(document.getElementById('gcNumber2'), {
minValue: 0,
maxValue: 100,
value: 50,
sliderConfig: {
visible: true,
position: InputMan.SliderPosition.Left,
},
});
const gcNumber3 = new InputMan.GcNumber(document.getElementById('gcNumber3'), {
minValue: 0,
maxValue: 100,
value: 50,
sliderConfig: {
visible: true,
position: InputMan.SliderPosition.Right,
},
});
const gcNumber4 = new GCIM.GcNumber(document.getElementById('gcNumber4'), {
minValue: 0,
maxValue: 100,
value: 50,
width: 300,
sliderConfig: {
visible: true,
marks: [20, 40, 50, 60, 80],
showMarkLabel: true,
},
});
const gcNumber5 = new GCIM.GcNumber(document.getElementById('gcNumber5'), {
minValue: 0,
maxValue: 100,
value: 50,
width: 300,
sliderConfig: {
visible: true,
marks: [20, 40, 50, 60, 80],
showMarkLabel: true,
tooltipShowMode: 'always',
},
});
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>数値コントロール - スライダー入力</title>
<!-- SystemJS -->
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
window.onload = function() {
System.import('./src/app');
}
</script>
</head>
<body>
<div>
<p>数値コントロールの下側の境界線に表示する(デフォルト)</p>
<input id="gcNumber1">
</div>
<br>
<div>
<p>スライダーを左に表示する</p>
<input id="gcNumber2">
</div>
<br>
<div>
<p>スライダーを右に表示する</p>
<input id="gcNumber3">
</div>
<br>
<div>
<p>目盛りラベルを表示する</p>
<input id="gcNumber4">
</div>
<br />
<div>
<p>ツールチップを表示する</p>
<input id="gcNumber5">
</div>
</body>
</html>
body {
padding-bottom: 10rem;
}
.custom .gcim__number-slider-container {
height: 8px;
border-radius: 100px;
background-color: #d5eee2;
}
body {
padding-bottom: 10rem;
}
[gcim-control-appearance="modern"] .custom .gcim__number-slider-container {
height: 8px;
border-radius: 100px;
background-color: #d5eee2;
}
System.config({
transpiler: 'plugin-babel',
babelOptions: {
es2015: true
},
meta: {
'*.css': { loader: 'css' }
},
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
'@mescius/inputman': 'npm:@mescius/inputman/index.js',
'@mescius/inputman/CSS': 'npm:@mescius/inputman/CSS',
'css': 'npm:systemjs-plugin-css/css.js',
'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js',
'systemjs-babel-build': 'npm:systemjs-plugin-babel/systemjs-babel-browser.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
src: {
defaultExtension: 'js'
},
"node_modules": {
defaultExtension: 'js'
},
}
});