0

I have a lightbox function in a new site that works just fine on my desktop but on an ipad the clicks have a serious lag in interation. I added "fastclick" to the project but doesnt seem to help a lot. Here is what I have if anyone sees something wrong with the code

js

$('a[data-ocular]').click(function(event) {
     event.preventDefault();
     //some more code 
}

$('#galleryPrev').off().on( "click", function() {

     currentImageIndex = (currentImageIndex) - 1;
     updateImage(currentImageIndex); 

 });

fastclick init at before </body> on the page

<script type="text/javascript">
    $(function() {
          FastClick.attach(document.body);
     });
</script?>
Packy
  • 3,405
  • 9
  • 50
  • 87
  • Did you put fastclick in a `script` tag somewhere too? – Josh Beam Jun 08 '15 at 15:31
  • just edited to my question, but yes at the end of the page @JoshBeam – Packy Jun 08 '15 at 15:36
  • no, I mean, did you load the fastclick module into the page before invoking it? For example, you need ``. And then later you call `FastClick.attach()`. – Josh Beam Jun 08 '15 at 15:37
  • Ya, its loaded in the page before I call it. In the docs I didnt see the `fastclick.attach()` , it said to use `$(function() { FastClick.attach(document.body); });` correct? Do I need to add `touchEnd` or `touchStart` on my click event? – Packy Jun 08 '15 at 15:41
  • I just wrote `FastClick.attach()` as shorthand for the method you were calling, but yes, you are correct. Can you post the whole HTML document where you're doing this? I use `FastClick` too, and the way you're invoking it looks correct (yes, you can use the `click` event, you don't need `touch`), so that tells me something else strange is going on. – Josh Beam Jun 08 '15 at 15:43
  • Unfortunatlwy the page is pretty long so cant post the whole thing. Should I init fastClick very last? – Packy Jun 08 '15 at 15:53
  • Yes. Right before the closing `

    ` tag. Try posting the code in a JSFiddle. Can't help if I can't see all the code.

    – Josh Beam Jun 08 '15 at 15:54

0 Answers0