Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.isFlipped = true;
const maxItemWidth = this.get('maxItemWidth');
const maxItemHeight = this.get('maxItemHeight');
const maxWidth = this.get('maxWidth');
const maxHeight = this.get('maxHeight');
const itemsGroup = this.get('itemsGroup');
const itemsBBox = itemsGroup.getBBox();
const layout = this.get('layout');
const paginationCfg = this._getPaginationCfg();
// 根据layout创建clip
let pageNumber = 0;
let mode = 'up-down'; // 上下翻页
let x = itemsBBox.tl.x;
let y = itemsBBox.tl.y; // 翻页器位置
let size = 0; // 翻页器尺寸
const clip = new Rect({
attrs: {
x,
y,
width: maxWidth - paginationCfg.size,
height: maxHeight,
},
});
if (layout === 'horizontal') {
const width = Math.max(maxWidth, itemsBBox.width);
clip.attr('width', width);
clip.attr('height', maxItemHeight);
this.set('maxWidth', width);
this.set('maxHeight', maxItemHeight);
pageNumber = Math.ceil(itemsBBox.height / (maxItemHeight + this.get('itemMarginBottom')));
x = x + width - paginationCfg.size; // temp:padding
y = Math.ceil(y + maxItemHeight / 2);
}
// 支持circle、rect、ellipse、Polygon及自定义path clip
const { type, x, y } = clip;
let clipShape = null;
if (type === 'circle') {
const { r } = clip;
clipShape = new G.Circle({
attrs: {
r,
x,
y
}
});
} else if (type === 'rect') {
const { width, height } = clip;
clipShape = new G.Rect({
attrs: {
x,
y,
width,
height
}
});
} else if (type === 'ellipse') {
const { rx, ry } = clip;
clipShape = new G.Ellipse({
attrs: {
x,
y,
rx,
ry
}