scroll updates
maintains scroll position (css3 scrolling only) only uses iScroll if touch is supported, otherwise uses browser default scrolling
This commit is contained in:
parent
bca792c256
commit
586b4d7293
|
@ -267,37 +267,51 @@ ViewNavigator.prototype.updateView = function( viewDescriptor ) {
|
|||
}
|
||||
|
||||
|
||||
ViewNavigator.prototype.resetScroller = function() {
|
||||
|
||||
var id = this.contentViewHolder.attr( "id" );
|
||||
var currentViewDescriptor = this.history[ this.history.length-1];
|
||||
ViewNavigator.prototype.destroyScroller = function() {
|
||||
|
||||
if ( !this.winPhone ) {
|
||||
if ( this.scroller != null ) {
|
||||
this.scroller.destroy();
|
||||
this.scroller = null;
|
||||
}
|
||||
if ( id && !(currentViewDescriptor && currentViewDescriptor.scroll === false)) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ViewNavigator.prototype.resetScroller = function() {
|
||||
|
||||
var id = this.contentViewHolder.attr( "id" );
|
||||
var currentViewDescriptor = this.history[ this.history.length-1];
|
||||
this.destroyScroller();
|
||||
|
||||
if ( !this.winPhone ) {
|
||||
if ( id && !(currentViewDescriptor && currentViewDescriptor.scroll == false)) {
|
||||
var self = this;
|
||||
if ( this.touchEnabled ){
|
||||
setTimeout( function() {
|
||||
|
||||
//use this to mantain scroll position when scroller is destroyed
|
||||
var targetDiv = $( $("#"+id ).children()[0] );
|
||||
var scrollY= targetDiv.attr( "scrollY" );
|
||||
var originalTopMargin = targetDiv.attr( "originalTopMargin" );
|
||||
if ( scrollY != undefined && scrollY != "" ){
|
||||
if ( currentViewDescriptor.maintainScrollPosition !== false && scrollY != undefined && scrollY != "" ){
|
||||
// console.log( "resetScroller scrollY: " + scrollY)
|
||||
// targetDiv.css( "margin-top", originalTopMargin );
|
||||
var cssString = "translate3d(0px, "+(originalTopMargin).toString()+"px, 0px)";
|
||||
targetDiv.css( "-webkit-transform", cssString );
|
||||
}
|
||||
self.scroller = new iScroll( id );
|
||||
if ( scrollY != undefined && scrollY != "" ) {
|
||||
if ( currentViewDescriptor.maintainScrollPosition !== false && scrollY != undefined && scrollY != "" ) {
|
||||
self.scroller.scrollTo( 0, parseInt( scrollY ) );
|
||||
}
|
||||
}, 10 );
|
||||
//this.scroller = new iScroll( id );
|
||||
}
|
||||
else {
|
||||
var target = $("#"+id );
|
||||
target.css( "overflow", "auto" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue