タグボックスコントロールでドラッグ操作でタグの並び替えを実行できます。
概要
タグボックスコントロールでドラッグ操作機能を使用するにはallowDragTagプロパティにtrueを設定します。allowDragTagプロパティはタグボックスを初期化する場合のみ設定できます。初期化以降にallowDragTagプロパティの更新はできません。
import '@mescius/inputman/CSS/gc.inputman-js.css';
import { InputMan } from '@mescius/inputman';
import { products } from './data';
InputMan.appearanceStyle = InputMan.AppearanceStyle.Modern;
const tagbox1 = new InputMan.GcTagBox(document.getElementById('tagbox1'), {
width: 500,
height: 60,
items: products,
allowDragTag: true,
value: ['果汁100%オレンジ', '果汁100%レモン', 'コーヒービター']
});
<!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>
選択項目をドラッグ操作で移動できます。<br>
<div id="tagbox1"></div>
</body>
</html>
body {
min-height: 300px;
}
export const products = ['果汁100%オレンジ', '果汁100%グレープ', '果汁100%レモン', '果汁100%ピーチ', 'コーヒーマイルド', 'コーヒービター'];
body {
min-height: 300px;
}
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'
},
}
});