cinera_pre.js: Add sticky-awareness to auto-scroll
This lets the grid view auto-scroll out from under the control bar.
This commit is contained in:
parent
7e80017434
commit
4ba03f9338
|
@ -23,7 +23,7 @@ typedef struct
|
||||||
version CINERA_APP_VERSION = {
|
version CINERA_APP_VERSION = {
|
||||||
.Major = 0,
|
.Major = 0,
|
||||||
.Minor = 8,
|
.Minor = 8,
|
||||||
.Patch = 4
|
.Patch = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <stdarg.h> // NOTE(matt): varargs
|
#include <stdarg.h> // NOTE(matt): varargs
|
||||||
|
|
|
@ -268,21 +268,23 @@ var ScrollTicking = false;
|
||||||
var ScrollerFunction;
|
var ScrollerFunction;
|
||||||
var ScrollCondition;
|
var ScrollCondition;
|
||||||
|
|
||||||
function ScrollTo(Element, ScrollPos) {
|
function ScrollTo(Element, ScrollPos, StickyObscuringElement) {
|
||||||
var BoundingRect = Element.getBoundingClientRect();
|
var BoundingRect = Element.getBoundingClientRect();
|
||||||
var Height = BoundingRect.height;
|
var Height = BoundingRect.height;
|
||||||
var PercentageOfInView = 89;
|
var PercentageOfInView = 89;
|
||||||
var GatherableHeight = Height * (1 - PercentageOfInView / 100);
|
var GatherableHeight = Height * (1 - PercentageOfInView / 100);
|
||||||
var ScrollY = BoundingRect.top;
|
var ScrollY = BoundingRect.top;
|
||||||
var YOffsetFromPage = getElementYOffsetFromPage(Element);
|
var YOffsetFromPage = getElementYOffsetFromPage(Element);
|
||||||
var DesiredScroll = null;
|
|
||||||
|
|
||||||
if(ScrollY < 0)
|
var DesiredScroll = null;
|
||||||
|
var Ceiling = StickyObscuringElement ? StickyObscuringElement.offsetHeight : 0;
|
||||||
|
|
||||||
|
if(ScrollY < Ceiling)
|
||||||
{
|
{
|
||||||
ScrollY = ~ScrollY;
|
if(ScrollY < 0) { ScrollY = -ScrollY; }
|
||||||
if(ScrollY <= GatherableHeight)
|
if(ScrollY <= GatherableHeight)
|
||||||
{
|
{
|
||||||
DesiredScroll = YOffsetFromPage;
|
DesiredScroll = YOffsetFromPage - Ceiling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -304,7 +306,7 @@ function ScrollTo(Element, ScrollPos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function
|
function
|
||||||
InitScrollEventListener(Element)
|
InitScrollEventListener(Element, StickyObscuringElement)
|
||||||
{
|
{
|
||||||
window.addEventListener('scroll', function() {
|
window.addEventListener('scroll', function() {
|
||||||
if(ScrollCondition == undefined || ScrollCondition == true)
|
if(ScrollCondition == undefined || ScrollCondition == true)
|
||||||
|
@ -314,7 +316,7 @@ InitScrollEventListener(Element)
|
||||||
if (!ScrollTicking) {
|
if (!ScrollTicking) {
|
||||||
window.requestAnimationFrame(function() {
|
window.requestAnimationFrame(function() {
|
||||||
clearTimeout(ScrollerFunction);
|
clearTimeout(ScrollerFunction);
|
||||||
ScrollerFunction = setTimeout(ScrollTo, 2000, Element, LastScrollYPos);
|
ScrollerFunction = setTimeout(ScrollTo, 2000, Element, LastScrollYPos, StickyObscuringElement);
|
||||||
ScrollTicking = false;
|
ScrollTicking = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ BindGridKeys(Nav.GridSize);
|
||||||
BindControls();
|
BindControls();
|
||||||
InitResizeEventListener();
|
InitResizeEventListener();
|
||||||
InitOrientationChangeListener();
|
InitOrientationChangeListener();
|
||||||
InitScrollEventListener(Nav.Grid);
|
InitScrollEventListener(Nav.GridContainer, Nav.Controls.Header);
|
||||||
//
|
//
|
||||||
////
|
////
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue