jquery mobile & swipe.js - jquery-mobile

I created a carousel with swipe.js , it works fine in iOS4 and iOS5. But in iOS6, without acceleration of hardware, when we swipe, there is a lag that can not be accepted.
I have tried to create a carousel without jquery mobile, the performance is really great, but when we use JQM and listview (data-role="listview"), it became slower and the more elements in the list, the slower carousel is.
In html code, we have a carousel list and a normal listview, it seems if there are more elements in the listview, the carousel swipe will be slower. and they are two elements independent.
Here is html code
<div id='slider' class='swipe' style='width:250px'>
<ul>
<li style='display:block'><div>1</div></li>
<li style='display:none'><div>2</div></li>
<li style='display:none'><div>3</div></li>
<li style='display:none'><div>4</div></li>
<li style='display:none'><div>5</div></li>
</ul>
</div>
and a normal list view
<section class="nav_univers">
<h1>Toutes les catégories</h1>
<nav>
<ul class="categories" data-role="listview" data-inset="true">
<li>Livre<a class="xt_books"></a></li>
<li>Musique<a class="xt_music"></a></li>
<li>Video<a class="xt_video"></a></li>
<li>Jeux<a class="xt_video_games"></a></li>
<li>AAA<a class="xt_phone_gps"></a></li>
<li>QQQ<a class="xt_computing"></a></li>
<li>DDS<a class="xt_multimedia"</a></li>
<li>VVV<a class="xt_home"></a></li>
<li>GGG<a class="xt_sports"></a></li>
<li>HHH<a class="xt_mode"></a></li>
</ul>
</nav>
</section>
and with Swipejs to create an object
var slider1 = new Swipe(document.getElementById('slider'));
You can find our site here:
www.priceminister.com with user agent set to mobile device.
anyone can help me?

I had the same problem,
Change your css with :
.swipe
{
....
....
/* IOS6 issue*/
-webkit-perspective: 1000;
-webkit-backface-visibility: hidden;
}

Related

TWBS Navbar on mobile device, disable dropdown menu and use link instead

Is there a way to disable the dropdown menu in Twitter Bootstrap 3 navbar when viewing on an iPhone and similar device sizes and then to replace it with a link to another screen.
The menu takes up a lot of space. On a desktop (even a tablet) this doesn't matter. On a mobile phone I would like it to take you to a different page and disable the dropdown altogether.
CSS Approach
I would use the responsive classes for this. It's probably not ideal to have extra markup for hidden elements, but it is the easiest and most reliable approach and requires no Javascript.
demo
...
<li class="visible-xs-block"><span class="glyphicon glyphicon-user" aria-label="My profile"></span> My Profile</li>
<li class="dropdown hidden-xs">
<span class="glyphicon glyphicon-user"></span> My Profile <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li><span class="glyphicon glyphicon-signal"></span> Statistics</li>
<li><span class="glyphicon glyphicon-certificate"></span> Certificates</li>
<li><span class="glyphicon glyphicon-star"></span> Favorites</li>
<li class="divider"></li>
<li><span class="glyphicon glyphicon-log-out"></span> Logout</li>
</ul>
</li>
...
In the above snippet, you'll see that I'm using the visible-xs-block class on the <li> with the link to your alternative page. This will insure that that this element is hidden, except on mobile devices. On the dropdown, I've used the hidden-xs class, which will hide the dropdown only on mobile devices.
Javascript Approach
You can do this with Javascript as suggested by #cvrebert, and if you don't have to worry about support for IE8 or IE9, you can do this easily with matchMedia.
JS (no support for IE8/9)
if (window.matchMedia("(max-width: 768px)").matches) {
/* the view port is less than 768 pixels wide */
/* hide your dropdown and display your link */
} else {
/* the view port is at least 768 pixels wide */
/* show your dropdown and hide your link */
}
It's a bit more complicated if you want a Javascript solution and need to support IE8/IE9 because you'll have to monitor the window resize event. To do this efficiently, you'll probably want to debounce or use a timeout.
Again, to me, the best way is the CSS approach above.

Jquery Mobile overlay is turned in to page

I am using jquery mobile and wanted a overlay in to be visible when ever i need. I have this at first in my html
<body>
<div id="overlay"></div>
</body>
(if you are wondering about other pages then they are added afterwards)
but when jquery mobile 1.4.2 initializes it turns my div in to a page like so:
<div data-role="page" data-url="/" tabindex="0" class="ui-page ui-page-theme-a" style="min-height: 640px;">
<div id="overlay">
</div>
</div>
How can i make Jquery not touch this element?
Let me guess you are using it to show a splash screen.
jQuery Mobile requires at least one page to exist during initialization.
To solve this problem add one dummy jQuery Mobile page and just set it CSS to display: none; something like this:
<body>
<div id="overlay"></div>
<div data-role="page" style="display: none;">
<div/>
</body>
I seems it only does it if there are no pages initially in the body. but if you add a blank page every works fine:
<div data-role="page"></div>

Getting the content area to fill the total visible area on "short" pages?

[Using jQuery Mobile version 1.3.2]
I'm working on a jQM project and am running into a bit of a dilemma here. For pages that don't have much content (such as a home page with only 3 buttons on it), and when the footer data-position is set to "inline", there is a big ugly gap below the footer...
Of course, if I set the footer's data-position to "fixed", then it looks good IF viewed in portrait mode...
BUT... when it's viewed in landscape mode, it looks bad, as there is barely any room for the content area, due to the header and footer taking up most of the visible area...
So, my question is... is there a good, working solution for getting the footer to be fixed to the bottom in situations where the content area does not fill up the entire screen, and then have the footer position automatically switch to "inline" for situations where the content area DOES fill up (at least) the entire screen?
OR... alternately... is it possible to have the footer position "fixed" when the device is in portrait mode, and then switch the footer position to "inline" when the device is in landscape mode?
I've spent a few hours researching this online today, but I haven't found any promising solutions to this problem so far (I found a handful of articles / forum posts that addressed the topic, but they were from 2-3 years ago, and the few proposed "solutions" looked like they might create more problems than they solve).
I'm not looking for a solution that is 100% cross-browser (because I know that doesn't exist), but as long as I can find a solution that works well on mobile iOS and mobile Android, I'd be happy.
I would imagine that this would be a fairly popular issue, so I'm a bit surprised that I haven't come across a good solution so far (maybe I just haven't looked in the right place yet).
So.... any ideas?
Thanks!
You can listen to the resize and orientationchange event and then fix/unfix the footer depending on available space.
Here is a DEMO
Using script, measure the header height + footer height + content height and compare it to the total window height (viewport). Then add or remove the ui-footer-fixed class on the footer div:
$(document).on("pagebeforeshow", "#page1", function(){
$(window).on("orientationchange resize", function(){
FooterPositionFixed()
});
setTimeout(FooterPositionFixed, 300);
});
function FooterPositionFixed(){
scroll(0, 0);
var totHeight = $(window).height();
var headerHeight = $("#jqmHeader:visible").outerHeight();
var footerHeight = $("#jqmFooter:visible").outerHeight();
var contentHeight = $("#jqmContent:visible").outerHeight();
if (totHeight > (headerHeight + footerHeight + contentHeight)){
if (!$("#jqmFooter").hasClass("ui-footer-fixed")){
$("#jqmFooter").addClass("ui-footer-fixed");
}
} else {
if ($("#jqmFooter").hasClass("ui-footer-fixed")){
$("#jqmFooter").removeClass("ui-footer-fixed");
}
}
}
Here is the HTML for this script:
<div data-role="page" id="page1">
<div data-role="header" id="jqmHeader">
<h1>My page</h1>
</div>
<div data-role="content" id="jqmContent">
<ul data-role="listview">
<li>Page 1</li>
<li>Page 2</li>
<li>Page 3</li>
</ul>
</div>
<div data-role="footer" data-position="fixed" id="jqmFooter">
<h2><a>Go to website</a><br />Copyright<br /> business name</h2>
</div>
</div>

Jquery Mobile Persistent Navbar - Flickers

I have an issue with Jquery mobile persistent navbar. I am developing a mobile app using phonegap to deploy on iOS and Android. I have a navbar to navigate from one page to another. (footer/navbar fixed).
Example on: http://jquerymobile.com/demos/1.2.0/docs/toolbars/footer-persist-a.html
The navigation works, the bar persists when rendered in a browser such as chrome or safari. But when I upload the app to the Android emulator or iOS emulator, clicking a link from the navbar makes the whole screen go white for a sec and then re-appears. (Kind of a flicker)
Can someone help with this?
Here's my code for the footer: (a.html,b.html... are the name of my pages)
<div data-role="footer" data-id="foo1" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar">
<ul>
<li>Info</li>
<li><a href="b.html" data-prefetch rel="external" >Friends</a></li>
<li>Albums</li>
<li>Emails</li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
Thank you !
I figured it out. It's a combination of what you said and what I had.
So to stop the Jquery mobile footer from flickering when you upload to Android or iOS, you need to set the following properties in your div:
page1.html:
<div data-position="fixed" data-tap-toggle="false" data-role="footer" data-id="f1">
Page 1 NAV
Page 2 NAV
</div>
page2.html
<div data-position="fixed" data-tap-toggle="false" data-role="footer" data-id="f1">
Page 1 NAV
Page 2 NAV
</div>
The data-id="f1" has to match in both pages so that jquery mobile knows that this is the same footer that was on the previous page therefore it won't render it again.
Let me know if you need help with this.
Regards,
Tony
Same problem here (I was trying to fix it for over 3 hours with no luck trying lots of stuff I found on the web but no luck).
If you remove the entire footer and add a button in the content area the transition works like a charm all of a sudden. So one workaround would be to fake the navbar via buttons from the content area you place at the bottom of the page... Not very pretty though.
<div data-role="content">
<h1>
Page Nav and Dialog Example
</h1>
<a data-role="button" href="index2.html">Page Navigation</a></div>
I'm using this with a custom-scripting.js:
$(document).bind("mobileinit", function(){
$.mobile.defaultPageTransition = 'none';
$.mobile.defaultDialogTransition = 'none';
$.mobile.useFastClick = true;});
Referencing it via:
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script src="custom-scripting.js"></script>
<script type="text/javascript" src="jquery.mobile-1.2.0.js"></script>
Maybe anyone else found a solution for using navbar without flickering?
Without using the navbar in the footer it stops flickering (tested on iPhone4 iOS5). So you can use the footer but don't use navbar inside it :-)
But attention: If you use data-position="fixed" it will start to flicker again...
<div data-role="footer">
<a data-role="button" href="#">Main</a>
<a data-role="button" href="favorites.html">Favorites</a>
<a data-role="button" href="more.html">More</a>
</div>
Hope it helps :-)

JQuery Mobile Tabs

Does anyone know if JQuery Mobile does Tabs that stick to the bottom like the iphone native apps?
Thanks
Yes, they have tabs that stay fixed to the bottom:
http://jquerymobile.com/demos/1.0a4.1/#docs/toolbars/footer-persist-a.html
They behave slightly differently in that they disappear while scrolling and then reappear after the scrolling is finished.
You can also watch the navbar section for more examples:
http://jquerymobile.com/test/docs/toolbars/docs-navbar.html
Example code:
<div data-role="navbar">
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
</div><!-- /navbar -->

Resources