mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-16 22:10:25 +00:00
Fixed preloader/fetched content fade transition, removed odd ‘snap’ when content size varies.
This commit is contained in:
parent
bd711e9f19
commit
93811d2775
4 changed files with 25 additions and 6 deletions
|
|
@ -54,7 +54,9 @@ div.ui-mobile-viewport { overflow-x: hidden; }
|
|||
/* loading screen */
|
||||
.ui-loading .ui-mobile-viewport { overflow: hidden !important; }
|
||||
.ui-loading .ui-loader { display: block; }
|
||||
.ui-loader-inline .ui-icon-loading { display: block; margin: 1em auto; width: 35px; height: 35px; background-color: rgba(0,0,0,.1); }
|
||||
.ui-loading-inline { min-height: 35px; position: relative; }
|
||||
|
||||
.ui-loader-inline .ui-icon-loading { display: block; margin: 0 auto; position: absolute; left: 50%; top: 50%; margin: -17px 0 0 -17px; width: 35px; height: 35px; background-color: rgba(0,0,0,.1); }
|
||||
|
||||
.ui-loading .ui-page { overflow: hidden; }
|
||||
.ui-loader { display: none; position: absolute; opacity: .85; z-index: 100; left: 50%; width: 200px; margin-left: -130px; margin-top: -35px; padding: 10px 30px; }
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@
|
|||
<p>This is a regular page, styled as a dialog. To create a dialog, just link to a normal page and include a transition and <code>data-rel="dialog"</code> attribute.</p>
|
||||
<a href="docs-dialogs.html" data-role="button" data-rel="back" data-theme="b">Sounds good</a>
|
||||
<a href="docs-dialogs.html" data-role="button" data-rel="back" data-theme="c">Cancel</a>
|
||||
|
||||
<div class="test-content">
|
||||
This is some alternate content.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@
|
|||
|
||||
<pre><code><a href="dialog.html" <strong>data-rel="dialog"</strong>>Link</a>
|
||||
</code></pre>
|
||||
<p>A <a data-role="fetchlink" data-target=".quote" href="dialog.html" data-transition="fade">fetch link</a> is created by adding the <code>data-target</code> attribute to a link. This tells the framework to <strong>not</strong> change pages and instead load the <code>href</code> into the target DOM element on the current page when the link is clicked. The target can be any jQuery selector (or restrict to ID only?). </p>
|
||||
<p>A <a data-role="fetchlink" data-target=".quote" href="dialog.html">fetch link</a> is created by adding the <code>data-target</code> attribute to a link. This tells the framework to <strong>not</strong> change pages and instead load the <code>href</code> into the target DOM element on the current page when the link is clicked. The target can be any jQuery selector (or restrict to ID only?). </p>
|
||||
|
||||
<p><a data-role="fetchlink" data-target=".quote" href="dialog.html" data-fragment=".test-content">Alternate Content</a></p>
|
||||
|
||||
|
||||
<pre><code><a href="dialog.html" <strong>data-target=".quote"</strong>>
|
||||
</code></pre>
|
||||
|
|
|
|||
|
|
@ -33,22 +33,32 @@ $.widget( "mobile.fetchlink", $.mobile.widget, {
|
|||
if ( url && method ) {
|
||||
|
||||
targetEl.ajaxStart(function(){
|
||||
$(this).trigger('inlineLoader');
|
||||
var $el = $(this);
|
||||
|
||||
$el
|
||||
.addClass('ui-loading-inline')
|
||||
.trigger('inlineLoader')
|
||||
.height( $el.height() );
|
||||
});
|
||||
|
||||
$.get( url, function( data ) {
|
||||
var rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
||||
data = $( $("<div/>").append( data.replace( rscript, "" ) ).find( load ) )
|
||||
responseEl = !fragment ? $( data.html() ) : data;
|
||||
|
||||
|
||||
/* TODO: Fetched relative a/img paths are broken by the base tag. */
|
||||
|
||||
setTimeout(function() {
|
||||
targetEl[ method ]( responseEl.addClass('fade in') );
|
||||
|
||||
responseEl
|
||||
.trigger( "create" )
|
||||
.trigger( "fetchlink", { target : targetEl, data: responseEl });
|
||||
|
||||
targetEl
|
||||
.removeClass('ui-loading-inline')
|
||||
.height('auto');
|
||||
}, 300);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +72,7 @@ $( document ).bind( "inlineLoader", function( e ){
|
|||
$( e.target ).children().removeClass('fade in').addClass('fade out');
|
||||
|
||||
setTimeout(function() {
|
||||
$( e.target ).html( "<div class='ui-loader-inline'><span class='ui-icon ui-icon-loading spin'></span></div>" );
|
||||
$( e.target ).html( "<div class='ui-loader-inline fade in'><span class='ui-icon ui-icon-loading spin'></span></div>" );
|
||||
}, 300);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue