-
Notifications
You must be signed in to change notification settings - Fork 36
/
galleryGroup.js
74 lines (66 loc) · 1.82 KB
/
galleryGroup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
////// <reference path="../../reference.ts" />
import utils from '../../utils/index';
import { Group } from 'pro-layouts';
class GalleryGroup {
constructor(config) {
this.uniqueId = utils.generateUUID();
this.isGalleryGroup = true;
if (config.dto && config.dto.dto) {
config.dto = config.dto.dto; //defence patch due to mis-use of item-core
if (utils.isDev()) {
console.warn('Item core is created with already existing item core');
}
}
this.dto = Object.assign({}, config.dto);
if (config.scheme) {
this.processScheme(config.scheme);
} else {
this.processScheme(new Group({ dto: config.dto }).scheme);
}
if (config.items) {
this.items = config.items;
} else {
console.warn('Pro Gallery created Gallery Group without items', config);
}
}
processScheme(scheme) {
this.id = scheme.id;
this.idx = scheme.idx;
this.width = scheme.width;
this.height = scheme.height;
this.totalHeight = scheme.totalHeight;
this.ratio = scheme.ratio;
this.top = scheme.top;
this.left = scheme.left;
this.right = scheme.right;
this.bottom = scheme.bottom;
this.visible = scheme.visible;
this.rendered = scheme.rendered;
this.required = scheme.required;
}
renderProps(galleryConfig) {
return {
className: 'group',
id: this.id,
idx: this.idx,
key: this.key,
type: this.type,
top: this.top,
left: this.left,
right: this.right,
bottom: this.bottom,
width: this.width,
height: this.height,
totalHeight: this.totalHeight,
items: this.items,
visible: this.visible,
rendered: this.rendered,
required: this.required,
galleryConfig,
};
}
get key() {
return 'group_' + this.id;
}
}
export default GalleryGroup;