サイズ変更

このサンプルでは複数行テキストコントロールをUI操作でサイズ変更する方法を示します。

複数行テキストコントロールのコーナーをドラッグしてサイズ変更する機能について解説します。 サイズ変更方法 複数行テキストコントロールのサイズをカスタマイズするには、resizeプロパティを設定します。hiddenResizeIconプロパティを設定することでコーナーにリサイズアイコンを表示するかどうかを設定できます。hiddenResizeIconプロパティのデフォルト値はfalseで、trueに設定する場合はコーナーハンドルのリサイズを非表示に設定します。 resizeプロパティの設定できる値は次のとおりで、既定値はNoneです。 値 説明 None 既定値。リサイズ不可 Both 縦と横両方リサイズ可能 Vertical 縦方向のみリサイズ可能 Horizontal 横方向のみリサイズ可能 また、resizeConfigプロパティでmaxWidth/minWidth/maxHeight/minHeightを設定することで、リサイズするときのコントロールの最大幅/最小幅、最大高/最小高を設定できます。 次のサンプルコードは、コントロールの幅と高さを特定の範囲内に設定する例です。 注意事項 タッチデバイスの場合、右下のアイコンでリサイズ可能となりますが、縦方向または横方向のみのリサイズはできません。 minHeightのデフォルト値は35pxで、minWidthのデフォルト値はコントロールにコピーボタンやドラッグボタンなどサイドボタンの設定が有無によって変動します。
import '@mescius/inputman/CSS/gc.inputman-js.css'; import { InputMan } from '@mescius/inputman'; import './styles.css'; InputMan.appearanceStyle = InputMan.AppearanceStyle.Modern; const gcMultiLineTextBox1 = new InputMan.GcMultiLineTextBox( document.getElementById('gcMultiLineTextBox1'), { text: '〒981−3205宮城県仙台市泉区紫山3-1-4', resize: 'both', width: 180, minWidth: 200, maxWidth: 600, minHeight: 100, maxHeight: 300, } ); const resizeMode = [ InputMan.ResizeMode.Both, InputMan.ResizeMode.Vertical, InputMan.ResizeMode.Horizontal, InputMan.ResizeMode.None, ]; document.getElementById('setResizeMode').addEventListener('change', (e) => { gcMultiLineTextBox1.resize = resizeMode[e.target.selectedIndex]; }); document.getElementById('setHiddenResizeIcon').addEventListener('change', (e) => { gcMultiLineTextBox1.hiddenResizeIcon = e.target.checked; });
<!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> <textarea id="gcMultiLineTextBox1"></textarea> </div> <table class="sample"> <tr> <th>リサイズできる方向</th> <td> <select id="setResizeMode"> <option selected>縦と横</option> <option>縦方向</option> <option>横方向</option> <option>リサイズ不可</option> </select> </td> </tr> </tr> <tr> <th>リサイズアイコン</th> <td> <label><input type="checkbox" id="setHiddenResizeIcon">非表示</label> </td> </tr> </table> </body> </html>
body { padding-bottom: 10rem; }
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' }, } });