Skip to content

Commit

Permalink
N.grid bug fix
Browse files Browse the repository at this point in the history
 - Calculating scroll paging limit index in onBind event is wrong ->
fixed
 - Calculating scroll paging limit index when rebinding is wrong ->
fixed
  • Loading branch information
bbalganjjm committed Dec 10, 2014
1 parent 5fa3788 commit 5ad1f77
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/natural_js/natural.ui.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Natural-UI v0.8.1.5
* Natural-UI v0.8.1.7
* bbalganjjm@gmail.com
*
* Copyright 2014 KIM HWANG MAN
Expand All @@ -8,7 +8,7 @@
* Date: 2014-09-26T11:11Z
*/
(function(window, $) {
var version = "0.8.1.5";
var version = "0.8.1.7";

// N local variables
$.fn.extend(N, {
Expand Down Expand Up @@ -1713,6 +1713,10 @@
if(opts.scrollPaging !== undefined) {
$.extend(this.options.scrollPaging, opts.scrollPaging);
}

//for scroll paging limit
this.options.scrollPaging.limit = this.options.scrollPaging.size;

if(N.type(this.options.context) === "string") {
this.options.context = N(this.options.context);
}
Expand Down Expand Up @@ -1824,7 +1828,7 @@
var this_ = this;
var limit;
if(opts.height > 0) {
limit = Math.min(opts.scrollPaging.size, opts.data.length);
limit = Math.min(opts.scrollPaging.limit, opts.data.length);
} else {
limit = opts.data.length
}
Expand Down Expand Up @@ -1860,11 +1864,11 @@
}
if(i <= lastIdx) {
render();
if(i === lastIdx) {
if(opts.onBind !== null) {
opts.onBind.call(opts.context, opts.context, opts.data);
}
} else if(i === lastIdx + 1) {
if(opts.onBind !== null) {
opts.onBind.call(opts.context, opts.context, opts.data);
}
opts.scrollPaging.limit = opts.scrollPaging.size;
}
});
};
Expand Down Expand Up @@ -2063,7 +2067,7 @@

// Scroll paging
var this_ = this;
var defSPSize = opts.scrollPaging.size;
var defSPSize = opts.scrollPaging.limit;
var tbodyLength;
tbodyWrap.scroll(function() {
var thisWrap = $(this);
Expand All @@ -2074,10 +2078,10 @@
opts.scrollPaging.idx += defSPSize;
}

if (opts.scrollPaging.idx + opts.scrollPaging.size >= opts.data.length) {
opts.scrollPaging.size = opts.data.length - opts.scrollPaging.idx;
if (opts.scrollPaging.idx + opts.scrollPaging.limit >= opts.data.length) {
opts.scrollPaging.limit = opts.data.length - opts.scrollPaging.idx;
} else {
opts.scrollPaging.size = defSPSize;
opts.scrollPaging.limit = defSPSize;
}

if(opts.scrollPaging.idx < opts.data.length) {
Expand Down

0 comments on commit 5ad1f77

Please sign in to comment.