Skip to content

Commit 93811d2

Browse files
committed
Fixed preloader/fetched content fade transition, removed odd ‘snap’ when content size varies.
1 parent bd711e9 commit 93811d2

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

css/structure/jquery.mobile.core.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ div.ui-mobile-viewport { overflow-x: hidden; }
5454
/* loading screen */
5555
.ui-loading .ui-mobile-viewport { overflow: hidden !important; }
5656
.ui-loading .ui-loader { display: block; }
57-
.ui-loader-inline .ui-icon-loading { display: block; margin: 1em auto; width: 35px; height: 35px; background-color: rgba(0,0,0,.1); }
57+
.ui-loading-inline { min-height: 35px; position: relative; }
58+
59+
.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); }
5860

5961
.ui-loading .ui-page { overflow: hidden; }
6062
.ui-loader { display: none; position: absolute; opacity: .85; z-index: 100; left: 50%; width: 200px; margin-left: -130px; margin-top: -35px; padding: 10px 30px; }

docs/pages/dialog.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ <h1>Delete page?</h1>
2525
<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>
2626
<a href="docs-dialogs.html" data-role="button" data-rel="back" data-theme="b">Sounds good</a>
2727
<a href="docs-dialogs.html" data-role="button" data-rel="back" data-theme="c">Cancel</a>
28+
29+
<div class="test-content">
30+
This is some alternate content.
31+
</div>
2832
</div>
2933
</div>
3034

docs/pages/fetchlinks.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ <h2>AJAX Fetch Links</h2>
2626

2727
<pre><code>&lt;a href=&quot;dialog.html&quot; <strong>data-rel=&quot;dialog&quot;</strong>&gt;Link&lt;/a&gt;
2828
</code></pre>
29-
<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>
29+
<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>
30+
31+
<p><a data-role="fetchlink" data-target=".quote" href="dialog.html" data-fragment=".test-content">Alternate Content</a></p>
32+
3033

3134
<pre><code>&lt;a href=&quot;dialog.html&quot; <strong>data-target=&quot;.quote&quot;</strong>&gt;
3235
</code></pre>

js/jquery.mobile.fetchlink.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,32 @@ $.widget( "mobile.fetchlink", $.mobile.widget, {
3333
if ( url && method ) {
3434

3535
targetEl.ajaxStart(function(){
36-
$(this).trigger('inlineLoader');
36+
var $el = $(this);
37+
38+
$el
39+
.addClass('ui-loading-inline')
40+
.trigger('inlineLoader')
41+
.height( $el.height() );
3742
});
3843

3944
$.get( url, function( data ) {
4045
var rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
4146
data = $( $("<div/>").append( data.replace( rscript, "" ) ).find( load ) )
4247
responseEl = !fragment ? $( data.html() ) : data;
43-
48+
49+
/* TODO: Fetched relative a/img paths are broken by the base tag. */
50+
4451
setTimeout(function() {
4552
targetEl[ method ]( responseEl.addClass('fade in') );
4653

4754
responseEl
4855
.trigger( "create" )
4956
.trigger( "fetchlink", { target : targetEl, data: responseEl });
57+
58+
targetEl
59+
.removeClass('ui-loading-inline')
60+
.height('auto');
5061
}, 300);
51-
5262
});
5363
}
5464
}
@@ -62,7 +72,7 @@ $( document ).bind( "inlineLoader", function( e ){
6272
$( e.target ).children().removeClass('fade in').addClass('fade out');
6373

6474
setTimeout(function() {
65-
$( e.target ).html( "<div class='ui-loader-inline'><span class='ui-icon ui-icon-loading spin'></span></div>" );
75+
$( e.target ).html( "<div class='ui-loader-inline fade in'><span class='ui-icon ui-icon-loading spin'></span></div>" );
6676
}, 300);
6777
});
6878

0 commit comments

Comments
 (0)