Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
44
gaia/shared/js/sticky_header.js
Executable file
44
gaia/shared/js/sticky_header.js
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
/* exported StickyHeader */
|
||||
|
||||
function StickyHeader(scrollable, sticky) {
|
||||
'use strict';
|
||||
|
||||
var headers = scrollable.getElementsByTagName('header');
|
||||
var stickyPosition;
|
||||
var stickyStyle = sticky.style;
|
||||
|
||||
this._throttledRefresh = function() {
|
||||
var display = false;
|
||||
if (stickyPosition === undefined) {
|
||||
stickyPosition = sticky.offsetHeight + sticky.offsetTop;
|
||||
}
|
||||
for (var i = 1, length = headers.length; i < length; i++) {
|
||||
if (headers[i].offsetTop - scrollable.scrollTop > stickyPosition) {
|
||||
|
||||
// While reflecting a header, make sure to not reflect a header
|
||||
// that is not displayed.
|
||||
var lookupIndex = 1;
|
||||
var header = headers[i - lookupIndex];
|
||||
while (header && header.offsetHeight === 0) {
|
||||
lookupIndex++;
|
||||
header = headers[i - lookupIndex];
|
||||
}
|
||||
|
||||
stickyStyle.backgroundImage = '-moz-element(#' + header.id + ')';
|
||||
display = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sticky.classList.toggle('has-content', display);
|
||||
this.throttle = null;
|
||||
}.bind(this);
|
||||
|
||||
this.refresh = function() {
|
||||
if (!this.throttle) {
|
||||
this.throttle = setTimeout(this._throttledRefresh, 0);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
scrollable.addEventListener('scroll', this.refresh);
|
||||
}
|
||||
Loading…
Reference in a new issue