chang select behavior
This commit is contained in:
parent
2f6bcc81af
commit
abebe9469d
@ -12,7 +12,6 @@ define(
|
|||||||
var string = require('common/string');
|
var string = require('common/string');
|
||||||
var lang = require('common/lang');
|
var lang = require('common/lang');
|
||||||
var MouseCapture = require('render/capture/Mouse');
|
var MouseCapture = require('render/capture/Mouse');
|
||||||
var isBoundingBoxCross = require('graphics/isBoundingBoxCross');
|
|
||||||
|
|
||||||
var GLYF_ITEM_TPL = ''
|
var GLYF_ITEM_TPL = ''
|
||||||
+ '<div data-index="${index}" class="glyf-item ${compound} ${modify}">'
|
+ '<div data-index="${index}" class="glyf-item ${compound} ${modify}">'
|
||||||
@ -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) {
|
me.main.children().each(function(i, element) {
|
||||||
var item = $(element);
|
var item = $(element);
|
||||||
var pos = item.offset();
|
var pos = item.offset();
|
||||||
var b = {
|
var p = {
|
||||||
x: pos.left,
|
x: pos.left + item.width() / 2,
|
||||||
y: pos.top,
|
y: pos.top + item.height() / 2
|
||||||
width: item.width(),
|
|
||||||
height: item.height()
|
|
||||||
}
|
}
|
||||||
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) {
|
if (toggle) {
|
||||||
item.toggleClass('selected');
|
item.toggleClass('selected');
|
||||||
}
|
}
|
||||||
else if (remove) {
|
|
||||||
item.removeClass('selected')
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
item.addClass('selected')
|
item.addClass('selected')
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user