feat: _getFilterItems

This commit is contained in:
Yanyan-Wang 2018-09-28 11:27:44 +08:00
parent 4782b06a03
commit 8e4ff4c1e6
2 changed files with 16 additions and 3 deletions

View File

@ -40,7 +40,8 @@ G6.registerGuide('mask', {
capture: false
});
},
bboxCalculation: false
bboxCalculation: false,
filter: false
});
class Plugin {

View File

@ -49,9 +49,9 @@ Mixin.AUGMENT = {
this.emit('beforefilter');
const filters = this.get('filters');
const items = this.getItems();
let filteredItems = this.getItems();
let filteredItems = this._getFilterItems();
filters.forEach(filter => {
filteredItems = Util.filter(filteredItems, filter);
filteredItems = filteredItems.filter(filter);
});
items.forEach(item => {
if (filteredItems.indexOf(item) === -1) {
@ -60,8 +60,20 @@ Mixin.AUGMENT = {
item.show();
}
});
this.draw();
this.emit('afterfilter');
},
/**
* get filter items
* @return {array} filterItems
*/
_getFilterItems() {
const items = this.getItems();
return items.filter(item => {
const shapeObj = item.getShapeObj();
return shapeObj.filter !== false;
});
}
};
module.exports = Mixin;