Skip to content

Commit

Permalink
fix(virtual-repeat): update executionContext to bindingContext
Browse files Browse the repository at this point in the history
  • Loading branch information
martingust committed Oct 15, 2015
1 parent 0345226 commit e29c46f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"aurelia-tools": "^0.1.3",
"conventional-changelog": "0.0.11",
"del": "^1.1.0",
"escape-string-regexp": "^1.0.3",
"gulp": "^3.8.10",
"gulp-babel": "^5.1.0",
"gulp-bump": "^0.1.11",
Expand All @@ -59,7 +58,6 @@
"object.assign": "^1.0.3",
"require-dir": "^0.1.0",
"run-sequence": "^1.0.2",
"vinyl": "^1.0.0",
"vinyl-paths": "^1.0.0",
"yargs": "^2.1.1"
},
Expand Down
36 changes: 18 additions & 18 deletions src/virtual-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class VirtualRepeat {
this.indicatorMinHeight = 15;
}

bind(executionContext){
this.executionContext = executionContext;
bind(bindingContext){
this.bindingContext = bindingContext;
this.virtualScrollInner = this.element.parentNode;
this.virtualScroll = this.virtualScrollInner.parentElement;
this.createScrollIndicator();
Expand All @@ -48,7 +48,7 @@ export class VirtualRepeat {
window.onresize = () => { this.handleContainerResize(); };

// create first item to get the heights
var row = this.createFullExecutionContext(this.items[0], 0, 1);
var row = this.createFullBindingContext(this.items[0], 0, 1);
var view = this.viewFactory.create(row);
this.viewSlot.add(view);
}
Expand All @@ -72,7 +72,7 @@ export class VirtualRepeat {
this.numberOfDomElements = Math.ceil(this.virtualScrollHeight / this.itemHeight) + 1;

for(var i = 1, ii = this.numberOfDomElements; i < ii; ++i){
row = this.createFullExecutionContext(this.items[i], i, ii);
row = this.createFullBindingContext(this.items[i], i, ii);
view = this.viewFactory.create(row);
this.viewSlot.add(view);
}
Expand Down Expand Up @@ -104,8 +104,8 @@ export class VirtualRepeat {
this.numberOfDomElements = Math.ceil(this.virtualScrollHeight / this.itemHeight) + 1;

if(this.numberOfDomElements > childrenLength){
addIndex = children[childrenLength - 1].executionContext.$index + 1;
row = this.createFullExecutionContext(this.items[addIndex], addIndex, this.items.length);
addIndex = children[childrenLength - 1].bindingContext.$index + 1;
row = this.createFullBindingContext(this.items[addIndex], addIndex, this.items.length);
view = this.viewFactory.create(row);
this.viewSlot.insert(childrenLength, view);
}else if (this.numberOfDomElements < childrenLength){
Expand Down Expand Up @@ -142,8 +142,8 @@ export class VirtualRepeat {
this.previousFirst = first;

view = viewSlot.children[0];
view.executionContext = this.updateExecutionContext(view.executionContext, first + numberOfDomElements - 1, items.length);
view.executionContext[this.local] = items[first + numberOfDomElements - 1];
view.bindingContext = this.updateBindingContext(view.bindingContext, first + numberOfDomElements - 1, items.length);
view.bindingContext[this.local] = items[first + numberOfDomElements - 1];
viewSlot.children.push(viewSlot.children.shift());

viewStart = VirtualRepeat.getNthNode(childNodes, 1, 8);
Expand All @@ -161,8 +161,8 @@ export class VirtualRepeat {

view = viewSlot.children[numberOfDomElements - 1];
if(view) {
view.executionContext[this.local] = items[first];
view.executionContext = this.updateExecutionContext(view.executionContext, first, items.length);
view.bindingContext[this.local] = items[first];
view.bindingContext = this.updateBindingContext(view.bindingContext, first, items.length);
viewSlot.children.unshift(viewSlot.children.splice(-1,1)[0]);

viewStart = VirtualRepeat.getNthNode(childNodes, 1, 8, true);
Expand Down Expand Up @@ -200,23 +200,23 @@ export class VirtualRepeat {
this.indicator.style.transform = indicatorTranslateStyle;
}

createBaseExecutionContext(data){
createBaseBindingContext(data){
var context = {};
context[this.local] = data;
return context;
}

createFullExecutionContext(data, index, length){
var context = this.createBaseExecutionContext(data);
return this.updateExecutionContext(context, index, length);
createFullBindingContext(data, index, length){
var context = this.createBaseBindingContext(data);
return this.updateBindingContext(context, index, length);
}

updateExecutionContext(context, index, length){
updateBindingContext(context, index, length){
var first = (index === 0),
last = (index === length - 1),
even = index % 2 === 0;

context.$parent = this.executionContext;
context.$parent = this.bindingContext;
context.$index = index;
context.$first = first;
context.$last = last;
Expand All @@ -237,8 +237,8 @@ export class VirtualRepeat {

for(i = 0, ii = viewSlot.children.length; i < ii; ++i){
view = viewSlot.children[i];
view.executionContext[this.local] = items[this.first + i];
view.executionContext = this.updateExecutionContext(view.executionContext, this.first + i, items.length);
view.bindingContext[this.local] = items[this.first + i];
view.bindingContext = this.updateBindingContext(view.bindingContext, this.first + i, items.length);
}

for(i = 0, ii = splices.length; i < ii; ++i){
Expand Down

0 comments on commit e29c46f

Please sign in to comment.