Click & Tap: collision (?) between PC browsers and mobile devices

96 views
Skip to first unread message

Giuseppe Briotti

unread,
Apr 1, 2014, 11:35:56 AM4/1/14
to isc...@googlegroups.com
I'm experimenting iScroll 5. It works fine in scrolling and zooming, but I've got problems with click() event.

This page is general purpouse and should be accessed by mobile device AND normal browsers. And it has some clickable elements (basically, the page contains an expandable TOC) with some onClick code.

If in the IScroll option I set click=true, everything works fine in IOS & Android devices, but the click event doesn't work anymore in other browser (say Firefox, Opera, and IE). If I set click=false the browsers work fine but the click is not managed for the mobile device...

I try with tap=true and manage the event fired but I'm not sure how it works...

What I'm missing?

Giuseppe

Dhameer Govind

unread,
Oct 14, 2015, 4:59:45 AM10/14/15
to iScroll
Hi Giuseppe

Have you found a solution for this yet?

Mike McPhail

unread,
Oct 19, 2016, 5:05:07 PM10/19/16
to iScroll
You can attach to the tap event and then trigger the click of the element you need.  Unfortunately iScroll doesnt play nice with standard JavaScript events so you have to monkey rig a lot of things when using this library.  Example:

var iScrollOpts = {
                    freeScroll: true,
                    scrollX: true,
                    scrollY: true,
                    zoom: true,
                    bounce: false,
                    momentum: true,
                    scrollbars: true,
                    tap: true,
                    preventDefaultException: { tagName: /^(INPUT|TEXTAREA|SELECT|A)$/ },
                    click: clickOption
                }; 

                //have to do this inside a scroll area because anchor clicks just dont fire...
                var anchors = $("#content a");
                $.each(anchors, function(key, value) {
                    if (!value.href.includes('javascript')) {
                      $(value).on('tap', function () {
                          window.location.href = value.href;
                      });
                    }                  
                });
Reply all
Reply to author
Forward
0 new messages