Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 92756

Re: Why doesn't this slider code work with Kindle Fire or Android?

$
0
0

I must have visited hundreds of pages trying to solve this problem but at last I stumbled on the solution.

 

In fact it was something quite simple. The action code is a conditional after testing for the device used: in the line:

 

if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {

 

It struck me that it may be better to test if it supported touch, so I added these lines before the conditional:

 

var isTouchSupported = 'ontouchstart' in window;

var startEvent = isTouchSupported ? 'touchstart' : 'mousedown';

var moveEvent = isTouchSupported ? 'touchmove' : 'mousemove';

var endEvent = isTouchSupported ? 'touchend' : 'mouseup';

 

and then replaced the conditional line with:

if (isTouchSupported) {


It worked like a charm - on my IMac, IPad, Iphone, Xperia Z1 (android) and Kindle Fire.


Peter Small


Viewing all articles
Browse latest Browse all 92756

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>