@visactor/vrender-components 0.18.0-alpha.0 → 0.18.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/axis/base.js +24 -24
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/grid/base.js +1 -1
- package/cjs/axis/grid/base.js.map +1 -1
- package/cjs/axis/line.js +59 -52
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/overlap/auto-hide.d.ts +1 -0
- package/cjs/axis/overlap/auto-hide.js +10 -2
- package/cjs/axis/overlap/auto-hide.js.map +1 -1
- package/cjs/axis/overlap/auto-limit.d.ts +1 -0
- package/cjs/axis/overlap/auto-limit.js +5 -3
- package/cjs/axis/overlap/auto-limit.js.map +1 -1
- package/cjs/axis/type.d.ts +1 -0
- package/cjs/axis/type.js.map +1 -1
- package/cjs/brush/brush.js +4 -4
- package/cjs/brush/brush.js.map +1 -1
- package/cjs/checkbox/checkbox.js +2 -1
- package/cjs/checkbox/checkbox.js.map +1 -1
- package/cjs/core/type.d.ts +10 -8
- package/cjs/core/type.js.map +1 -1
- package/cjs/data-zoom/data-zoom.d.ts +6 -1
- package/cjs/data-zoom/data-zoom.js +180 -118
- package/cjs/data-zoom/data-zoom.js.map +1 -1
- package/cjs/data-zoom/type.d.ts +1 -0
- package/cjs/data-zoom/type.js.map +1 -1
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +3 -2
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/indicator.d.ts +3 -1
- package/cjs/indicator/indicator.js +60 -46
- package/cjs/indicator/indicator.js.map +1 -1
- package/cjs/indicator/type.d.ts +1 -0
- package/cjs/indicator/type.js.map +1 -1
- package/cjs/label/arc.d.ts +2 -2
- package/cjs/label/arc.js +38 -35
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +6 -8
- package/cjs/label/base.js +92 -65
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/line.js +3 -4
- package/cjs/label/line.js.map +1 -1
- package/cjs/label/type.d.ts +15 -8
- package/cjs/label/type.js.map +1 -1
- package/cjs/label/util.d.ts +4 -0
- package/cjs/label/util.js +24 -3
- package/cjs/label/util.js.map +1 -1
- package/cjs/legend/base.js +1 -1
- package/cjs/legend/base.js.map +1 -1
- package/cjs/legend/color/color.d.ts +7 -0
- package/cjs/legend/color/color.js +16 -2
- package/cjs/legend/color/color.js.map +1 -1
- package/cjs/legend/discrete/discrete.d.ts +6 -2
- package/cjs/legend/discrete/discrete.js +139 -69
- package/cjs/legend/discrete/discrete.js.map +1 -1
- package/cjs/legend/discrete/type.d.ts +17 -7
- package/cjs/legend/discrete/type.js.map +1 -1
- package/cjs/legend/register.js +2 -2
- package/cjs/legend/register.js.map +1 -1
- package/cjs/legend/size/size.d.ts +1 -0
- package/cjs/legend/size/size.js +4 -1
- package/cjs/legend/size/size.js.map +1 -1
- package/cjs/legend/type.d.ts +2 -2
- package/cjs/legend/type.js.map +1 -1
- package/cjs/marker/area.js +5 -1
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/base.d.ts +1 -0
- package/cjs/marker/base.js +6 -3
- package/cjs/marker/base.js.map +1 -1
- package/cjs/marker/line.js +7 -1
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +1 -0
- package/cjs/marker/point.js +24 -11
- package/cjs/marker/point.js.map +1 -1
- package/cjs/marker/type.d.ts +1 -0
- package/cjs/marker/type.js.map +1 -1
- package/cjs/pager/pager.js +5 -3
- package/cjs/pager/pager.js.map +1 -1
- package/cjs/scrollbar/scrollbar.js +19 -5
- package/cjs/scrollbar/scrollbar.js.map +1 -1
- package/cjs/segment/segment.js +1 -1
- package/cjs/segment/segment.js.map +1 -1
- package/cjs/slider/slider.d.ts +27 -0
- package/cjs/slider/slider.js +102 -13
- package/cjs/slider/slider.js.map +1 -1
- package/cjs/slider/type.d.ts +9 -1
- package/cjs/slider/type.js.map +1 -1
- package/cjs/tag/tag.js +28 -42
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/title/title.js +2 -2
- package/cjs/title/title.js.map +1 -1
- package/cjs/tooltip/tooltip.js +1 -1
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/util/limit-shape.d.ts +4 -0
- package/cjs/util/limit-shape.js +13 -4
- package/cjs/util/limit-shape.js.map +1 -1
- package/cjs/util/text.d.ts +5 -2
- package/cjs/util/text.js +19 -6
- package/cjs/util/text.js.map +1 -1
- package/es/axis/base.js +22 -26
- package/es/axis/base.js.map +1 -1
- package/es/axis/grid/base.js +1 -1
- package/es/axis/grid/base.js.map +1 -1
- package/es/axis/line.js +59 -50
- package/es/axis/line.js.map +1 -1
- package/es/axis/overlap/auto-hide.d.ts +1 -0
- package/es/axis/overlap/auto-hide.js +10 -2
- package/es/axis/overlap/auto-hide.js.map +1 -1
- package/es/axis/overlap/auto-limit.d.ts +1 -0
- package/es/axis/overlap/auto-limit.js +5 -3
- package/es/axis/overlap/auto-limit.js.map +1 -1
- package/es/axis/type.d.ts +1 -0
- package/es/axis/type.js.map +1 -1
- package/es/brush/brush.js +4 -4
- package/es/brush/brush.js.map +1 -1
- package/es/checkbox/checkbox.js +2 -1
- package/es/checkbox/checkbox.js.map +1 -1
- package/es/core/type.d.ts +10 -8
- package/es/core/type.js.map +1 -1
- package/es/data-zoom/data-zoom.d.ts +6 -1
- package/es/data-zoom/data-zoom.js +179 -116
- package/es/data-zoom/data-zoom.js.map +1 -1
- package/es/data-zoom/type.d.ts +1 -0
- package/es/data-zoom/type.js.map +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/index.js.map +1 -1
- package/es/indicator/indicator.d.ts +3 -1
- package/es/indicator/indicator.js +57 -47
- package/es/indicator/indicator.js.map +1 -1
- package/es/indicator/type.d.ts +1 -0
- package/es/indicator/type.js.map +1 -1
- package/es/label/arc.d.ts +2 -2
- package/es/label/arc.js +38 -35
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +6 -8
- package/es/label/base.js +92 -65
- package/es/label/base.js.map +1 -1
- package/es/label/line.js +3 -4
- package/es/label/line.js.map +1 -1
- package/es/label/type.d.ts +15 -8
- package/es/label/type.js.map +1 -1
- package/es/label/util.d.ts +4 -0
- package/es/label/util.js +22 -2
- package/es/label/util.js.map +1 -1
- package/es/legend/base.js +1 -1
- package/es/legend/base.js.map +1 -1
- package/es/legend/color/color.d.ts +7 -0
- package/es/legend/color/color.js +17 -3
- package/es/legend/color/color.js.map +1 -1
- package/es/legend/discrete/discrete.d.ts +6 -2
- package/es/legend/discrete/discrete.js +141 -67
- package/es/legend/discrete/discrete.js.map +1 -1
- package/es/legend/discrete/type.d.ts +17 -7
- package/es/legend/discrete/type.js.map +1 -1
- package/es/legend/register.js +3 -1
- package/es/legend/register.js.map +1 -1
- package/es/legend/size/size.d.ts +1 -0
- package/es/legend/size/size.js +4 -1
- package/es/legend/size/size.js.map +1 -1
- package/es/legend/type.d.ts +2 -2
- package/es/legend/type.js.map +1 -1
- package/es/marker/area.js +6 -2
- package/es/marker/area.js.map +1 -1
- package/es/marker/base.d.ts +1 -0
- package/es/marker/base.js +6 -3
- package/es/marker/base.js.map +1 -1
- package/es/marker/line.js +8 -2
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +1 -0
- package/es/marker/point.js +25 -11
- package/es/marker/point.js.map +1 -1
- package/es/marker/type.d.ts +1 -0
- package/es/marker/type.js.map +1 -1
- package/es/pager/pager.js +4 -3
- package/es/pager/pager.js.map +1 -1
- package/es/scrollbar/scrollbar.js +19 -5
- package/es/scrollbar/scrollbar.js.map +1 -1
- package/es/segment/segment.js +1 -1
- package/es/segment/segment.js.map +1 -1
- package/es/slider/slider.d.ts +27 -0
- package/es/slider/slider.js +102 -13
- package/es/slider/slider.js.map +1 -1
- package/es/slider/type.d.ts +9 -1
- package/es/slider/type.js.map +1 -1
- package/es/tag/tag.js +29 -45
- package/es/tag/tag.js.map +1 -1
- package/es/title/title.js +3 -3
- package/es/title/title.js.map +1 -1
- package/es/tooltip/tooltip.js +1 -1
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/util/limit-shape.d.ts +4 -0
- package/es/util/limit-shape.js +11 -3
- package/es/util/limit-shape.js.map +1 -1
- package/es/util/text.d.ts +5 -2
- package/es/util/text.js +17 -5
- package/es/util/text.js.map +1 -1
- package/package.json +3 -3
- package/dist/index.js +0 -29932
- package/dist/index.min.js +0 -1
|
@@ -8,7 +8,7 @@ var __rest = this && this.__rest || function(s, e) {
|
|
|
8
8
|
return t;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
import { merge, isEmpty, normalizePadding, get, isValid, isNil, isFunction } from "@visactor/vutils";
|
|
11
|
+
import { merge, isEmpty, normalizePadding, get, isValid, isNil, isFunction, isArray } from "@visactor/vutils";
|
|
12
12
|
|
|
13
13
|
import { graphicCreator } from "@visactor/vrender-core";
|
|
14
14
|
|
|
@@ -20,6 +20,10 @@ import { DEFAULT_TITLE_SPACE, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DE
|
|
|
20
20
|
|
|
21
21
|
import { loadDiscreteLegendComponent } from "../register";
|
|
22
22
|
|
|
23
|
+
import { isRichText, richTextAttributeTransform } from "../../util";
|
|
24
|
+
|
|
25
|
+
import { ScrollBar } from "../../scrollbar";
|
|
26
|
+
|
|
23
27
|
const DEFAULT_STATES = {
|
|
24
28
|
[LegendStateValue.focus]: {},
|
|
25
29
|
[LegendStateValue.selected]: {},
|
|
@@ -140,10 +144,11 @@ export class DiscreteLegend extends LegendBase {
|
|
|
140
144
|
startY: 0,
|
|
141
145
|
startIndex: 0,
|
|
142
146
|
items: legendItems,
|
|
143
|
-
isHorizontal: isHorizontal
|
|
147
|
+
isHorizontal: isHorizontal,
|
|
148
|
+
totalPage: 1 / 0
|
|
144
149
|
}, this._itemContext = this._renderItems();
|
|
145
150
|
let pagerRendered = !1;
|
|
146
|
-
this._itemContext.doWrap && autoPage && this._itemContext.pages > this._itemContext.maxPages && (pagerRendered = this.
|
|
151
|
+
this._itemContext.doWrap && autoPage && this._itemContext.pages > this._itemContext.maxPages && (pagerRendered = this._renderPagerComponent(isHorizontal)),
|
|
147
152
|
pagerRendered || (itemsContainer.setAttribute("y", this._title ? this._title.AABBBounds.height() + get(this.attribute, "title.space", 8) : 0),
|
|
148
153
|
this._innerView.add(itemsContainer));
|
|
149
154
|
}
|
|
@@ -156,7 +161,7 @@ export class DiscreteLegend extends LegendBase {
|
|
|
156
161
|
}
|
|
157
162
|
_renderEachItem(item, isSelected, index, items) {
|
|
158
163
|
var _a, _b;
|
|
159
|
-
const {id: id, label: label, value: value, shape: shape} = item, {padding: padding = 0, focus: focus, focusIconStyle: focusIconStyle} = this.attribute.item, {shape: shapeAttr, label: labelAttr, value: valueAttr, background: background} = this.attribute.item, shapeStyle = this._handleStyle(shapeAttr, item, isSelected, index, items), labelStyle = this._handleStyle(labelAttr, item, isSelected, index, items), valueStyle = this._handleStyle(valueAttr, item, isSelected, index, items), backgroundStyle = this._handleStyle(background, item, isSelected, index, items), parsedPadding = normalizePadding(padding);
|
|
164
|
+
const {id: id, label: label, value: value, shape: shape} = item, {padding: padding = 0, focus: focus, focusIconStyle: focusIconStyle, align: align} = this.attribute.item, {shape: shapeAttr, label: labelAttr, value: valueAttr, background: background} = this.attribute.item, shapeStyle = this._handleStyle(shapeAttr, item, isSelected, index, items), labelStyle = this._handleStyle(labelAttr, item, isSelected, index, items), valueStyle = this._handleStyle(valueAttr, item, isSelected, index, items), backgroundStyle = this._handleStyle(background, item, isSelected, index, items), parsedPadding = normalizePadding(padding);
|
|
160
165
|
let itemGroup;
|
|
161
166
|
!1 === background.visible ? (itemGroup = graphicCreator.group({
|
|
162
167
|
x: 0,
|
|
@@ -175,7 +180,8 @@ export class DiscreteLegend extends LegendBase {
|
|
|
175
180
|
itemGroup.add(innerGroup);
|
|
176
181
|
let focusShape, focusStartX = 0, shapeSize = 0, shapeSpace = 0;
|
|
177
182
|
if (shapeAttr && !1 !== shapeAttr.visible) {
|
|
178
|
-
|
|
183
|
+
const s = get(shapeStyle, "style.size", DEFAULT_SHAPE_SIZE);
|
|
184
|
+
shapeSize = isArray(s) ? s[0] || 0 : s, shapeSpace = get(shapeAttr, "space", DEFAULT_SHAPE_SPACE);
|
|
179
185
|
const itemShape = graphicCreator.symbol(Object.assign(Object.assign({
|
|
180
186
|
x: 0,
|
|
181
187
|
y: 0,
|
|
@@ -190,7 +196,7 @@ export class DiscreteLegend extends LegendBase {
|
|
|
190
196
|
itemShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
|
|
191
197
|
innerGroup.add(itemShape);
|
|
192
198
|
}
|
|
193
|
-
let focusSpace = 0;
|
|
199
|
+
let labelShape, focusSpace = 0;
|
|
194
200
|
if (focus) {
|
|
195
201
|
const focusSize = get(focusIconStyle, "size", DEFAULT_SHAPE_SIZE);
|
|
196
202
|
focusShape = graphicCreator.symbol(Object.assign(Object.assign({
|
|
@@ -204,30 +210,33 @@ export class DiscreteLegend extends LegendBase {
|
|
|
204
210
|
})), this._appendDataToShape(focusShape, LEGEND_ELEMENT_NAME.focus, item, itemGroup),
|
|
205
211
|
focusSpace = focusSize;
|
|
206
212
|
}
|
|
207
|
-
const
|
|
213
|
+
const text = labelAttr.formatMethod ? labelAttr.formatMethod(label, item, index) : label, labelAttributes = Object.assign(Object.assign({
|
|
208
214
|
x: shapeSize / 2 + shapeSpace,
|
|
209
215
|
y: 0,
|
|
210
216
|
textAlign: "start",
|
|
211
217
|
textBaseline: "middle",
|
|
212
218
|
lineHeight: null === (_b = labelStyle.style) || void 0 === _b ? void 0 : _b.fontSize
|
|
213
219
|
}, labelStyle.style), {
|
|
214
|
-
text:
|
|
215
|
-
})
|
|
220
|
+
text: text
|
|
221
|
+
});
|
|
222
|
+
labelShape = isRichText(labelAttributes) ? graphicCreator.richtext(richTextAttributeTransform(labelAttributes)) : graphicCreator.text(labelAttributes),
|
|
216
223
|
this._appendDataToShape(labelShape, LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state),
|
|
217
224
|
labelShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
|
|
218
225
|
innerGroup.add(labelShape);
|
|
219
226
|
const labelSpace = get(labelAttr, "space", DEFAULT_LABEL_SPACE);
|
|
220
227
|
if (isValid(value)) {
|
|
221
|
-
const valueSpace = get(valueAttr, "space", focus ? DEFAULT_VALUE_SPACE : 0),
|
|
228
|
+
const valueSpace = get(valueAttr, "space", focus ? DEFAULT_VALUE_SPACE : 0), valueText = valueAttr.formatMethod ? valueAttr.formatMethod(value, item, index) : value, valueAttributes = Object.assign(Object.assign({
|
|
222
229
|
x: 0,
|
|
223
230
|
y: 0,
|
|
224
231
|
textAlign: "start",
|
|
225
232
|
textBaseline: "middle",
|
|
226
233
|
lineHeight: valueStyle.style.fontSize
|
|
227
234
|
}, valueStyle.style), {
|
|
228
|
-
text:
|
|
229
|
-
})
|
|
230
|
-
|
|
235
|
+
text: valueText
|
|
236
|
+
});
|
|
237
|
+
let valueShape;
|
|
238
|
+
if (valueShape = isRichText(valueAttributes) ? graphicCreator.richtext(richTextAttributeTransform(valueAttributes)) : graphicCreator.text(valueAttributes),
|
|
239
|
+
this._appendDataToShape(valueShape, LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state),
|
|
231
240
|
valueShape.addState(isSelected ? LegendStateValue.selected : LegendStateValue.unSelected),
|
|
232
241
|
this._itemWidthByUser) {
|
|
233
242
|
const layoutWidth = this._itemWidthByUser - parsedPadding[1] - parsedPadding[3] - shapeSize - shapeSpace - labelSpace - focusSpace - valueSpace, valueBounds = valueShape.AABBBounds, labelBounds = labelShape.AABBBounds, valueWidth = valueBounds.width(), labelWidth = labelBounds.width();
|
|
@@ -242,85 +251,150 @@ export class DiscreteLegend extends LegendBase {
|
|
|
242
251
|
} else this._itemWidthByUser ? (labelShape.setAttribute("maxLineWidth", this._itemWidthByUser - parsedPadding[1] - parsedPadding[3] - shapeSize - shapeSpace - focusSpace),
|
|
243
252
|
focusStartX = labelShape.AABBBounds.x2 + labelSpace) : focusStartX = labelShape.AABBBounds.x2 + labelSpace;
|
|
244
253
|
focusShape && (focusShape.setAttribute("x", focusStartX), innerGroup.add(focusShape));
|
|
245
|
-
const innerGroupBounds = innerGroup.AABBBounds, innerGroupWidth = innerGroupBounds.width()
|
|
254
|
+
const innerGroupBounds = innerGroup.AABBBounds, innerGroupWidth = innerGroupBounds.width();
|
|
255
|
+
if ("right" === align) {
|
|
256
|
+
const x2 = innerGroupBounds.x2, x1 = innerGroupBounds.x1;
|
|
257
|
+
innerGroup.forEachChildren(((child, index) => {
|
|
258
|
+
"symbol" !== child.type && "right" !== child.attribute.textAlign || child === focusShape ? child.setAttribute("x", x1 + x2 - child.attribute.x - child.AABBBounds.width()) : "symbol" !== child.type ? child.setAttributes({
|
|
259
|
+
x: x1 + x2 - child.attribute.x,
|
|
260
|
+
textAlign: "left"
|
|
261
|
+
}) : child.setAttribute("x", x1 + x2 - child.attribute.x);
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
const innerGroupHeight = innerGroupBounds.height(), itemGroupWidth = isValid(this.attribute.item.width) ? this.attribute.item.width : innerGroupWidth + parsedPadding[1] + parsedPadding[3], itemGroupHeight = this._itemHeightByUser || innerGroupHeight + parsedPadding[0] + parsedPadding[2];
|
|
246
265
|
return itemGroup.attribute.width = itemGroupWidth, itemGroup.attribute.height = itemGroupHeight,
|
|
247
266
|
focusShape && focusShape.setAttribute("visible", !1), innerGroup.translateTo(-innerGroupBounds.x1 + parsedPadding[3], -innerGroupBounds.y1 + parsedPadding[0]),
|
|
248
267
|
itemGroup;
|
|
249
268
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
269
|
+
_createPager(isScrollbar, isHorizontal, compStyle, compSize) {
|
|
270
|
+
var _a, _b;
|
|
271
|
+
const {disableTriggerEvent: disableTriggerEvent, maxRow: maxRow} = this.attribute;
|
|
272
|
+
return isScrollbar ? new ScrollBar(isHorizontal ? Object.assign(Object.assign({
|
|
273
|
+
direction: "vertical",
|
|
274
|
+
width: 12,
|
|
275
|
+
range: [ 0, .5 ]
|
|
276
|
+
}, compStyle), {
|
|
277
|
+
height: compSize,
|
|
278
|
+
disableTriggerEvent: disableTriggerEvent
|
|
279
|
+
}) : Object.assign(Object.assign({
|
|
280
|
+
direction: "horizontal",
|
|
281
|
+
disableTriggerEvent: disableTriggerEvent,
|
|
282
|
+
range: [ 0, .5 ],
|
|
283
|
+
height: 12
|
|
284
|
+
}, compStyle), {
|
|
285
|
+
width: compSize
|
|
286
|
+
})) : new Pager(isHorizontal ? Object.assign(Object.assign({
|
|
287
|
+
layout: 1 === maxRow ? "horizontal" : "vertical",
|
|
288
|
+
total: 99
|
|
289
|
+
}, merge({
|
|
290
|
+
handler: {
|
|
291
|
+
preShape: "triangleUp",
|
|
292
|
+
nextShape: "triangleDown"
|
|
293
|
+
}
|
|
294
|
+
}, compStyle)), {
|
|
295
|
+
defaultCurrent: null === (_a = this.attribute.pager) || void 0 === _a ? void 0 : _a.defaultCurrent,
|
|
296
|
+
disableTriggerEvent: disableTriggerEvent
|
|
297
|
+
}) : Object.assign({
|
|
298
|
+
layout: "horizontal",
|
|
299
|
+
total: 99,
|
|
300
|
+
disableTriggerEvent: disableTriggerEvent,
|
|
301
|
+
defaultCurrent: null === (_b = this.attribute.pager) || void 0 === _b ? void 0 : _b.defaultCurrent
|
|
302
|
+
}, compStyle));
|
|
303
|
+
}
|
|
304
|
+
_updatePositionOfPager(isScrollbar, isHorizontal, contentSize, renderStartY, compSize) {
|
|
305
|
+
const {maxHeight: maxHeight, pager: pager} = this.attribute, {currentPage: currentPage, totalPage: totalPage} = this._itemContext;
|
|
306
|
+
if (isScrollbar) this._pagerComponent.setScrollRange([ (currentPage - 1) / totalPage, currentPage / totalPage ]),
|
|
307
|
+
isHorizontal ? this._pagerComponent.setAttributes({
|
|
308
|
+
x: contentSize,
|
|
309
|
+
y: renderStartY
|
|
310
|
+
}) : this._pagerComponent.setAttributes({
|
|
311
|
+
x: 0,
|
|
312
|
+
y: maxHeight - this._pagerComponent.AABBBounds.height()
|
|
313
|
+
}); else {
|
|
314
|
+
const position = pager && pager.position || "middle";
|
|
315
|
+
if (this._pagerComponent.setTotal(totalPage), isHorizontal) {
|
|
316
|
+
let y;
|
|
317
|
+
y = "start" === position ? renderStartY : "end" === position ? renderStartY + compSize - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compSize / 2 - this._pagerComponent.AABBBounds.height() / 2,
|
|
318
|
+
this._pagerComponent.setAttributes({
|
|
319
|
+
x: contentSize,
|
|
320
|
+
y: y
|
|
321
|
+
});
|
|
322
|
+
} else {
|
|
323
|
+
let x;
|
|
324
|
+
x = "start" === position ? 0 : "end" === position ? compSize - this._pagerComponent.AABBBounds.width() : (compSize - this._pagerComponent.AABBBounds.width()) / 2,
|
|
325
|
+
this._pagerComponent.setAttributes({
|
|
326
|
+
x: x,
|
|
327
|
+
y: maxHeight - this._pagerComponent.AABBBounds.height()
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
_bindEventsOfPager(isScrollbar, isHorizontal, compSize, spaceSize) {
|
|
333
|
+
const pager = this.attribute.pager || {}, {animation: animation = !0, animationDuration: animationDuration = 450, animationEasing: animationEasing = "quadIn"} = pager, pageParser = isScrollbar ? e => {
|
|
334
|
+
const {value: value} = e.detail;
|
|
335
|
+
let newPage = value[0] * this._itemContext.totalPage;
|
|
336
|
+
return pager.scrollByPosition ? newPage += 1 : newPage = Math.floor(newPage) + 1,
|
|
337
|
+
newPage;
|
|
338
|
+
} : e => e.detail.current, onPaging = e => {
|
|
339
|
+
const newPage = pageParser(e);
|
|
340
|
+
if (newPage !== this._itemContext.currentPage) {
|
|
341
|
+
if (this._itemContext.currentPage = newPage, this._itemContext && this._itemContext.startIndex < this._itemContext.items.length) {
|
|
342
|
+
this._renderItems();
|
|
343
|
+
const newTotalPage = Math.ceil(this._itemContext.pages / this._itemContext.maxPages);
|
|
344
|
+
this._itemContext.totalPage = newTotalPage, this._pagerComponent.setScrollRange([ (newPage - 1) / newTotalPage, newPage / newTotalPage ]);
|
|
261
345
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
346
|
+
animation ? this._itemsContainer.animate().to(isHorizontal ? {
|
|
347
|
+
y: -(newPage - 1) * (compSize + spaceSize)
|
|
348
|
+
} : {
|
|
349
|
+
x: -(newPage - 1) * (compSize + spaceSize)
|
|
350
|
+
}, animationDuration, animationEasing) : isHorizontal ? this._itemsContainer.setAttribute("y", -(newPage - 1) * (compSize + spaceSize)) : this._itemsContainer.setAttribute("x", -(newPage - 1) * (compSize + spaceSize));
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
isScrollbar ? (this._pagerComponent.addEventListener("scrollDrag", onPaging), this._pagerComponent.addEventListener("scrollUp", onPaging)) : (this._pagerComponent.addEventListener("toPrev", onPaging),
|
|
354
|
+
this._pagerComponent.addEventListener("toNext", onPaging));
|
|
355
|
+
}
|
|
356
|
+
_renderPagerComponent(isHorizontal) {
|
|
357
|
+
const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, "title.space", 8) : 0, {maxWidth: maxWidth, maxHeight: maxHeight, maxCol: maxCol = 1, maxRow: maxRow = 2, item: item = {}, pager: pager = {}} = this.attribute, {spaceCol: spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow: spaceRow = DEFAULT_ITEM_SPACE_ROW} = item, itemsContainer = this._itemsContainer, {space: pagerSpace = DEFAULT_PAGER_SPACE, defaultCurrent: defaultCurrent = 1} = pager, compStyle = __rest(pager, [ "space", "defaultCurrent" ]), isScrollbar = "scrollbar" === pager.type;
|
|
358
|
+
let comp, compSize = 0, contentSize = 0, startX = 0, startY = 0, pages = 1;
|
|
359
|
+
if (isHorizontal) {
|
|
360
|
+
if (compSize = (maxRow - 1) * spaceRow + this._itemHeight * maxRow, comp = this._createPager(isScrollbar, isHorizontal, compStyle, compSize),
|
|
361
|
+
this._pagerComponent = comp, this._innerView.add(comp), contentSize = maxWidth - comp.AABBBounds.width() - pagerSpace,
|
|
362
|
+
contentSize <= 0) return this._innerView.removeChild(comp), !1;
|
|
268
363
|
itemsContainer.getChildren().forEach(((item, index) => {
|
|
269
364
|
const {width: width, height: height} = item.attribute;
|
|
270
|
-
|
|
365
|
+
contentSize < startX + width && (startX = 0, startY += height + spaceRow, pages += 1),
|
|
271
366
|
index > 0 && item.setAttributes({
|
|
272
367
|
x: startX,
|
|
273
368
|
y: startY
|
|
274
369
|
}), startX += spaceCol + width;
|
|
275
|
-
})), this._itemContext.startX = startX, this._itemContext.startY = startY, this._itemContext.pages = pages
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
x: pageWidth,
|
|
279
|
-
y: y
|
|
280
|
-
});
|
|
370
|
+
})), this._itemContext.startX = startX, this._itemContext.startY = startY, this._itemContext.pages = pages;
|
|
371
|
+
const total = Math.ceil(pages / maxRow);
|
|
372
|
+
this._itemContext.totalPage = total, this._updatePositionOfPager(isScrollbar, isHorizontal, contentSize, renderStartY, compSize);
|
|
281
373
|
} else {
|
|
282
|
-
if (
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
disableTriggerEvent: disableTriggerEvent
|
|
286
|
-
}, pageStyle)), this._pager = pagerComp, this._innerView.add(pagerComp), pageWidth = this._itemMaxWidth * maxCol + (maxCol - 1) * spaceCol,
|
|
287
|
-
pageHeight = maxHeight - pagerComp.AABBBounds.height() - pagerSpace - renderStartY,
|
|
288
|
-
pageHeight <= 0) return this._innerView.removeChild(pagerComp), !1;
|
|
289
|
-
let x;
|
|
374
|
+
if (compSize = this._itemMaxWidth * maxCol + (maxCol - 1) * spaceCol, comp = this._createPager(isScrollbar, isHorizontal, compStyle, compSize),
|
|
375
|
+
this._pagerComponent = comp, this._innerView.add(comp), contentSize = maxHeight - comp.AABBBounds.height() - pagerSpace - renderStartY,
|
|
376
|
+
contentSize <= 0) return this._innerView.removeChild(comp), !1;
|
|
290
377
|
itemsContainer.getChildren().forEach(((item, index) => {
|
|
291
378
|
const {height: height} = item.attribute;
|
|
292
|
-
|
|
379
|
+
contentSize < startY + height && (startY = 0, startX += this._itemMaxWidth + spaceCol,
|
|
293
380
|
pages += 1), index > 0 && item.setAttributes({
|
|
294
381
|
x: startX,
|
|
295
382
|
y: startY
|
|
296
383
|
}), startY += spaceRow + height;
|
|
297
|
-
}))
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
y: maxHeight - pagerComp.AABBBounds.height()
|
|
301
|
-
});
|
|
384
|
+
}));
|
|
385
|
+
const total = Math.ceil(pages / maxCol);
|
|
386
|
+
this._itemContext.totalPage = total, this._updatePositionOfPager(isScrollbar, isHorizontal, contentSize, renderStartY, compSize);
|
|
302
387
|
}
|
|
303
|
-
|
|
388
|
+
defaultCurrent > 1 && (isHorizontal ? itemsContainer.setAttribute("y", -(defaultCurrent - 1) * (compSize + spaceRow)) : itemsContainer.setAttribute("x", -(defaultCurrent - 1) * (compSize + spaceCol)));
|
|
304
389
|
const clipGroup = graphicCreator.group({
|
|
305
390
|
x: 0,
|
|
306
391
|
y: renderStartY,
|
|
307
|
-
width:
|
|
308
|
-
height:
|
|
392
|
+
width: isHorizontal ? contentSize : compSize,
|
|
393
|
+
height: isHorizontal ? compSize : contentSize,
|
|
309
394
|
clip: !0,
|
|
310
395
|
pickable: !1
|
|
311
396
|
});
|
|
312
|
-
clipGroup.add(itemsContainer), this._innerView.add(clipGroup)
|
|
313
|
-
const onPaging = e => {
|
|
314
|
-
const {current: current} = e.detail;
|
|
315
|
-
this._itemContext.currentPage = current, this._itemContext && this._itemContext.startIndex < this._itemContext.items.length && (this._renderItems(),
|
|
316
|
-
pagerComp.setTotal(Math.ceil(this._itemContext.pages / this._itemContext.maxPages))),
|
|
317
|
-
animation ? itemsContainer.animate().to(isHorizontal ? {
|
|
318
|
-
y: -(current - 1) * (pageHeight + spaceRow)
|
|
319
|
-
} : {
|
|
320
|
-
x: -(current - 1) * (pageWidth + spaceCol)
|
|
321
|
-
}, animationDuration, animationEasing) : isHorizontal ? itemsContainer.setAttribute("y", -(current - 1) * (pageHeight + spaceRow)) : itemsContainer.setAttribute("x", -(current - 1) * (pageWidth + spaceCol));
|
|
322
|
-
};
|
|
323
|
-
return this._pager.addEventListener("toPrev", onPaging), this._pager.addEventListener("toNext", onPaging),
|
|
397
|
+
return clipGroup.add(itemsContainer), this._innerView.add(clipGroup), this._bindEventsOfPager(isScrollbar, isHorizontal, compSize, isHorizontal ? spaceRow : spaceCol),
|
|
324
398
|
!0;
|
|
325
399
|
}
|
|
326
400
|
_hover(legendItem, e) {
|