Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove addEvent from config

  • Loading branch information...
commit 88896e3d1e12be93f2694dc8473fab99b954d9e0 1 parent fe8699b
@turnertime authored
Showing with 24 additions and 23 deletions.
  1. +24 −23 virtualist.js
View
47 virtualist.js
@@ -71,39 +71,40 @@ window.Virtualist = window.Virtualist || (function (document, HTMLElement, scree
if (typeof settings.render !== "function") { throw new Error("render must be a function"); }
if (typeof settings.size !== "number") { throw new Error("size must be a number"); }
- var config = {
+ var
+ config = {
- // adds a new event handler to the dom element specified
- addEvent: buildAddEvent(),
+ // the number of pages in buffer (default: 1)
+ bufferSize: (typeof settings.bufferSize === "number") ? Math.ceil(Math.max(1, settings.bufferSize)) : 1,
- // the number of pages in buffer (default: 1)
- bufferSize: (typeof settings.bufferSize === "number") ? Math.ceil(Math.max(1, settings.bufferSize)) : 1,
+ // the HTMLElement with the virtualist instance
+ el: settings.el,
- // the HTMLElement with the virtualist instance
- el: settings.el,
+ // the size of the viewport (default: screen.avail[Height|Width])
+ explicitSize: (typeof settings.explicitSize === "number") ? Math.ceil(Math.max(1, settings.explicitSize)) : (settings.isHorizontal ? screen.availWidth : screen.availHeight),
- // the size of the viewport (default: screen.avail[Height|Width])
- explicitSize: (typeof settings.explicitSize === "number") ? Math.ceil(Math.max(1, settings.explicitSize)) : (settings.isHorizontal ? screen.availWidth : screen.availHeight),
+ // specifies whether the list is virtualized horizontally or vertically
+ isHorizontal: !!settings.isHorizontal,
- // specifies whether the list is virtualized horizontally or vertically
- isHorizontal: !!settings.isHorizontal,
+ // the number of items to render
+ length: Math.ceil(Math.max(0, settings.length)),
- // the number of items to render
- length: Math.ceil(Math.max(0, settings.length)),
+ // the maximum size (in pixels) of the canvas (default: 500000)
+ maxCanvasSize: (typeof settings.maxCanvasSize === "number") ? Math.ceil(Math.max(1, settings.maxCanvasSize)) : 500000,
- // the maximum size (in pixels) of the canvas (default: 500000)
- maxCanvasSize: (typeof settings.maxCanvasSize === "number") ? Math.ceil(Math.max(1, settings.maxCanvasSize)) : 500000,
+ // the function used to render a list item (parameter: index, returns: the html string representation of the rendered item)
+ render: settings.render,
- // the function used to render a list item (parameter: index, returns: the html string representation of the rendered item)
- render: settings.render,
+ // the current scroll position
+ scrollPosition: 0,
- // the current scroll position
- scrollPosition: 0,
+ // the size (in pixels) of a single list item
+ size: Math.ceil(Math.max(1, settings.size))
- // the size (in pixels) of a single list item
- size: Math.ceil(Math.max(1, settings.size))
+ },
- };
+ // Pure-javascript function used for cross-browser add event
+ addEvent = buildAddEvent();
//-------------------------------------------
@@ -145,7 +146,7 @@ window.Virtualist = window.Virtualist || (function (document, HTMLElement, scree
var html = render(config, e.target.scrollTop);
if (html) { config.calculated.canvas.innerHTML = html; }
};
- config.addEvent(config.el, "scroll", config.scrollHandler);
+ addEvent(config.el, "scroll", config.scrollHandler);
Please sign in to comment.
Something went wrong with that request. Please try again.