Skip to content

Commit

Permalink
properly cancel requests
Browse files Browse the repository at this point in the history
  • Loading branch information
schlosser committed Jun 22, 2016
1 parent 9152188 commit 15b6de5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ var options = {
figureTagName: 'figure',
spaceBetweenImages: 8,
transitionSpeed: 500,
primaryImageBufferHeight: 3000,
secondaryImageBufferHeight: 1000,
primaryImageBufferHeight: 1000,
secondaryImageBufferHeight: 300,
thumbnailSize: 20,
urlForSize: function(filename, size) {
return '/img/' + size + '/' + filename;
Expand Down Expand Up @@ -193,15 +193,15 @@ Transition speed in milliseconds.
#### `options.primaryImageBufferHeight` _(number)_

Height in pixels of images to preload in the direction that the user is scrolling. For example, in the default case, if the user is scrolling down, 3000px worth of images will be loaded below the viewport.
Height in pixels of images to preload in the direction that the user is scrolling. For example, in the default case, if the user is scrolling down, 1000px worth of images will be loaded below the viewport.

> **Default**: `3000`
> **Default**: `1000`
#### `options.secondaryImageBufferHeight` _(number)_

Height in pixels of images to preload in the direction that the user is NOT scrolling. For example, in the default case, if the user is scrolling down, 1000px worth of images will be loaded above the viewport. Images further up will be removed.
Height in pixels of images to preload in the direction that the user is NOT scrolling. For example, in the default case, if the user is scrolling down, 300px worth of images will be loaded above the viewport. Images further up will be removed.

> **Default**: `1000`
> **Default**: `300`
#### `options.thumbnailSize` _(number)_

Expand Down Expand Up @@ -280,6 +280,6 @@ Enable the Pig library by beginning to listen to scroll and resize events, loadi
Disable the Pig library by removing event listeners set in `Pig.enable()`.
[download]: https://github.com/schlosser/pig.js/releases/download/v0.1/pig.min.js
[download]: https://github.com/schlosser/pig.js/releases/download/v0.2/pig.min.js
[feeding-dan]: https://feeding.schlosser.io/
[feeding-dan-gh]: https://github.com/schlosser/feeding-dan/
24 changes: 13 additions & 11 deletions src/pig.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,20 @@
* Default: 3000
* Description: Height in pixels of images to preload in the direction
* that the user is scrolling. For example, in the default case, if the
* user is scrolling down, 3000px worth of images will be loaded below
* user is scrolling down, 1000px worth of images will be loaded below
* the viewport.
*/
primaryImageBufferHeight: 3000,
primaryImageBufferHeight: 1000,

/**
* Type: Number
* Default: 100
* Description: Height in pixels of images to preload in the direction
* that the user is NOT scrolling. For example, in the default case, if
* the user is scrolling down, 1000px worth of images will be loaded
* the user is scrolling down, 300px worth of images will be loaded
* above the viewport. Images further up will be removed.
*/
secondaryImageBufferHeight: 1000,
secondaryImageBufferHeight: 300,

/**
* Type: Number
Expand Down Expand Up @@ -780,27 +780,29 @@
* ProgressiveImage object.
*/
ProgressiveImage.prototype.hide = function() {
// Remove the image from the DOM.
if (this.existsOnPage) {
this.pig.container.removeChild(this.getElement());
}

this.existsOnPage = false;

// Remove the images from the element, so that if a user is scrolling super
// fast, we won't try to load every image we scroll past.
if (this.getElement()) {
if (this.thumbnail) {
this.thumbnail.src = '';
this.getElement().removeChild(this.thumbnail);
delete this.thumbnail;
}

if (this.fullImage) {
this.fullImage.src = '';
this.getElement().removeChild(this.fullImage);
delete this.fullImage;
}
}

// Remove the image from the DOM.
if (this.existsOnPage) {
this.pig.container.removeChild(this.getElement());
}

this.existsOnPage = false;

};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pig.min.js

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

0 comments on commit 15b6de5

Please sign in to comment.