hammer.js

stopPropagation() with tap event

假如想象 提交于 2019-12-21 04:03:05
问题 I'm using hammer.js and it appears that I event.stopPropagation() doesn't work with tap event. If I click on the child, the associated event is triggered but parent's event is also triggered and I don't want that. $('#parent').hammer().bind('tap', function(e) { $(this).css('background', 'red'); });​​​​​​​​ $('#child').hammer().bind('tap', function(e) { e.stopPropagation(); $(this).css('background', 'blue'); }); Here is an example: http://jsfiddle.net/Mt9gV/ ​ I also tried with jGestures and

hammer.js object has no method addEventListener

流过昼夜 提交于 2019-12-19 12:39:38
问题 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? 回答1: I imagine your issue is that you don't have Hammer.js's jQuery Plugin installed (GitHub). Because of this, you

Removing hammer events

落花浮王杯 提交于 2019-12-19 03:15:51
问题 I create an event using hammer.js library like this: Hammer(myElement).on("doubletap", function(evt){ evt.preventDefault(); }); How can I then remove the registred event? Can I also use Jquery? 回答1: It's simply Hammer(myElement).off(eventName); If you want to use jQuery, then the syntax is: $(myElement).hammer().on(eventName, callback) If you want to specify "namespace" for the event, then you declare eg. $(myElement).hammer().on("tap.namespace", callback); $(myElement).hammer().on("tap

How to use hammer.js with Angular.js

天涯浪子 提交于 2019-12-18 10:55:30
问题 I'm new with Angular.js and reading i know angular dont have events like tap, double tap, etc. I'm trying to combine with Hammer.js without success. Code from gist /** * angular-hammer.js * Inspired by AngularJS' implementation of "click dblclick mousedown..." * * This ties in the Hammer events to attributes like: * * hm-tap="add_something()" * hm-swipe="remove_something()" * * and also has support for Hammer options with: * * hm-tap-opts="{hold: false}" * * or any other of the "hm-event"

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

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-14 00:25:01
问题 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=

Swipe up/down not working on Ionic 2

a 夏天 提交于 2019-12-13 12:32:27
问题 How can I use swipe up or swipe down with Ionic 2? I've tried the Gestures API but it only fires on horizontal swipe. <ion-card (swipe)="swipePage($event)"> </ion-card> 回答1: In the HammerJS official document, bottom line says : When calling Hammer() to create a simple instance, the pan and swipe recognizers are configured to only detect horizontal gestures. For additional config, you must tweak your hammer instance, try this : First run npm install hammerjs --save && npm install @types

Can't seem to pass options to Hammer.js Jquery

拥有回忆 提交于 2019-12-13 05:24:31
问题 What am I doing wrong? Can't seem to pass any options to the JQuery plugin of Hammer.js $('#my-div').hammer({direction: Hammer.DIRECTION_ALL}).bind('pan', function(e){ // do something }); I've tried passing "direction" as string too but still no joy - Please help :-( 回答1: If you're using the jquery.hammer plugin You can access the Hammer.Manager instance on the data object and set options. In your case: $('#my-div').data('hammer').get('pan').set({ direction: Hammer.DIRECTION_ALL }); 回答2: From

Calling the method provided in HTML in Knockout custom bindinghandler

心不动则不痛 提交于 2019-12-13 04:42:23
问题 I'm using both knockout.js and hammer.js in my current project. I created a custom binding handler for the 'tap' event in hammer.js (this should also work for other events such as hold or swipe). My problem is that in this binding handler, I want to call a method that I provide in the data-bind attribute in HTML. According to the knockout documentation, I found out that I should call valueAccessor(), but unfortunately, this doesn't do anything. I've created this Fiddle, which should give you

overriding Backbone.View delegateEvents so the events object can include mobile events

自闭症网瘾萝莉.ら 提交于 2019-12-13 02:42:58
问题 I am using Hammer.js to capture touchscreen events in a Backbone View. Hammer has a special syntax for adding touch listeners, which I have been using in the View's initialize function: $("#next-button").hammer({prevent_default: true}).on('tap', $.proxy(this.next, this)); I would rather add it to the standard events object, like this: events: {"tap #next-button":"next"} So I hacked the end of Backbone.View's delegateEvents method: var isMobileEvent=["tap", "doubleTap"].indexOf(eventName)!=-1;

hammerjs pan event not working in cordova app

佐手、 提交于 2019-12-13 01:48:03
问题 I'm using Hammer.js with the jQuery plugin in a Cordova app. I am also using zepto and zepto touch. The reason for having both (currently) is that I recently used only zepto. But the touch/gestures didn't work on Android. So now I try to move to Hammer.js, event by event. While the Pinch Events are working perfect (while zepto touch is also included as library), I don't get the pan event fired. Maybe there is a zepto swipe event interfering, but I wasn't able to verify this. Here is my code: