This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added comments to clarify some of the changes.
- Loading branch information
1 parent
d76865d
commit 6a6fdcd
Showing
2 changed files
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -532,6 +532,8 @@ <h1>{{video.snippet.title}}</h1> | |
|
||
// We can take some shortcuts since we know that there won't be any nested objects within the two param objects. | ||
_paramsEqual: function(firstParams, secondParams) { | ||
// First, check to make sure that for every key in firstParams, there's a key in secondParams, and both | ||
// keys have values that are equal. If not, return false. | ||
for (var key in firstParams) { | ||
if (firstParams.hasOwnProperty(key)) { | ||
if (firstParams[key] !== secondParams[key]) { | ||
|
@@ -540,12 +542,15 @@ <h1>{{video.snippet.title}}</h1> | |
} | ||
} | ||
|
||
// Then, check to make sure that all the keys secondParams are also present in firstParams. | ||
// If secondParams has a key that's not in firstParams, return false. | ||
for (var key in secondParams) { | ||
if (secondParams.hasOwnProperty(key) && !firstParams.hasOwnProperty(key)) { | ||
return false; | ||
} | ||
} | ||
|
||
// If those tests succeed, return true, since the keys/values in both sets of params match. | ||
return true; | ||
}, | ||
|
||
|
@@ -569,6 +574,16 @@ <h1>{{video.snippet.title}}</h1> | |
this._nextPageToken = response.nextPageToken; | ||
|
||
this.async(function() { | ||
// Additional pages of results are loaded dynamically when there's a scroll event and the user | ||
// has scrolled close to the bottom of the container. (See this.handleResultsScroll) | ||
// There's a bootstrapping issue, though, since if the initial request(s) don't return enough | ||
// videos to trigger scroll bars, it's not possible for the user to trigger a scroll event and they're | ||
// stuck with the initial results. | ||
// Therefore, we check here to see whether there are no scroll bars (clientHeight == scrollHeight | ||
// means there aren't any) and if there aren't, load in the next page of results. | ||
// This check will be done each time there's an API response, so if the next page of results isn't | ||
// enough to show scroll bars, another page will be loaded, until scroll bars are visible or until | ||
// there are no more pages of results. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jeffposnick
Author
Contributor
|
||
if (this.$.resultspage.scroller.clientHeight == this.$.resultspage.scroller.scrollHeight) { | ||
this.updateYouTubeApiParams(); | ||
} | ||
|
https://github.com/Polymer/core-scroll-threshold might be useful to you in the future.