jquery-mobile/experiments/scrollview/scrollview.js
Kin Blas fbaa3c1288 Make sure newX and newY are initialized to the current scroll offsets. This fixes a scroll propagation bug that was resetting the non-scrolled dimension to zero.
Replaced all occurences of "horizontal" and "vertical" with "x" and "y".

Modified samples to use data-scroll="x|y|true".

Implemented public scrollTo(0 function that gives an optional duration parameter for animated scrolling.
2010-11-30 15:20:10 -08:00

42 lines
1.2 KiB
JavaScript

function ResizePageContentHeight(page)
{
var $page = $(page);
var $content = $page.children(".ui-content");
var hh = $page.children(".ui-header").outerHeight(); hh = hh ? hh : 0;
var fh = $page.children(".ui-footer").outerHeight(); fh = fh ? fh : 0;
var pt = parseFloat($content.css("padding-top"));
var pb = parseFloat($content.css("padding-bottom"));
var wh = window.innerHeight;
$content.height(wh - (hh + fh) - (pt + pb));
}
$("[data-role=page]").live("pageshow", function(event) {
var $page = $(this);
$page.find(".ui-content, [data-scroll]").not(".ui-scrollview-clip").each(function(){
var $this = $(this);
// XXX: Remove this check for ui-scrolllistview once we've
// integrated list divider support into the main scrollview class.
if ($this.hasClass("ui-scrolllistview"))
$this.scrolllistview();
else
{
var st = $this.data("scroll") + "";
var snap = st && st.search(/^[xy]s$/ != -1);
var dir = st && st.search(/^[xy]/) != -1 ? st.charAt(0) : null;
var opts = {};
if (dir)
opts.direction = dir;
if (snap)
opts.snap = "viewport";
$this.scrollview(opts);
}
});
ResizePageContentHeight(event.target);
});
$(document).live("orientationchange", function(event) {
ResizePageContentHeight($(".ui-page"));
});