Skip to content

Commit

Permalink
fix destroy method (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
callmecavs committed Jul 16, 2015
1 parent 68e9d86 commit 5266f94
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "layzr.js",
"version": "1.4.2",
"version": "1.4.3",
"description": "A small, fast, modern, and dependency-free library for lazy loading.",
"homepage": "http://callmecavs.github.io/layzr.js/",
"main": ["dist/layzr.js"],
Expand Down
15 changes: 8 additions & 7 deletions dist/layzr.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function Layzr(options) {
// nodelist
this._nodes = document.querySelectorAll(this._optionsSelector);

// scroll and resize handler
this._handlerBind = this._requestScroll.bind(this);

// call to create
this._create();
}
Expand Down Expand Up @@ -84,19 +87,17 @@ Layzr.prototype._getContainerHeight = function() {

Layzr.prototype._create = function() {
// fire scroll event once
this._requestScroll();
this._handlerBind();

// bind scroll and resize event
this._optionsContainer.addEventListener('scroll', this._requestScroll.bind(this), false);
this._optionsContainer.addEventListener('resize', this._requestScroll.bind(this), false);
this._optionsContainer.addEventListener('scroll', this._handlerBind, false);
this._optionsContainer.addEventListener('resize', this._handlerBind, false);
};

Layzr.prototype._destroy = function() {
// possibly remove attributes, and set all sources?

// unbind scroll and resize event
this._optionsContainer.removeEventListener('scroll', this._requestScroll.bind(this), false);
this._optionsContainer.removeEventListener('resize', this._requestScroll.bind(this), false);
this._optionsContainer.removeEventListener('scroll', this._handlerBind, false);
this._optionsContainer.removeEventListener('resize', this._handlerBind, false);
};

Layzr.prototype._inViewport = function(node) {
Expand Down
2 changes: 1 addition & 1 deletion dist/layzr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "layzr.js",
"version": "1.4.2",
"version": "1.4.3",
"description": "A small, fast, modern, and dependency-free library for lazy loading.",
"homepage": "http://callmecavs.github.io/layzr.js/",
"main": "dist/layzr.js",
Expand Down
15 changes: 8 additions & 7 deletions src/layzr.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ function Layzr(options) {
// nodelist
this._nodes = document.querySelectorAll(this._optionsSelector);

// scroll and resize handler
this._handlerBind = this._requestScroll.bind(this);

// call to create
this._create();
}
Expand Down Expand Up @@ -69,19 +72,17 @@ Layzr.prototype._getContainerHeight = function() {

Layzr.prototype._create = function() {
// fire scroll event once
this._requestScroll();
this._handlerBind();

// bind scroll and resize event
this._optionsContainer.addEventListener('scroll', this._requestScroll.bind(this), false);
this._optionsContainer.addEventListener('resize', this._requestScroll.bind(this), false);
this._optionsContainer.addEventListener('scroll', this._handlerBind, false);
this._optionsContainer.addEventListener('resize', this._handlerBind, false);
};

Layzr.prototype._destroy = function() {
// possibly remove attributes, and set all sources?

// unbind scroll and resize event
this._optionsContainer.removeEventListener('scroll', this._requestScroll.bind(this), false);
this._optionsContainer.removeEventListener('resize', this._requestScroll.bind(this), false);
this._optionsContainer.removeEventListener('scroll', this._handlerBind, false);
this._optionsContainer.removeEventListener('resize', this._handlerBind, false);
};

Layzr.prototype._inViewport = function(node) {
Expand Down

0 comments on commit 5266f94

Please sign in to comment.