hammer.js

Hammer.js : How to handle / set tap and doubletap on same elements

和自甴很熟 提交于 2019-12-06 11:20:10
I'm using jquery.hammer.js, it works quite well and I am able to bind function to a doubletap event. That is working fine. What I want is to bind two different behaviors. One for the "tap", one for the "doubletap". I use the code below to bind my functions. When I do that, I only get the "tap", the "doubletap" doesn't seem to be triggered. $("#W0AM").hammer(); $("#W0AM").on('doubletap', function (event) { alert( 'this was a double tap' ); }).on('tap', function (event) { alert( 'this was a single tap' ); }); If I remove the .on('tap'... ) binding, then I get the "doubletap" as expected. $("

Google Maps Using Touch Events That Don't Target It

£可爱£侵袭症+ 提交于 2019-12-06 09:02:20
I am trying to build a web application that has true multi touch capabilities. For example, I want to be able to drag a container around the screen while also zooming/panning on a google map at the same time. The problem that I am having is that if I am touching somewhere else on the page (not on the map) and then I touch on the map with another finger, the map acts as if both fingers were touching the map. This results in trying to pan on the google map with one finger turning into zooming in/out of the map because I am touching somewhere else on the page. I am using Hammer.js for my other

Pinch to zoom with Hammer.js

本秂侑毒 提交于 2019-12-05 05:58:25
问题 I want a pinch to Zoom function for an image. I want it to zoom in the area where the fingers are. My index is only <div id="wrapper" style="-webkit-transform: translate3d(0,0,0);overflow: hidden;"> </div> And my script for zooming and scrolling is similar with this example. I have made a few changes to fit with my project My problem is in case 'transform': rotation = last_rotation + ev.gesture.rotation; scale = Math.max(1, Math.min(last_scale * ev.gesture.scale, 10)); break; How can I change

Prevent only horizontal scrolling mobile app

时光毁灭记忆、已成空白 提交于 2019-12-04 19:05:33
I'm developing an web app. On the left side is an sidebar using the Sidr-plugin ( jQuery Plugin: Sidr ). The test site is on my developing server . My problem is that if I'm swipe from left-to-right the sidebar is displayed. That's very good. But if I want to close the sidebar by swiping from right-to-left I must prevent the scrolling by add this following code: $('body').bind('touchmove', function(e){e.preventDefault()}) I did that, but now: My navigation in the top of the page (menu) doesn't work fine. I can't scroll until to the end. So my question is: How can I change this. It should only

Hammer.js pan event only for touch devices and not for desktop computer Click+Drag

≯℡__Kan透↙ 提交于 2019-12-04 16:51:50
I use this standard code for Pan / Pinch (1) with Hammer.js : var mc = new Hammer(document.body); mc.add(new Hammer.Pinch({ threshold: 0 })).recognizeWith(mc.get('pan')); // let the pan gesture support all directions. this will block the vertical scrolling on a touch-device while on the element mc.get('pan').set({ direction: Hammer.DIRECTION_ALL }); mc.on("panleft panright panup pandown tap press pinchstart pinchmove", function(ev) { $('#myElement').text(ev.type +" gesture detected. ev.scale=" + ev.scale + " ev.deltaX,Y=" + ev.deltaX +' ' + ev.deltaY); }); How to get the hammer.js pan events

Pinch to zoom with Hammer.js

帅比萌擦擦* 提交于 2019-12-03 21:01:28
I want a pinch to Zoom function for an image. I want it to zoom in the area where the fingers are. My index is only <div id="wrapper" style="-webkit-transform: translate3d(0,0,0);overflow: hidden;"> </div> And my script for zooming and scrolling is similar with this example . I have made a few changes to fit with my project My problem is in case 'transform': rotation = last_rotation + ev.gesture.rotation; scale = Math.max(1, Math.min(last_scale * ev.gesture.scale, 10)); break; How can I change it so that it doesn't zoom into the center of the picture but at place where the first finger have

Zooming SVG with Hammer.js

ぃ、小莉子 提交于 2019-12-03 13:54:34
问题 I am writing a cross platform web application that displays information using SVG. I need to have a multi-touch interface to pan and zoom the SVG graphic. From my research, it appears that Hammer.js is my best approach, and I am using the jQuery library version. I am able to pan and zoom the image using the viewBox property of the SVG. The problem I'm having is using the center point information during the pinch zoom (vs. scaling from the top left corner). That center point, wherever it is in

jQuery functions not working with Hammer.js

跟風遠走 提交于 2019-12-02 08:39:51
问题 I am trying to add press to jQuery selector. I have many elements on same document, So I can not use IDs for each. I tried by $(selector)[i] as like explained here . var selectProduct = $('.mh60 a'); for (var i = 0; i < selectProduct.length; i++) { Hammer(selectProduct[i]).on("press", function() { $(selectProduct[i]).addClass('active'); }); } It's not producing any error and not working. I didn't get what I am missing here. And when I try to log selectProduct[i] by console.log(selectProduct[i

jQuery functions not working with Hammer.js

拈花ヽ惹草 提交于 2019-12-02 02:53:36
I am trying to add press to jQuery selector. I have many elements on same document, So I can not use IDs for each. I tried by $(selector)[i] as like explained here . var selectProduct = $('.mh60 a'); for (var i = 0; i < selectProduct.length; i++) { Hammer(selectProduct[i]).on("press", function() { $(selectProduct[i]).addClass('active'); }); } It's not producing any error and not working. I didn't get what I am missing here. And when I try to log selectProduct[i] by console.log(selectProduct[i]); it gives undefined result. UPDATE 1 When I remove for loop and just use selectProduct[0] ,

hammer.js object has no method addEventListener

和自甴很熟 提交于 2019-12-01 15:04:46
I am getting the Error: Uncaught TypeError: Object [object Object] has no method 'addEventListener' hammer.js:168 my code is like this: <script type="text/javascript" src="js/hammer.js"></script> On device ready function: var resim = $('#kaydir'); Hammer(resim).on('swipeleft', function(ev){ console.log('left: ', ev); }); It seems the error is in hammer.js . What should I do? James Donnelly I imagine your issue is that you don't have Hammer.js's jQuery Plugin installed ( GitHub ). Because of this, you cannot pass a jQuery object into the Hammer() function, your two options: With the jQuery