Browse Source

Made Item.isVisible independent of parent

css_transitions
josdejong 10 years ago
parent
commit
3401f74eb5
4 changed files with 20 additions and 41 deletions
  1. +4
    -4
      src/timeline/component/ItemSet.js
  2. +7
    -14
      src/timeline/component/item/ItemBox.js
  3. +5
    -12
      src/timeline/component/item/ItemPoint.js
  4. +4
    -11
      src/timeline/component/item/ItemRange.js

+ 4
- 4
src/timeline/component/ItemSet.js View File

@ -301,11 +301,11 @@ ItemSet.prototype.repaint = function repaint() {
// find start of visible items
var start = Math.min(this.visibleItemsStart, Math.max(this.orderedItems.length - 1, 0));
var item = this.orderedItems[start];
while (item && item.isVisible() && start > 0) {
while (item && item.isVisible(this.range) && start > 0) {
start--;
item = this.orderedItems[start];
}
while (item && !item.isVisible()) {
while (item && !item.isVisible(this.range)) {
if (item.displayed) item.hide();
start++;
@ -316,12 +316,12 @@ ItemSet.prototype.repaint = function repaint() {
// find end of visible items
var end = Math.max(Math.min(this.visibleItemsEnd, this.orderedItems.length), this.visibleItemsStart);
item = this.orderedItems[end];
while (item && item.isVisible()) {
while (item && item.isVisible(this.range)) {
end++;
item = this.orderedItems[end];
}
item = this.orderedItems[end - 1];
while (item && !item.isVisible() && end > 0) {
while (item && !item.isVisible(this.range) && end > 0) {
if (item.displayed) item.hide();
end--;

+ 7
- 14
src/timeline/component/item/ItemBox.js View File

@ -33,23 +33,16 @@ function ItemBox (parent, data, options, defaultOptions) {
ItemBox.prototype = new Item (null, null);
/**
* Check whether this item is visible in the current time window
* Check whether this item is visible inside given range
* @returns {{start: Number, end: Number}} range with a timestamp for start and end
* @returns {boolean} True if visible
*/
ItemBox.prototype.isVisible = function isVisible () {
ItemBox.prototype.isVisible = function isVisible (range) {
// determine visibility
var data = this.data;
var range = this.parent && this.parent.range;
if (data && range) {
// TODO: account for the width of the item. Right now we add 1/4 to the window
var interval = (range.end - range.start) / 4;
interval = 0; // TODO: remove
return (data.start > range.start - interval) && (data.start < range.end + interval);
}
else {
return false;
}
// TODO: account for the width of the item. Right now we add 1/4 to the window
var interval = (range.end - range.start) / 4;
interval = 0; // TODO: remove
return (this.data.start > range.start - interval) && (this.data.start < range.end + interval);
}
/**

+ 5
- 12
src/timeline/component/item/ItemPoint.js View File

@ -34,21 +34,14 @@ function ItemPoint (parent, data, options, defaultOptions) {
ItemPoint.prototype = new Item (null, null);
/**
* Check whether this item is visible in the current time window
* Check whether this item is visible inside given range
* @returns {{start: Number, end: Number}} range with a timestamp for start and end
* @returns {boolean} True if visible
*/
ItemPoint.prototype.isVisible = function isVisible () {
ItemPoint.prototype.isVisible = function isVisible (range) {
// determine visibility
var data = this.data;
var range = this.parent && this.parent.range;
if (data && range) {
var interval = (range.end - range.start);
return (data.start > range.start - interval) && (data.start < range.end);
}
else {
return false;
}
var interval = (range.end - range.start);
return (this.data.start > range.start - interval) && (this.data.start < range.end);
}
/**

+ 4
- 11
src/timeline/component/item/ItemRange.js View File

@ -33,20 +33,13 @@ ItemRange.prototype = new Item (null, null);
ItemRange.prototype.baseClassName = 'item range';
/**
* Check whether this item is visible in the current time window
* Check whether this item is visible inside given range
* @returns {{start: Number, end: Number}} range with a timestamp for start and end
* @returns {boolean} True if visible
*/
ItemRange.prototype.isVisible = function isVisible () {
ItemRange.prototype.isVisible = function isVisible (range) {
// determine visibility
var data = this.data;
var range = this.parent && this.parent.range;
if (data && range) {
return (data.start < range.end) && (data.end > range.start);
}
else {
return false;
}
return (this.data.start < range.end) && (this.data.end > range.start);
}
/**

Loading…
Cancel
Save