CC-3328 : Scrolling behaviour in Chrome on OSX makes Airtime unusable

This commit is contained in:
Naomi Aro 2012-03-13 14:19:25 +01:00
parent 6830af574a
commit a8d61ff19c
1 changed files with 42 additions and 26 deletions

View File

@ -1,12 +1,12 @@
/* /*
* jQuery.stickyPanel * jQuery.stickyPanel
* ---------------------- * ----------------------
* version: 1.0.0 * version: 1.4.1
* date: 1/17/11 * date: 7/21/11
* *
* Copyright (c) 2011 Donny Velazquez * Copyright (c) 2011 Donny Velazquez
* http://donnyvblog.blogspot.com/ * http://donnyvblog.blogspot.com/
* http://code.google.com/p/stickyPanel * http://code.google.com/p/sticky-panel/
* *
* Licensed under the Apache License 2.0 * Licensed under the Apache License 2.0
* *
@ -24,55 +24,71 @@
}; };
function Scroll(event) { function Scroll(event) {
var node = event.data.selected; var node = event.data.selected;
var o = event.data.options; var o = event.data.options;
var isMobile = navigator.userAgent.toLowerCase().indexOf('mobile') > 0;
var windowHeight = $(window).height();
var nodeHeight = node.outerHeight(true);
var scrollTop = $(document).scrollTop();
// when top of window reaches the top of the panel detach // when top of window reaches the top of the panel detach
if ($(document).scrollTop() >= node.offset().top) { if (!isMobile &&
scrollTop <= $(document).height() - windowHeight && // Fix for rubberband scrolling in Safari on Lion
scrollTop > node.offset().top - o.topPadding) {
// topPadding // topPadding
var top = 0; var newNodeTop = 0;
if (o.topPadding != "undefined") { if (o.topPadding != "undefined") {
top = top + o.topPadding; newNodeTop = newNodeTop + o.topPadding;
} }
// get left before adding spacer
var nodeLeft = node.offset().left;
// save panels top // save panels top
node.data("PanelsTop", node.offset().top - top); node.data("PanelsTop", node.offset().top - newNodeTop);
// MOVED: savePanelSpace before afterDetachCSSClass to handle afterDetachCSSClass changing size of node
// savePanelSpace
if (o.savePanelSpace == true) {
var nodeWidth = node.outerWidth(true);
var nodeCssfloat = node.css("float");
var nodeCssdisplay = node.css("display");
var randomNum = Math.ceil(Math.random() * 9999); /* Pick random number between 1 and 9999 */
node.data("PanelSpaceID", "stickyPanelSpace" + randomNum);
node.before("<div id='" + node.data("PanelSpaceID") + "' style='width:" + nodeWidth + "px;height:" + nodeHeight + "px;float:" + nodeCssfloat + ";display:" + nodeCssdisplay + ";'>&nbsp;</div>");
}
// afterDetachCSSClass // afterDetachCSSClass
if (o.afterDetachCSSClass != "") { if (o.afterDetachCSSClass != "") {
node.addClass(o.afterDetachCSSClass); node.addClass(o.afterDetachCSSClass);
} }
// savePanelSpace // save inline css
if (o.savePanelSpace == true) { node.data("Original_Inline_CSS", (!node.attr("style") ? "" : node.attr("style")));
var width = node.outerWidth(true);
var height = node.outerHeight(true);
var float = node.css("float");
var randomNum = Math.ceil(Math.random() * 9999); /* Pick random number between 1 and 9999 */
node.data("PanelSpaceID", "stickyPanelSpace" + randomNum);
node.before("<div id='" + node.data("PanelSpaceID") + "' style='width:" + width + "px;height:" + height + "px;float:" + float + ";'></div>");
}
// detach panel // detach panel
node.css({ node.css({
"top": top, "margin": 0,
"left": nodeLeft,
"top": newNodeTop,
"position": "fixed" "position": "fixed"
}); });
} }
if ($(document).scrollTop() <= node.data("PanelsTop")) { // ADDED: css top check to avoid continuous reattachment
if (scrollTop <= node.data("PanelsTop") && node.css("top") != "auto") {
if (o.savePanelSpace == true) {
$("#" + node.data("PanelSpaceID")).remove();
}
if (o.savePanelSpace == true) {
$("#" + node.data("PanelSpaceID")).remove();
}
// attach panel // attach panel
node.css({ node.attr("style", node.data("Original_Inline_CSS"));
"top": "auto",
"position": "static"
});
if (o.afterDetachCSSClass != "") { if (o.afterDetachCSSClass != "") {
node.removeClass(o.afterDetachCSSClass); node.removeClass(o.afterDetachCSSClass);