ドロップダウンの方向

コンボコントロールでは、ドロップダウンの表示スペースを判定して、自動的に適切な方向にドロップダウンを表示することができます。 ドロップダウンの方向 ドロップダウンは通常コントロールの下に表示されますが、コントロールの下にドロップダウンを表示できる十分なスペースがない場合は、ドロップダウンがコントロールの上に表示されます。ドロップダウンの表示スペースを判定するとき、既定ではWebページ本体(body要素)をコンテナとして扱いますが、setContainerメソッドで任意の要素をコンテナとして指定することも可能です。
import '@grapecity/inputman/CSS/gc.inputman-js.css'; import './styles.css'; import { InputMan } from '@grapecity/inputman'; import { products } from './data'; const gcComboBox1 = new InputMan.GcComboBox(document.getElementById('gcComboBox1'), { items: products, container: document.getElementById('container1') }); const gcComboBox2 = new InputMan.GcComboBox(document.getElementById('gcComboBox2'), { items: products, container: document.getElementById('container2') });
<!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> System.import('./src/app'); </script> </head> <body> <div class="flexbox"> <div id="container1"> <p>ドロップダウンが下に表示されます。</p> <select id="gcComboBox1"></select> </div> <div id="container2"> <p>ドロップダウンが上に表示されます。</p> <select id="gcComboBox2"></select> </div> </div> </body> </html>
.flexbox { display: flex; flex-wrap: wrap; } .flexbox > div { height: 300px; width: 300px; background-color: #f8f8f8; } #container2 > p { margin-top: 220px; }
export const products = ['果汁100%オレンジ', '果汁100%グレープ', '果汁100%レモン', '果汁100%ピーチ', 'コーヒーマイルド', 'コーヒービター'];
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: { '@grapecity/inputman': 'npm:@grapecity/inputman/index.js', '@grapecity/inputman/CSS': 'npm:@grapecity/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' }, } });