add history debounce

This commit is contained in:
kekee000
2015-02-03 23:13:50 +08:00
parent 6ddbee0c89
commit 99cea1be3f
3 changed files with 9 additions and 8 deletions

View File

@@ -197,6 +197,11 @@ define(
*/
function bindViewer(program) {
// 由于可能存在连续保存的情况,这里debounce一下
var pushHistory = lang.debounce(function () {
program.ttfManager.pushHistory();
}, 200);
program.viewer.on('del', function (e) {
if (e.list) {
program.ttfManager.removeGlyf(e.list);
@@ -358,9 +363,7 @@ define(
var selected = program.viewer.getSelected();
if (selected.length) {
moveSelectedGlyf(selected, true);
setTimeout(function () {
program.ttfManager.pushHistory();
});
pushHistory();
}
}
@@ -381,9 +384,7 @@ define(
var selected = program.viewer.getSelected();
if (selected.length) {
moveSelectedGlyf(selected, false);
setTimeout(function () {
program.ttfManager.pushHistory();
});
pushHistory();
}
}
});

View File

@@ -213,7 +213,7 @@ define(
unicodes = [glyf.unicode];
}
if (lang.isArray(unicodes)) {
if (Array.isArray(unicodes)) {
unicodes.forEach(function (unicode) {
if (unicode !== 0xFFFF) {
usFirstCharIndex = Math.min(usFirstCharIndex, unicode);

View File

@@ -539,7 +539,7 @@ define(
// 按unicode数组查找
if (condition.unicode) {
var unicodeList = lang.isArray(condition.unicode) ? condition.unicode : [condition.unicode];
var unicodeList = Array.isArray(condition.unicode) ? condition.unicode : [condition.unicode];
var unicodeHash = {};
unicodeList.forEach(function (unicode) {
if (typeof unicode === 'string') {