diff --git a/src/fonteditor/widget/glyfviewer.js b/src/fonteditor/widget/glyfviewer.js index 4124996..98a032d 100644 --- a/src/fonteditor/widget/glyfviewer.js +++ b/src/fonteditor/widget/glyfviewer.js @@ -12,7 +12,6 @@ define( var string = require('common/string'); var lang = require('common/lang'); var MouseCapture = require('render/capture/Mouse'); - var isBoundingBoxCross = require('graphics/isBoundingBoxCross'); var GLYF_ITEM_TPL = '' + '
' @@ -136,23 +135,26 @@ define( }); // 选择范围内元素 - function selectRangeItem(bound, toggle, remove) { + function selectRangeItem(bound, toggle, append) { + + if (!toggle && !append) { + me.main.children().removeClass('selected'); + } + me.main.children().each(function(i, element) { var item = $(element); var pos = item.offset(); - var b = { - x: pos.left, - y: pos.top, - width: item.width(), - height: item.height() + var p = { + x: pos.left + item.width() / 2, + y: pos.top + item.height() / 2 } - if (3 === isBoundingBoxCross(bound, b)) { + + if (p.x >= bound.x && p.x <= bound.x + bound.width + && p.y >= bound.y && p.y <= bound.y + bound.height + ) { if (toggle) { item.toggleClass('selected'); } - else if (remove) { - item.removeClass('selected') - } else { item.addClass('selected') }