|
394 | 394 | toScroll = active.lastScroll || $.mobile.defaultHomeScroll, |
395 | 395 | screenHeight = getScreenHeight(); |
396 | 396 |
|
397 | | - // Scroll to top |
398 | | - window.scrollTo( 0, $.mobile.defaultHomeScroll ); |
| 397 | + if( $.support.overflowScrollingTouch && fromPage ){ |
| 398 | + // Send focus to the newly shown page |
| 399 | + $.mobile.silentScroll( toScroll, toPage ); |
| 400 | + } |
| 401 | + else{ |
| 402 | + window.scrollTo( 0, $.mobile.defaultHomeScroll ); |
| 403 | + } |
399 | 404 |
|
400 | 405 | //if the Y location we're scrolling to is less than 10px, let it go for sake of smoothness |
401 | | - if( toScroll < $.mobile.minScrollBack ){ |
| 406 | + if( toScroll < $.mobile.minScrollBack && !$.support.overflowScrollingTouch ){ |
402 | 407 | toScroll = 0; |
403 | 408 | } |
404 | 409 |
|
405 | 410 | if( fromPage ) { |
406 | 411 | //trigger before show/hide events |
407 | 412 | fromPage.data( "page" )._trigger( "beforehide", null, { nextPage: toPage } ); |
408 | 413 | } |
409 | | - toPage |
410 | | - .height( screenHeight + toScroll ) |
| 414 | + if( !$.support.overflowScrollingTouch){ |
| 415 | + toPage.height( screenHeight + toScroll ); |
| 416 | + } |
| 417 | + |
| 418 | + toPage |
411 | 419 | .data( "page" )._trigger( "beforeshow", null, { prevPage: fromPage || $( "" ) } ); |
412 | 420 |
|
413 | 421 | //clear page loader |
|
420 | 428 | promise = th( transition, reverse, toPage, fromPage ); |
421 | 429 |
|
422 | 430 | promise.done(function() { |
423 | | - //reset toPage height bac |
424 | | - toPage.height( "" ); |
425 | 431 |
|
426 | | - // Send focus to the newly shown page |
427 | | - reFocus( toPage ); |
428 | 432 |
|
429 | | - // Jump to top or prev scroll, sometimes on iOS the page has not rendered yet. |
430 | | - $.mobile.silentScroll( toScroll ); |
| 433 | + if( $.support.overflowScrollingTouch ){ |
| 434 | + $.mobile.silentScroll( toScroll, toPage ); |
| 435 | + } |
| 436 | + else{ |
| 437 | + //reset toPage height bac |
| 438 | + toPage.height( "" ); |
| 439 | + |
| 440 | + // Send focus to the newly shown page |
| 441 | + reFocus( toPage ); |
431 | 442 |
|
| 443 | + // Jump to top or prev scroll, sometimes on iOS the page has not rendered yet. |
| 444 | + $.mobile.silentScroll( toScroll ); |
| 445 | + } |
432 | 446 | //trigger show/hide events |
433 | 447 | if( fromPage ) { |
434 | 448 | fromPage.height("").data( "page" )._trigger( "hide", null, { nextPage: toPage } ); |
|
445 | 459 | function getScreenHeight(){ |
446 | 460 | var orientation = jQuery.event.special.orientationchange.orientation(), |
447 | 461 | port = orientation === "portrait", |
448 | | - winMin = port ? 480 : 320, |
449 | | - screenHeight = port ? screen.availHeight : screen.availWidth, |
| 462 | + winMin = port ? 460 : 300, |
| 463 | + screenHeight = port ? document.documentElement.clientHeight || screen.availHeight : screen.availWidth || document.documentElement.clientWidth, |
450 | 464 | winHeight = Math.max( winMin, $( window ).height() ), |
451 | 465 | pageMin = Math.min( screenHeight, winHeight ); |
452 | 466 |
|
453 | 467 | return pageMin; |
454 | 468 | } |
| 469 | + |
455 | 470 |
|
456 | 471 | //simply set the active page's minimum height to screen height, depending on orientation |
457 | 472 | function resetActivePageHeight(){ |
458 | | - $( "." + $.mobile.activePageClass ).css( "min-height", getScreenHeight() ); |
| 473 | + $( "." + $.mobile.activePageClass ).css( ( $.support.overflowScrollingTouch ? "height" : "min-height" ), getScreenHeight() ); |
459 | 474 | } |
| 475 | + |
| 476 | + // TEMP TEMP |
| 477 | + $.mobile.getScreenHeight = getScreenHeight; |
| 478 | + $.mobile.resetActivePageHeight = resetActivePageHeight; |
460 | 479 |
|
461 | 480 | //shared page enhancements |
462 | 481 | function enhancePage( $page, role ) { |
|
893 | 912 | } |
894 | 913 |
|
895 | 914 | // Set active item's lastScroll prop |
896 | | - if( active ){ |
897 | | - active.lastScroll = $( window ).scrollTop(); |
| 915 | + if( active && fromPage ){ |
| 916 | + active.lastScroll = $( ( $.support.overflowScrollingTouch ? fromPage : window ) ).scrollTop(); |
898 | 917 | } |
899 | 918 |
|
900 | 919 | // Kill the keyboard. |
|
0 commit comments