Browse Source

Some fixes in Group

css_transitions
jos 10 years ago
parent
commit
2676492108
2 changed files with 21 additions and 10 deletions
  1. +20
    -10
      src/timeline/component/Group.js
  2. +1
    -0
      src/timeline/component/ItemSet.js

+ 20
- 10
src/timeline/component/Group.js View File

@ -81,9 +81,9 @@ Group.prototype.setData = function setData(data) {
/**
* Set item set for the group. The group will create a view on the itemSet,
* filtered by the groups id.
* @param {DataSet | DataView} itemSet
* @param {DataSet | DataView} itemsData
*/
Group.prototype.setItems = function setItems(itemSet) {
Group.prototype.setItems = function setItems(itemsData) {
if (this.itemSet) {
// remove current item set
this.itemSet.setItems();
@ -91,17 +91,23 @@ Group.prototype.setItems = function setItems(itemSet) {
this.itemSet = null;
}
if (itemSet) {
if (itemsData) {
var groupId = this.groupId;
var itemSetOptions = Object.create(this.options);
var me = this;
var itemSetOptions = util.extend(this.options, {
height: function () {
// FIXME: setting height doesn't yet work
return Math.max(me.props.label.height, me.itemSet.height);
}
});
this.itemSet = new ItemSet(itemSetOptions);
this.itemSet.on('change', this.emit.bind(this, 'change')); // propagate change event
this.groupFrame.appendChild(this.itemSet.getFrame());
if (this.range) this.itemSet.setRange(this.range);
this.view = new DataView(itemSet, {
this.view = new DataView(itemsData, {
filter: function (item) {
return item.group == groupId;
}
@ -175,17 +181,21 @@ Group.prototype.getSelection = function getSelection() {
* @return {boolean} Returns true if the component is resized
*/
Group.prototype.repaint = function repaint() {
this.show();
var resized = this.itemSet.repaint();
var resized = false;
this.height = this.itemSet ? this.itemSet.height : 0;
this.show();
this.dom.label.style.height = this.height + 'px';
if (this.itemSet) {
resized = this.itemSet.repaint() || resized;
}
// calculate inner size of the label
resized = util.updateProperty(this.props.label, 'width', this.dom.inner.clientWidth) || resized;
resized = util.updateProperty(this.props.label, 'height', this.dom.inner.clientHeight) || resized;
this.height = this.itemSet ? this.itemSet.height : 0;
this.dom.label.style.height = this.height + 'px';
return resized;
};

+ 1
- 0
src/timeline/component/ItemSet.js View File

@ -329,6 +329,7 @@ ItemSet.prototype.repaint = function repaint() {
frame.style.bottom = asSize((orientation == 'top') ? '' : '0');
frame.style.width = asSize(options.width, '100%');
frame.style.height = asSize(height);
//frame.style.height = asSize('height' in options ? options.height : height); // TODO: reckon with height
// calculate actual size and position
this.top = frame.offsetTop;

Loading…
Cancel
Save