From e480acb9d2393bb4281e424cda0b1c066f53bbcc Mon Sep 17 00:00:00 2001 From: James Date: Mon, 15 Jun 2015 14:58:23 +0100 Subject: [PATCH 01/15] Add directive which allows us to define default props for events which will be used in any corresponding angular hm-X invocation (except custom), as well as import defaults from Hammer's own presets object. --- angular.hammer.js | 143 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 137 insertions(+), 6 deletions(-) diff --git a/angular.hammer.js b/angular.hammer.js index 8983531..3a157bc 100644 --- a/angular.hammer.js +++ b/angular.hammer.js @@ -85,7 +85,140 @@ * @requires angular * @requires hammer */ - angular.module('hmTouchEvents', []); + var hmTouchEvents = angular.module('hmTouchEvents', []); + + /** + * Provides a common interface for configuring global manager and recognizer + * options. Allows things like tap duration etc to be defaulted globally and + * overridden on a per-directive basis as needed. + * + * @return {Object} functions to add manager and recognizer options. + */ + hmTouchEvents.provider(NAME, function(){ + + var self = this; + var defaultRecognizerOpts = false; + var recognizerOptsHash = {}; + var managerOpts = {}; + + // + // Make use of presets from Hammer.defaults.preset array + // in angular-hammer events. + // + self.applyHammerPresets = function(){ + //force hammer to extend presets with more info: + Hammer(document.createElement("i")); + var hammerPresets = Hammer.defaults.preset; + + //add each preset to defaults list so long as there + //is associated config with it: + angular.forEach(hammerPresets, function(presetArr){ + + var data = presetArr[1]; + if(!data) return; + var name = data.event; + + //use event name given by hammer to set event type now: + data.type = name; + + if(!name) throw Error(NAME+"Provider: useHammerPresets: preset event expected by now"); + recognizerOptsHash[name] = data; + + }); + } + + // + // Add a manager option (key/val to extend or object to set all): + // + self.addManagerOption = function(name, val){ + if(typeof name == "object"){ + angular.extend(managerOpts, name); + } + else { + managerOpts[name] = val; + } + } + + // + // Add a recognizer option (key/val or object with "type" set): + // + self.addRecognizerOption = function(name, val){ + if(Array.isArray(name)){ + for(var i = 0; i < name.length; i++) self.addRecognizerOption(name[i]); + return; + } + if(typeof name == "object") { + val = name; + name = val.type; + } + if(typeof val != "object") { + throw Error(NAME+"Provider: recognizer value expected to be object"); + } + if(!name){ + defaultRecognizerOpts = val; + } else { + recognizerOptsHash[val.type] = val; + } + } + + // internal helper funcs: + function doRecognizerOptsExist(type, arr){ + for(var i = 0; i < arr.length; i++){ + if(arr[i].type == type) return true; + } + return false; + } + function doDefaultRecognizerOptsExist(arr){ + for(var i = 0; i < arr.length; i++){ + if(!arr[i].type) return true; + } + return false; + } + + //provide an interface to this that the hm-* directives use + //to extend their recognizer/manager opts. + self.$get = function(){ + return { + extendWithDefaultManagerOpts: function(opts){ + if(typeof opts != "object"){ + opts = {}; + } + var out = {}; + for(var name in managerOpts) { + if(!opts[name]) opts[name] = angular.copy(managerOpts[name]); + } + return angular.extend({}, managerOpts, opts); + }, + extendWithDefaultRecognizerOpts: function(eventName, opts){ + + var eventType = getRecognizerTypeFromeventName(eventName); + + //dont apply anything if this is custom event: + if(eventType == "custom") return opts; + + var eventOpts = recognizerOptsHash[eventType]; + var defaults = defaultRecognizerOpts; + + //dont apply anything if nothing set to apply: + if(!eventOpts && !defaults) return opts; + + //no opts, but either defaults or eventOpts to apply to extend: + if(!opts) return angular.extend({type:eventType}, defaults || {}, eventOpts || {}); + + //extend provided opts with settings obtained here: + if(!Array.isArray(opts)) opts = [opts]; + opts = opts.map(function(opt){ + if(!opt.type && defaults) return angular.extend({}, defaults, opt); + if(opt.type == eventType) return angular.extend({}, defaults, eventOpts, opt); + }); + + return opts; + + } + }; + }; + + }); /** * Iterates through each gesture type mapping and creates a directive for @@ -99,8 +232,7 @@ directiveName = directive[0], eventName = directive[1]; - angular.module('hmTouchEvents') - .directive(directiveName, ['$parse', '$window', function ($parse, $window) { + hmTouchEvents.directive(directiveName, ['$parse', '$window', hmTouchEvents, function ($parse, $window, defaultEvents) { return { 'restrict' : 'A', 'link' : function (scope, element, attrs) { @@ -121,8 +253,8 @@ } var hammer = element.data('hammer'), - managerOpts = angular.fromJson(attrs.hmManagerOptions), - recognizerOpts = angular.fromJson(attrs.hmRecognizerOptions); + managerOpts = defaultEvents.extendWithDefaultManagerOpts( scope.$eval(attrs.hmManagerOptions) ), + recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( eventName, scope.$eval(attrs.hmRecognizerOptions) ); // Check for a manager, make one if needed and destroy it when @@ -172,7 +304,6 @@ }; // Setting up the recognizers based on the supplied options - if (angular.isArray(recognizerOpts)) { // The recognizer options may be stored in an array. In this // case, Angular Hammer iterates through the array of options From 0995449f4c53d2243a1d12064e5ef580f1addd7f Mon Sep 17 00:00:00 2001 From: James Date: Mon, 15 Jun 2015 15:01:02 +0100 Subject: [PATCH 02/15] update minified/mapped builds --- angular.hammer.min.js | 2 +- angular.hammer.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/angular.hammer.min.js b/angular.hammer.min.js index 5552b6c..5e2320b 100644 --- a/angular.hammer.min.js +++ b/angular.hammer.min.js @@ -1,5 +1,5 @@ // ---- Angular Hammer ---- // Copyright (c) 2014 Ryan S Mullins // Licensed under the MIT Software License -!function(a,b,c){"use strict";function d(a,b){if(!a||!b||!b.type)return null;var d;return d=b.type.indexOf("pan")>-1?new c.Pan(b):b.type.indexOf("pinch")>-1?new c.Pinch(b):b.type.indexOf("press")>-1?new c.Press(b):b.type.indexOf("rotate")>-1?new c.Rotate(b):b.type.indexOf("swipe")>-1?new c.Swipe(b):new c.Tap(b),a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":"tap"}function g(a,b,c){if(a&&b){var e=a.get(b.type);e||(e=d(a,b)),b.directions||(b.directions="pan"===b.type||"swipe"===b.type?"DIRECTION_ALL":b.type.indexOf("left")>-1?"DIRECTION_LEFT":b.type.indexOf("right")>-1?"DIRECTION_RIGHT":b.type.indexOf("up")>-1?"DIRECTION_UP":b.type.indexOf("down")>-1?"DIRECTION_DOWN":""),b.direction=h(b.directions),e.set(b),b.recognizeWith&&(a.get(b.recognizeWith)||d(a,{type:b.recognizeWith}),e.recognizeWith(a.get(b.recognizeWith))),b.dropRecognizeWith&&a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),b.requireFailure&&(a.get(b.requireFailure)||d(a,{type:b.requireFailure}),e.requireFailure(a.get(b.requireFailure))),b.dropRequireFailure&&a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts&&c&&i(c)}}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;b-1)&&g(m,e(n,a),k)}):b.isObject(o)?("hmCustom"===h?i=o.event:(o.type||(o.type=f(i)),o.event&&delete o.event),("hmCustom"===h||i.indexOf(o.type)>-1)&&g(m,e(n,o),k)):"hmCustom"!==h?(o={type:f(i)},"hmDoubletap"===h&&(o.event=i,o.taps=2,m.get("tap")&&(o.recognizeWith="tap")),o.type.indexOf("pan")>-1&&m.get("swipe")&&(o.recognizeWith="swipe"),o.type.indexOf("pinch")>-1&&m.get("rotate")&&(o.recognizeWith="rotate"),g(m,e(n,o),k)):i=null,i&&m.on(i,r)}}}])})}(window,window.angular,window.Hammer); +!function(a,b,c){"use strict";function d(a,b){if(void 0===a||void 0===b)return null;var d;return d=b.indexOf("pan")>-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":"tap"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b.type);if(e||(e=d(a,b.type)),b.directions||("pan"===b.type||"swipe"===b.type?b.directions="DIRECTION_ALL":b.type.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b.type.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b.type.indexOf("up")>-1?b.directions="DIRECTION_UP":b.type.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;b-1)&&g(n,e(o,a),l)}):b.isObject(p)?("hmCustom"===h?i=p.event:(p.type||(p.type=f(i)),p.event&&delete p.event),("hmCustom"===h||i.indexOf(p.type)>-1)&&g(n,e(o,p),l)):"hmCustom"!==h?(p={type:f(i)},"hmDoubletap"===h&&(p.event=i,p.taps=2,n.get("tap")&&(p.recognizeWith="tap")),p.type.indexOf("pan")>-1&&n.get("swipe")&&(p.recognizeWith="swipe"),p.type.indexOf("pinch")>-1&&n.get("rotate")&&(p.recognizeWith="rotate"),g(n,e(o,p),l)):i=null,i&&n.on(i,s)}}}])})}(window,window.angular,window.Hammer); //# sourceMappingURL=angular.hammer.min.js.map \ No newline at end of file diff --git a/angular.hammer.min.js.map b/angular.hammer.min.js.map index 341d4dc..5736fef 100644 --- a/angular.hammer.min.js.map +++ b/angular.hammer.min.js.map @@ -1 +1 @@ -{"version":3,"file":"angular.hammer.min.js","sources":["angular.hammer.js"],"names":["window","angular","Hammer","addRecognizer","manager","options","type","recognizer","indexOf","Pan","Pinch","Press","Rotate","Swipe","Tap","add","applyManagerOptions","managerOpts","recognizerOpts","preventGhosts","getRecognizerTypeFromeventName","eventName","setupRecognizerWithOptions","element","get","directions","direction","parseDirections","set","recognizeWith","dropRecognizeWith","requireFailure","dropRequireFailure","dirs","forEach","split","hasOwnProperty","preventGhostClick","ev","i","coordinates","length","x","y","Math","abs","clientX","threshold","clientY","stopPropagation","preventDefault","resetCoordinates","popCoordinates","splice","registerCoordinates","touches","changedTouches","touch","push","setTimeout","timeout","addEventListener","require","e","console","log","gestureTypes","module","directive","directiveName","$parse","$window","restrict","link","scope","attrs","bind","handler","hammer","data","fromJson","hmManagerOptions","hmRecognizerOptions","Manager","$on","destroy","handlerName","handlerExpr","event","callHandler","fn","$event","call","phase","$root","$$phase","srcEvent","$apply","isArray","isObject","taps","on"],"mappings":";;;CAKA,SAAWA,EAAQC,EAASC,GAC1B,YAyRA,SAASC,GAAeC,EAASC,GAC/B,IAAKD,IAAYC,IAAYA,EAAQC,KAAQ,MAAO,KAEpD,IAAIC,EAiBJ,OAdEA,GADEF,EAAQC,KAAKE,QAAQ,OAAS,GACnB,GAAIN,GAAOO,IAAIJ,GACnBA,EAAQC,KAAKE,QAAQ,SAAW,GAC5B,GAAIN,GAAOQ,MAAML,GACrBA,EAAQC,KAAKE,QAAQ,SAAW,GAC5B,GAAIN,GAAOS,MAAMN,GACrBA,EAAQC,KAAKE,QAAQ,UAAY,GAC7B,GAAIN,GAAOU,OAAOP,GACtBA,EAAQC,KAAKE,QAAQ,SAAW,GAC5B,GAAIN,GAAOW,MAAMR,GAEjB,GAAIH,GAAOY,IAAIT,GAG9BD,EAAQW,IAAIR,GACLA,EAUT,QAASS,GAAqBC,EAAaC,GAKzC,MAJID,KACFC,EAAeC,cAAgBF,EAAYE,eAGt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["angular.hammer.js"],"names":["window","angular","Hammer","addRecognizer","manager","type","undefined","recognizer","indexOf","Pan","Pinch","Press","Rotate","Swipe","Tap","add","applyManagerOptions","managerOpts","recognizerOpts","preventGhosts","getRecognizerTypeFromeventName","eventName","setupRecognizerWithOptions","options","element","console","error","get","directions","direction","parseDirections","set","recognizeWith","recognizeWithRecognizer","dropRecognizeWith","requireFailure","requireFailureRecognizer","dropRequireFailure","dirs","forEach","split","hasOwnProperty","preventGhostClick","ev","i","coordinates","length","x","y","Math","abs","clientX","threshold","clientY","stopPropagation","preventDefault","resetCoordinates","popCoordinates","splice","registerCoordinates","touches","changedTouches","touch","push","setTimeout","timeout","addEventListener","require","e","log","gestureTypes","hmTouchEvents","module","provider","NAME","self","this","defaultRecognizerOpts","recognizerOptsHash","applyHammerPresets","document","createElement","hammerPresets","defaults","preset","presetArr","data","name","event","Error","addManagerOption","val","extend","addRecognizerOption","Array","isArray","$get","extendWithDefaultManagerOpts","opts","copy","extendWithDefaultRecognizerOpts","eventType","eventOpts","map","opt","directive","directiveName","$parse","$window","defaultEvents","restrict","link","scope","attrs","bind","handler","hammer","$eval","hmManagerOptions","hmRecognizerOptions","Manager","$on","destroy","handlerName","handlerExpr","callHandler","fn","$event","call","phase","$root","$$phase","srcEvent","$apply","isObject","taps","on"],"mappings":";;;CAKA,SAAWA,EAAQC,EAASC,GAC1B,YA4ZA,SAASC,GAAeC,EAASC,GAC/B,GAAgBC,SAAZF,GAAkCE,SAATD,EAAsB,MAAO,KAE1D,IAAIE,EAiBJ,OAdEA,GADEF,EAAKG,QAAQ,OAAS,GACX,GAAIN,GAAOO,IACfJ,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOQ,MACfL,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOS,MACfN,EAAKG,QAAQ,UAAY,GACrB,GAAIN,GAAOU,OACfP,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOW,MAEX,GAAIX,GAAOY,IAG1BV,EAAQW,IA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AEpBtE,EAAeb,OAClBa,EAAeb,KAAOe,EAA+BC,IAGnDH,EAAesE,aACVtE,GAAesE,QAIN,aAAlBkB,GACArF,EAAUb,QAAQU,EAAeb,MAAQ,KAC3CiB,EACE8F,EACApG,EAAoBC,EAAaC,GACjCM,IAEuB,aAAlBkF,GAMTxF,GACEb,KAAQe,EAA+BC,IAGnB,gBAAlBqF,IACFxF,EAAesE,MAAQnE,EACvBH,EAAeqH,KAAO,EAElBnB,EAAOzF,IAAI,SACbT,EAAec,cAAgB,QAI/Bd,EAAeb,KAAKG,QAAQ,OAAS,IACrC4G,EAAOzF,IAAI,WACbT,EAAec,cAAgB,SAG7Bd,EAAeb,KAAKG,QAAQ,SAAW,IACvC4G,EAAOzF,IAAI,YACbT,EAAec,cAAgB,UAGjCV,EACE8F,EACApG,EAAoBC,EAAaC,GACjCM,IAEFH,EAAY,KAGVA,GACF+F,EAAOoB,GAAGnH,EAAW8F,WA4PhCnH,OAAQA,OAAOC,QAASD,OAAOE"} \ No newline at end of file From 42d6b7fbb723a02eec5da49cd8a7f6761ebc9a2d Mon Sep 17 00:00:00 2001 From: James Date: Mon, 15 Jun 2015 15:01:12 +0100 Subject: [PATCH 03/15] update docs --- doc/angular.hammer.js.html | 218 ++++++++++++++++++++++++++++------ doc/index.html | 2 +- doc/module-hmTouchEvents.html | 2 +- 3 files changed, 183 insertions(+), 39 deletions(-) diff --git a/doc/angular.hammer.js.html b/doc/angular.hammer.js.html index 2bccc1b..238951e 100644 --- a/doc/angular.hammer.js.html +++ b/doc/angular.hammer.js.html @@ -112,7 +112,140 @@

Source: angular.hammer.js

* @requires angular * @requires hammer */ - angular.module('hmTouchEvents', []); + var hmTouchEvents = angular.module('hmTouchEvents', []); + + /** + * Provides a common interface for configuring global manager and recognizer + * options. Allows things like tap duration etc to be defaulted globally and + * overridden on a per-directive basis as needed. + * + * @return {Object} functions to add manager and recognizer options. + */ + hmTouchEvents.provider(NAME, function(){ + + var self = this; + var defaultRecognizerOpts = false; + var recognizerOptsHash = {}; + var managerOpts = {}; + + // + // Make use of presets from Hammer.defaults.preset array + // in angular-hammer events. + // + self.applyHammerPresets = function(){ + //force hammer to extend presets with more info: + Hammer(document.createElement("i")); + var hammerPresets = Hammer.defaults.preset; + + //add each preset to defaults list so long as there + //is associated config with it: + angular.forEach(hammerPresets, function(presetArr){ + + var data = presetArr[1]; + if(!data) return; + var name = data.event; + + //use event name given by hammer to set event type now: + data.type = name; + + if(!name) throw Error(NAME+"Provider: useHammerPresets: preset event expected by now"); + recognizerOptsHash[name] = data; + + }); + } + + // + // Add a manager option (key/val to extend or object to set all): + // + self.addManagerOption = function(name, val){ + if(typeof name == "object"){ + angular.extend(managerOpts, name); + } + else { + managerOpts[name] = val; + } + } + + // + // Add a recognizer option (key/val or object with "type" set): + // + self.addRecognizerOption = function(name, val){ + if(Array.isArray(name)){ + for(var i = 0; i < name.length; i++) self.addRecognizerOption(name[i]); + return; + } + if(typeof name == "object") { + val = name; + name = val.type; + } + if(typeof val != "object") { + throw Error(NAME+"Provider: recognizer value expected to be object"); + } + if(!name){ + defaultRecognizerOpts = val; + } else { + recognizerOptsHash[val.type] = val; + } + } + + // internal helper funcs: + function doRecognizerOptsExist(type, arr){ + for(var i = 0; i < arr.length; i++){ + if(arr[i].type == type) return true; + } + return false; + } + function doDefaultRecognizerOptsExist(arr){ + for(var i = 0; i < arr.length; i++){ + if(!arr[i].type) return true; + } + return false; + } + + //provide an interface to this that the hm-* directives use + //to extend their recognizer/manager opts. + self.$get = function(){ + return { + extendWithDefaultManagerOpts: function(opts){ + if(typeof opts != "object"){ + opts = {}; + } + var out = {}; + for(var name in managerOpts) { + if(!opts[name]) opts[name] = angular.copy(managerOpts[name]); + } + return angular.extend({}, managerOpts, opts); + }, + extendWithDefaultRecognizerOpts: function(eventName, opts){ + + var eventType = getRecognizerTypeFromeventName(eventName); + + //dont apply anything if this is custom event: + if(eventType == "custom") return opts; + + var eventOpts = recognizerOptsHash[eventType]; + var defaults = defaultRecognizerOpts; + + //dont apply anything if nothing set to apply: + if(!eventOpts && !defaults) return opts; + + //no opts, but either defaults or eventOpts to apply to extend: + if(!opts) return angular.extend({type:eventType}, defaults || {}, eventOpts || {}); + + //extend provided opts with settings obtained here: + if(!Array.isArray(opts)) opts = [opts]; + opts = opts.map(function(opt){ + if(!opt.type && defaults) return angular.extend({}, defaults, opt); + if(opt.type == eventType) return angular.extend({}, defaults, eventOpts, opt); + }); + + return opts; + + } + }; + }; + + }); /** * Iterates through each gesture type mapping and creates a directive for @@ -126,8 +259,7 @@

Source: angular.hammer.js

directiveName = directive[0], eventName = directive[1]; - angular.module('hmTouchEvents') - .directive(directiveName, ['$parse', '$window', function ($parse, $window) { + hmTouchEvents.directive(directiveName, ['$parse', '$window', hmTouchEvents, function ($parse, $window, defaultEvents) { return { 'restrict' : 'A', 'link' : function (scope, element, attrs) { @@ -148,8 +280,8 @@

Source: angular.hammer.js

} var hammer = element.data('hammer'), - managerOpts = angular.fromJson(attrs.hmManagerOptions), - recognizerOpts = angular.fromJson(attrs.hmRecognizerOptions); + managerOpts = defaultEvents.extendWithDefaultManagerOpts( scope.$eval(attrs.hmManagerOptions) ), + recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( eventName, scope.$eval(attrs.hmRecognizerOptions) ); // Check for a manager, make one if needed and destroy it when @@ -192,14 +324,13 @@

Source: angular.hammer.js

function callHandler () { var fn = handlerExpr(scope, {'$event':event}); - if (fn) { + if (typeof fn === 'function') { fn.call(scope, event); } } }; // Setting up the recognizers based on the supplied options - if (angular.isArray(recognizerOpts)) { // The recognizer options may be stored in an array. In this // case, Angular Hammer iterates through the array of options @@ -308,27 +439,27 @@

Source: angular.hammer.js

* add is determined by the value of the options.type property. * * @param {Object} manager Hammer.js manager object assigned to an element - * @param {Object} options Options that define the recognizer to add - * @return {Object} Reference to the new gesture recognizer, if successful, - * null otherwise. + * @param {String} type Options that define the recognizer to add + * @return {Object} Reference to the new gesture recognizer, if + * successful, null otherwise. */ - function addRecognizer (manager, options) { - if (!manager || !options || !options.type) { return null; } + function addRecognizer (manager, type) { + if (manager === undefined || type === undefined) { return null; } var recognizer; - if (options.type.indexOf('pan') > -1) { - recognizer = new Hammer.Pan(options); - } else if (options.type.indexOf('pinch') > -1) { - recognizer = new Hammer.Pinch(options); - } else if (options.type.indexOf('press') > -1) { - recognizer = new Hammer.Press(options); - } else if (options.type.indexOf('rotate') > -1) { - recognizer = new Hammer.Rotate(options); - } else if (options.type.indexOf('swipe') > -1) { - recognizer = new Hammer.Swipe(options); + if (type.indexOf('pan') > -1) { + recognizer = new Hammer.Pan(); + } else if (type.indexOf('pinch') > -1) { + recognizer = new Hammer.Pinch(); + } else if (type.indexOf('press') > -1) { + recognizer = new Hammer.Press(); + } else if (type.indexOf('rotate') > -1) { + recognizer = new Hammer.Rotate(); + } else if (type.indexOf('swipe') > -1) { + recognizer = new Hammer.Swipe(); } else { - recognizer = new Hammer.Tap(options); + recognizer = new Hammer.Tap(); } manager.add(recognizer); @@ -383,12 +514,15 @@

Source: angular.hammer.js

* @return None */ function setupRecognizerWithOptions (manager, options, element) { - if (!manager || !options) { return; } + if (manager == null || options == null || options.type == null) { + return console.error('ERROR: Angular Hammer could not setup the' + + ' recognizer. Values of the passed manager and options: ', manager, options); + } var recognizer = manager.get(options.type); if (!recognizer) { - recognizer = addRecognizer(manager, options); + recognizer = addRecognizer(manager, options.type); } if (!options.directions) { @@ -410,31 +544,41 @@

Source: angular.hammer.js

options.direction = parseDirections(options.directions); recognizer.set(options); - if (options.recognizeWith) { - if (!manager.get(options.recognizeWith)){ - addRecognizer(manager, {type:options.recognizeWith}); + if (typeof options.recognizeWith === 'string') { + var recognizeWithRecognizer; + + if (manager.get(options.recognizeWith) == null){ + recognizeWithRecognizer = addRecognizer(manager, options.recognizeWith); } - recognizer.recognizeWith(manager.get(options.recognizeWith)); + if (recognizeWithRecognizer != null) { + recognizer.recognizeWith(recognizeWithRecognizer); + } } - if (options.dropRecognizeWith && manager.get(options.dropRecognizeWith)) { + if (typeof options.dropRecognizeWith === 'string' && + manager.get(options.dropRecognizeWith) != null) { recognizer.dropRecognizeWith(manager.get(options.dropRecognizeWith)); } - if (options.requireFailure) { - if (!manager.get(options.requireFailure)){ - addRecognizer(manager, {type:options.requireFailure}); + if (typeof options.requireFailure === 'string') { + var requireFailureRecognizer; + + if (manager.get(options.requireFailure) == null){ + requireFailureRecognizer = addRecognizer(manager, {type:options.requireFailure}); } - recognizer.requireFailure(manager.get(options.requireFailure)); + if (requireFailureRecognizer != null) { + recognizer.requireFailure(requireFailureRecognizer); + } } - if (options.dropRequireFailure && manager.get(options.dropRequireFailure)) { + if (typeof options.dropRequireFailure === 'string' && + manager.get(options.dropRequireFailure) != null) { recognizer.dropRequireFailure(manager.get(options.dropRequireFailure)); } - if (options.preventGhosts && element) { + if (options.preventGhosts === true && element != null) { preventGhosts(element); } } @@ -550,7 +694,7 @@

Index

Modules

  • diff --git a/doc/index.html b/doc/index.html index e38f450..f45df56 100644 --- a/doc/index.html +++ b/doc/index.html @@ -54,7 +54,7 @@

    Index

    Modules

    • diff --git a/doc/module-hmTouchEvents.html b/doc/module-hmTouchEvents.html index c66fc0b..9b29e3c 100644 --- a/doc/module-hmTouchEvents.html +++ b/doc/module-hmTouchEvents.html @@ -122,7 +122,7 @@

      Index

      Modules

      • From 4562fc4e261a339abc8f6bc7e8d9010f3343289b Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Jun 2015 11:37:50 +0100 Subject: [PATCH 04/15] various changes to angular hammer including 1. normalize recognizer opts to array to avoid code duplication, 2. apply directive defaults properly if not hmCUstom, 3. rewrite how extending works to handle extending/applying defaults. --- angular.hammer.js | 215 ++++++++++++++++++++-------------------------- 1 file changed, 95 insertions(+), 120 deletions(-) diff --git a/angular.hammer.js b/angular.hammer.js index 3a157bc..a6bfb20 100644 --- a/angular.hammer.js +++ b/angular.hammer.js @@ -85,6 +85,7 @@ * @requires angular * @requires hammer */ + var NAME = 'hmTouchEvents'; var hmTouchEvents = angular.module('hmTouchEvents', []); /** @@ -101,29 +102,32 @@ var recognizerOptsHash = {}; var managerOpts = {}; + // + // In order to use the Hamme rpresets provided, we need + // to map the recognizer fn to some name: + // + var recognizerFnToName = {}; + recognizerFnToName[ Hammer.Tap.toString() ] = "tap"; + recognizerFnToName[ Hammer.Pan.toString() ] = "pan"; + recognizerFnToName[ Hammer.Pinch.toString() ] = "pinch"; + recognizerFnToName[ Hammer.Press.toString() ] = "press"; + recognizerFnToName[ Hammer.Rotate.toString() ] = "rotate"; + recognizerFnToName[ Hammer.Swipe.toString() ] = "swipe"; + // // Make use of presets from Hammer.defaults.preset array // in angular-hammer events. // self.applyHammerPresets = function(){ - //force hammer to extend presets with more info: - Hammer(document.createElement("i")); var hammerPresets = Hammer.defaults.preset; //add each preset to defaults list so long as there //is associated config with it: angular.forEach(hammerPresets, function(presetArr){ - + var name = recognizerFnToName[presetArr[0]]; var data = presetArr[1]; - if(!data) return; - var name = data.event; - - //use event name given by hammer to set event type now: - data.type = name; - - if(!name) throw Error(NAME+"Provider: useHammerPresets: preset event expected by now"); - recognizerOptsHash[name] = data; - + if(!data || !name) return; + recognizerOptsHash[name] = angular.copy(data); }); } @@ -193,26 +197,40 @@ var eventType = getRecognizerTypeFromeventName(eventName); - //dont apply anything if this is custom event: + if(typeof opts == "undefined"){ + opts = []; + } else if(!Array.isArray(opts)){ + opts = [opts]; + } + + //dont apply anything if this is custom event + //(beyond normalizing opts to an array): if(eventType == "custom") return opts; var eventOpts = recognizerOptsHash[eventType]; - var defaults = defaultRecognizerOpts; - //dont apply anything if nothing set to apply: - if(!eventOpts && !defaults) return opts; + //find any defaults provided and extend them + //together with global defaults: + var defaults = angular.extend({}, defaultRecognizerOpts || {}, opts.reduce(function(o, opt){ + if(opt.type) return o; + return angular.extend(o, opt); + }, {})); + + //no opts, but either defaults or eventOpts, so we + //create an opt to get those options in and return: + if(!opts.length) return [angular.extend({type:eventType}, defaults, eventOpts || {})]; - //no opts, but either defaults or eventOpts to apply to extend: - if(!opts) return angular.extend({type:eventType}, defaults || {}, eventOpts || {}); + //one or more opts; extend the opt matching this eventName + //with the defaults and event-specific opts set up here. + //remove "default" opts entirely as we merge them in with + //the relevant type here anyway. + return opts.map(function(opt){ - //extend provided opts with settings obtained here: - if(!Array.isArray(opts)) opts = [opts]; - opts = opts.map(function(opt){ - if(!opt.type && defaults) return angular.extend({}, defaults, opt); - if(opt.type == eventType) return angular.extend({}, defaults, eventOpts, opt); - }); + if(!opt.type) return false; + if(opt.type == eventType) return angular.extend({}, defaults, eventOpts || {}, opt); + else return opt; - return opts; + }).filter(angular.identity); } }; @@ -232,34 +250,23 @@ directiveName = directive[0], eventName = directive[1]; - hmTouchEvents.directive(directiveName, ['$parse', '$window', hmTouchEvents, function ($parse, $window, defaultEvents) { + hmTouchEvents.directive(directiveName, ['$parse', '$window', NAME, function ($parse, $window, defaultEvents) { return { 'restrict' : 'A', 'link' : function (scope, element, attrs) { - // Check for Hammer and required functionality - // If no Hammer, maybe bind tap and doubletap to click and dblclick - + // Check for Hammer and required functionality. + // error if they arent found as unexpected behaviour otherwise if (!Hammer || !$window.addEventListener) { - if (directiveName === 'hmTap') { - element.bind('click', handler); - } - - if (directiveName === 'hmDoubletap') { - element.bind('dblclick', handler); - } - - return; + throw Error(NAME+": window.Hammer or window.addEventListener not found, can't add event "+directiveName); } var hammer = element.data('hammer'), managerOpts = defaultEvents.extendWithDefaultManagerOpts( scope.$eval(attrs.hmManagerOptions) ), recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( eventName, scope.$eval(attrs.hmRecognizerOptions) ); - // Check for a manager, make one if needed and destroy it when // the scope is destroyed - if (!hammer) { hammer = new Hammer.Manager(element[0], managerOpts); element.data('hammer', hammer); @@ -269,7 +276,6 @@ } // Instantiate the handler - var handlerName = attrs[directiveName], handlerExpr = $parse(handlerName), handler = function (event) { @@ -303,103 +309,72 @@ } }; - // Setting up the recognizers based on the supplied options - if (angular.isArray(recognizerOpts)) { - // The recognizer options may be stored in an array. In this - // case, Angular Hammer iterates through the array of options - // trying to find an occurrence of the options.type in the event - // name. If it find the type in the event name, it applies those - // options to the recognizer for events with that name. If it - // does not find the type in the event name it moves on. - - angular.forEach(recognizerOpts, function (options) { - if (directiveName === 'hmCustom') { - eventName = options.event; - } else { - if (!options.type) { - options.type = getRecognizerTypeFromeventName(eventName); - } - if (options.event) { - delete options.event; - } - } + // The recognizer options are normalized to an array. Angular + // Hammer iterates through the array of options + // trying to find an occurrence of the options.type in the event + // name. If it find the type in the event name, it applies those + // options to the recognizer for events with that name. If it + // does not find the type in the event name it moves on. - if (directiveName === 'hmCustom' || - eventName.indexOf(options.type) > -1) { - setupRecognizerWithOptions( - hammer, - applyManagerOptions(managerOpts, options), - element); - } - }); - } else if (angular.isObject(recognizerOpts)) { - // Recognizer options may be stored as an object. In this case, - // Angular Hammer checks to make sure that the options type - // property is found in the event name. If the options are - // designated for this general type of event, Angular Hammer - // applies the options directly to the manager instance for - // this element. + angular.forEach(recognizerOpts, function (options) { if (directiveName === 'hmCustom') { - eventName = recognizerOpts.event; + eventName = options.event; } else { - if (!recognizerOpts.type) { - recognizerOpts.type = getRecognizerTypeFromeventName(eventName); - } - if (recognizerOpts.event) { - delete recognizerOpts.event; - } - } + //ignore these options if not custom and not + //matching the event type we are working with: + if(eventName.indexOf(options.type || "") == -1){ + return; + } - if (directiveName === 'hmCustom' || - eventName.indexOf(recognizerOpts.type) > -1) { - setupRecognizerWithOptions( - hammer, - applyManagerOptions(managerOpts, recognizerOpts), - element); - } - } else if (directiveName !== 'hmCustom') { - // If no options are supplied, or the supplied options do not - // match any of the above conditions, Angular Hammer sets up - // the default options that a manager instantiated using - // Hammer() would have. - - recognizerOpts = { - 'type': getRecognizerTypeFromeventName(eventName) - }; - - if (directiveName === 'hmDoubletap') { - recognizerOpts.event = eventName; - recognizerOpts.taps = 2; - - if (hammer.get('tap')) { - recognizerOpts.recognizeWith = 'tap'; + if (options.event) { + delete options.event; } } - if (recognizerOpts.type.indexOf('pan') > -1 && - hammer.get('swipe')) { - recognizerOpts.recognizeWith = 'swipe'; - } + //not a custom directive, so apply the defaults + //depending on the directive we're using. + //(to make things like double tap work) + if(directiveName !== 'hmCustom'){ + + if (directiveName === 'hmDoubletap') { + options.event = eventName; + options.taps = 2; + + if (hammer.get('tap')) { + options.recognizeWith = 'tap'; + } + } + + if (options.type.indexOf('pan') > -1 && + hammer.get('swipe')) { + options.recognizeWith = 'swipe'; + } + + if (options.type.indexOf('pinch') > -1 && + hammer.get('rotate')) { + options.recognizeWith = 'rotate'; + } - if (recognizerOpts.type.indexOf('pinch') > -1 && - hammer.get('rotate')) { - recognizerOpts.recognizeWith = 'rotate'; } + //apply the recognizer options: setupRecognizerWithOptions( hammer, - applyManagerOptions(managerOpts, recognizerOpts), - element); - } else { - eventName = null; - } + applyManagerOptions(managerOpts, options), + element + ); - if (eventName) { + }); + + //apply the event so long as there were actually some + //recognizers applied for it + if (recognizerOpts.length) { hammer.on(eventName, handler); } + } }; }]); From cb5ebea3f9ab85a85e94859c684102b3a1369fc1 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Jun 2015 11:38:27 +0100 Subject: [PATCH 05/15] build from latest tweaks --- angular.hammer.min.js | 2 +- angular.hammer.min.js.map | 2 +- doc/angular.hammer.js.html | 217 +++++++++++++++------------------- doc/index.html | 2 +- doc/module-hmTouchEvents.html | 2 +- 5 files changed, 100 insertions(+), 125 deletions(-) diff --git a/angular.hammer.min.js b/angular.hammer.min.js index 5e2320b..bb85df2 100644 --- a/angular.hammer.min.js +++ b/angular.hammer.min.js @@ -1,5 +1,5 @@ // ---- Angular Hammer ---- // Copyright (c) 2014 Ryan S Mullins // Licensed under the MIT Software License -!function(a,b,c){"use strict";function d(a,b){if(void 0===a||void 0===b)return null;var d;return d=b.indexOf("pan")>-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":"tap"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b.type);if(e||(e=d(a,b.type)),b.directions||("pan"===b.type||"swipe"===b.type?b.directions="DIRECTION_ALL":b.type.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b.type.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b.type.indexOf("up")>-1?b.directions="DIRECTION_UP":b.type.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;b-1)&&g(n,e(o,a),l)}):b.isObject(p)?("hmCustom"===h?i=p.event:(p.type||(p.type=f(i)),p.event&&delete p.event),("hmCustom"===h||i.indexOf(p.type)>-1)&&g(n,e(o,p),l)):"hmCustom"!==h?(p={type:f(i)},"hmDoubletap"===h&&(p.event=i,p.taps=2,n.get("tap")&&(p.recognizeWith="tap")),p.type.indexOf("pan")>-1&&n.get("swipe")&&(p.recognizeWith="swipe"),p.type.indexOf("pinch")>-1&&n.get("rotate")&&(p.recognizeWith="rotate"),g(n,e(o,p),l)):i=null,i&&n.on(i,s)}}}])})}(window,window.angular,window.Hammer); +!function(a,b,c){"use strict";function d(a,b){if(void 0===a||void 0===b)return null;var d;return d=b.indexOf("pan")>-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":"tap"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b.type);if(e||(e=d(a,b.type)),b.directions||("pan"===b.type||"swipe"===b.type?b.directions="DIRECTION_ALL":b.type.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b.type.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b.type.indexOf("up")>-1?b.directions="DIRECTION_UP":b.type.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;b-1&&n.get("swipe")&&(a.recognizeWith="swipe"),a.type.indexOf("pinch")>-1&&n.get("rotate")&&(a.recognizeWith="rotate")),g(n,e(o,a),k)}),p.length&&n.on(h,s)}}}])})}(window,window.angular,window.Hammer); //# sourceMappingURL=angular.hammer.min.js.map \ No newline at end of file diff --git a/angular.hammer.min.js.map b/angular.hammer.min.js.map index 5736fef..954df94 100644 --- a/angular.hammer.min.js.map +++ b/angular.hammer.min.js.map @@ -1 +1 @@ -{"version":3,"file":"angular.hammer.min.js","sources":["angular.hammer.js"],"names":["window","angular","Hammer","addRecognizer","manager","type","undefined","recognizer","indexOf","Pan","Pinch","Press","Rotate","Swipe","Tap","add","applyManagerOptions","managerOpts","recognizerOpts","preventGhosts","getRecognizerTypeFromeventName","eventName","setupRecognizerWithOptions","options","element","console","error","get","directions","direction","parseDirections","set","recognizeWith","recognizeWithRecognizer","dropRecognizeWith","requireFailure","requireFailureRecognizer","dropRequireFailure","dirs","forEach","split","hasOwnProperty","preventGhostClick","ev","i","coordinates","length","x","y","Math","abs","clientX","threshold","clientY","stopPropagation","preventDefault","resetCoordinates","popCoordinates","splice","registerCoordinates","touches","changedTouches","touch","push","setTimeout","timeout","addEventListener","require","e","log","gestureTypes","hmTouchEvents","module","provider","NAME","self","this","defaultRecognizerOpts","recognizerOptsHash","applyHammerPresets","document","createElement","hammerPresets","defaults","preset","presetArr","data","name","event","Error","addManagerOption","val","extend","addRecognizerOption","Array","isArray","$get","extendWithDefaultManagerOpts","opts","copy","extendWithDefaultRecognizerOpts","eventType","eventOpts","map","opt","directive","directiveName","$parse","$window","defaultEvents","restrict","link","scope","attrs","bind","handler","hammer","$eval","hmManagerOptions","hmRecognizerOptions","Manager","$on","destroy","handlerName","handlerExpr","callHandler","fn","$event","call","phase","$root","$$phase","srcEvent","$apply","isObject","taps","on"],"mappings":";;;CAKA,SAAWA,EAAQC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2E,GAAgC,YAAVA,EACxBJ,IAEAb,EAAMqB,OAAOR,GAajB5H,GAAQ8F,QAAQ7E,GAQlBjB,EAAQsC,QAAQrB,EAAgB,SAAUK,GAClB,aAAlBmF,EACFrF,EAAYE,EAAQiE,OAEfjE,EAAQlB,OACXkB,EAAQlB,KAAOe,EAA+BC,IAG5CE,EAAQiE,aACHjE,GAAQiE,QAIG,aAAlBkB,GACArF,EAAUb,QAAQe,EAAQlB,MAAQ,KACpCiB,EACE8F,EACApG,EAAoBC,EAAaM,GACjCC,KAGGvB,EAAQqI,SAASpH,IAQJ,aAAlBwF,EACFrF,EAAYH,EAAesE,OAEpBtE,EAAeb,OAClBa,EAAeb,KAAOe,EAA+BC,IAGnDH,EAAesE,aACVtE,GAAesE,QAIN,aAAlBkB,GACArF,EAAUb,QAAQU,EAAeb,MAAQ,KAC3CiB,EACE8F,EACApG,EAAoBC,EAAaC,GACjCM,IAEuB,aAAlBkF,GAMTxF,GACEb,KAAQe,EAA+BC,IAGnB,gBAAlBqF,IACFxF,EAAesE,MAAQnE,EACvBH,EAAeqH,KAAO,EAElBnB,EAAOzF,IAAI,SACbT,EAAec,cAAgB,QAI/Bd,EAAeb,KAAKG,QAAQ,OAAS,IACrC4G,EAAOzF,IAAI,WACbT,EAAec,cAAgB,SAG7Bd,EAAeb,KAAKG,QAAQ,SAAW,IACvC4G,EAAOzF,IAAI,YACbT,EAAec,cAAgB,UAGjCV,EACE8F,EACApG,EAAoBC,EAAaC,GACjCM,IAEFH,EAAY,KAGVA,GACF+F,EAAOoB,GAAGnH,EAAW8F,WA4PhCnH,OAAQA,OAAOC,QAASD,OAAOE"} \ No newline at end of file +{"version":3,"file":"angular.hammer.min.js","sources":["angular.hammer.js"],"names":["window","angular","Hammer","addRecognizer","manager","type","undefined","recognizer","indexOf","Pan","Pinch","Press","Rotate","Swipe","Tap","add","applyManagerOptions","managerOpts","recognizerOpts","preventGhosts","getRecognizerTypeFromeventName","eventName","setupRecognizerWithOptions","options","element","console","error","get","directions","direction","parseDirections","set","recognizeWith","recognizeWithRecognizer","dropRecognizeWith","requireFailure","requireFailureRecognizer","dropRequireFailure","dirs","forEach","split","hasOwnProperty","preventGhostClick","ev","i","coordinates","length","x","y","Math","abs","clientX","threshold","clientY","stopPropagation","preventDefault","resetCoordinates","popCoordinates","splice","registerCoordinates","touches","changedTouches","touch","push","setTimeout","timeout","addEventListener","require","e","log","gestureTypes","NAME","hmTouchEvents","module","provider","self","this","defaultRecognizerOpts","recognizerOptsHash","recognizerFnToName","toString","applyHammerPresets","hammerPresets","defaults","preset","presetArr","name","data","copy","addManagerOption","val","extend","addRecognizerOption","Array","isArray","Error","$get","extendWithDefaultManagerOpts","opts","extendWithDefaultRecognizerOpts","eventType","eventOpts","reduce","o","opt","map","filter","identity","directive","directiveName","$parse","$window","defaultEvents","restrict","link","scope","attrs","hammer","$eval","hmManagerOptions","hmRecognizerOptions","Manager","$on","destroy","handlerName","handlerExpr","handler","event","callHandler","fn","$event","call","phase","$root","$$phase","srcEvent","$apply","taps","on"],"mappings":";;;CAKA,SAAWA,EAAQC,EAASC,GAC1B,YAmYA,SAASC,GAAeC,EAASC,GAC/B,GAAgBC,SAAZF,GAAkCE,SAATD,EAAsB,MAAO,KAE1D,IAAIE,EAiBJ,OAdEA,GADEF,EAAKG,QAAQ,OAAS,GACX,GAAIN,GAAOO,IACfJ,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOQ,MACfL,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOS,MACfN,EAAKG,QAAQ,UAAY,GACrB,GAAIN,GAAOU,OACfP,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOW,MAEX,GAAIX,GAAOY,IAG1BV,EAAQW,IAAIR,GACLA,EAUT,QAASS,GAAqBC,EAAaC,GAKzC,MAJID,KACFC,EAAeC,cAAgBF,EAAYE,eAGtCD,EAUT,QAASE,GAAgCC,GACvC,MAAIA,GAAUb,QAAQ,OAAS,GACtB,MACEa,EAAUb,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AgB,QAIxBT,EAAQlB,KAAKG,QAAQ,OAAS,IAC9B6G,EAAO1F,IAAI,WACbJ,EAAQS,cAAgB,SAGtBT,EAAQlB,KAAKG,QAAQ,SAAW,IAChC6G,EAAO1F,IAAI,YACbJ,EAAQS,cAAgB,WAM5BV,EACE+F,EACArG,EAAoBC,EAAaM,GACjCC,KAOAN,EAAe4B,QACjBuE,EAAOqB,GAAGrH,EAAWyG,WA6PhC9H,OAAQA,OAAOC,QAASD,OAAOE"} \ No newline at end of file diff --git a/doc/angular.hammer.js.html b/doc/angular.hammer.js.html index 238951e..bb3dcba 100644 --- a/doc/angular.hammer.js.html +++ b/doc/angular.hammer.js.html @@ -112,6 +112,7 @@

        Source: angular.hammer.js

        * @requires angular * @requires hammer */ + var NAME = 'hmTouchEvents'; var hmTouchEvents = angular.module('hmTouchEvents', []); /** @@ -128,29 +129,32 @@

        Source: angular.hammer.js

        var recognizerOptsHash = {}; var managerOpts = {}; + // + // In order to use the Hamme rpresets provided, we need + // to map the recognizer fn to some name: + // + var recognizerFnToName = {}; + recognizerFnToName[ Hammer.Tap.toString() ] = "tap"; + recognizerFnToName[ Hammer.Pan.toString() ] = "pan"; + recognizerFnToName[ Hammer.Pinch.toString() ] = "pinch"; + recognizerFnToName[ Hammer.Press.toString() ] = "press"; + recognizerFnToName[ Hammer.Rotate.toString() ] = "rotate"; + recognizerFnToName[ Hammer.Swipe.toString() ] = "swipe"; + // // Make use of presets from Hammer.defaults.preset array // in angular-hammer events. // self.applyHammerPresets = function(){ - //force hammer to extend presets with more info: - Hammer(document.createElement("i")); var hammerPresets = Hammer.defaults.preset; //add each preset to defaults list so long as there //is associated config with it: angular.forEach(hammerPresets, function(presetArr){ - + var name = recognizerFnToName[presetArr[0]]; var data = presetArr[1]; - if(!data) return; - var name = data.event; - - //use event name given by hammer to set event type now: - data.type = name; - - if(!name) throw Error(NAME+"Provider: useHammerPresets: preset event expected by now"); - recognizerOptsHash[name] = data; - + if(!data || !name) return; + recognizerOptsHash[name] = angular.copy(data); }); } @@ -220,26 +224,40 @@

        Source: angular.hammer.js

        var eventType = getRecognizerTypeFromeventName(eventName); - //dont apply anything if this is custom event: + if(typeof opts == "undefined"){ + opts = []; + } else if(!Array.isArray(opts)){ + opts = [opts]; + } + + //dont apply anything if this is custom event + //(beyond normalizing opts to an array): if(eventType == "custom") return opts; var eventOpts = recognizerOptsHash[eventType]; - var defaults = defaultRecognizerOpts; - //dont apply anything if nothing set to apply: - if(!eventOpts && !defaults) return opts; + //find any defaults provided and extend them + //together with global defaults: + var defaults = angular.extend({}, defaultRecognizerOpts || {}, opts.reduce(function(o, opt){ + if(opt.type) return o; + return angular.extend(o, opt); + }, {})); + + //no opts, but either defaults or eventOpts, so we + //create an opt to get those options in and return: + if(!opts.length) return [angular.extend({type:eventType}, defaults, eventOpts || {})]; - //no opts, but either defaults or eventOpts to apply to extend: - if(!opts) return angular.extend({type:eventType}, defaults || {}, eventOpts || {}); + //one or more opts; extend the opt matching this eventName + //with the defaults and event-specific opts set up here. + //remove "default" opts entirely as we merge them in with + //the relevant type here anyway. + return opts.map(function(opt){ - //extend provided opts with settings obtained here: - if(!Array.isArray(opts)) opts = [opts]; - opts = opts.map(function(opt){ - if(!opt.type && defaults) return angular.extend({}, defaults, opt); - if(opt.type == eventType) return angular.extend({}, defaults, eventOpts, opt); - }); + if(!opt.type) return false; + if(opt.type == eventType) return angular.extend({}, defaults, eventOpts || {}, opt); + else return opt; - return opts; + }).filter(angular.identity); } }; @@ -259,34 +277,23 @@

        Source: angular.hammer.js

        directiveName = directive[0], eventName = directive[1]; - hmTouchEvents.directive(directiveName, ['$parse', '$window', hmTouchEvents, function ($parse, $window, defaultEvents) { + hmTouchEvents.directive(directiveName, ['$parse', '$window', NAME, function ($parse, $window, defaultEvents) { return { 'restrict' : 'A', 'link' : function (scope, element, attrs) { - // Check for Hammer and required functionality - // If no Hammer, maybe bind tap and doubletap to click and dblclick - + // Check for Hammer and required functionality. + // error if they arent found as unexpected behaviour otherwise if (!Hammer || !$window.addEventListener) { - if (directiveName === 'hmTap') { - element.bind('click', handler); - } - - if (directiveName === 'hmDoubletap') { - element.bind('dblclick', handler); - } - - return; + throw Error(NAME+": window.Hammer or window.addEventListener not found, can't add event "+directiveName); } var hammer = element.data('hammer'), managerOpts = defaultEvents.extendWithDefaultManagerOpts( scope.$eval(attrs.hmManagerOptions) ), recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( eventName, scope.$eval(attrs.hmRecognizerOptions) ); - // Check for a manager, make one if needed and destroy it when // the scope is destroyed - if (!hammer) { hammer = new Hammer.Manager(element[0], managerOpts); element.data('hammer', hammer); @@ -296,7 +303,6 @@

        Source: angular.hammer.js

        } // Instantiate the handler - var handlerName = attrs[directiveName], handlerExpr = $parse(handlerName), handler = function (event) { @@ -330,103 +336,72 @@

        Source: angular.hammer.js

        } }; - // Setting up the recognizers based on the supplied options - if (angular.isArray(recognizerOpts)) { - // The recognizer options may be stored in an array. In this - // case, Angular Hammer iterates through the array of options - // trying to find an occurrence of the options.type in the event - // name. If it find the type in the event name, it applies those - // options to the recognizer for events with that name. If it - // does not find the type in the event name it moves on. - - angular.forEach(recognizerOpts, function (options) { - if (directiveName === 'hmCustom') { - eventName = options.event; - } else { - if (!options.type) { - options.type = getRecognizerTypeFromeventName(eventName); - } - if (options.event) { - delete options.event; - } - } + // The recognizer options are normalized to an array. Angular + // Hammer iterates through the array of options + // trying to find an occurrence of the options.type in the event + // name. If it find the type in the event name, it applies those + // options to the recognizer for events with that name. If it + // does not find the type in the event name it moves on. - if (directiveName === 'hmCustom' || - eventName.indexOf(options.type) > -1) { - setupRecognizerWithOptions( - hammer, - applyManagerOptions(managerOpts, options), - element); - } - }); - } else if (angular.isObject(recognizerOpts)) { - // Recognizer options may be stored as an object. In this case, - // Angular Hammer checks to make sure that the options type - // property is found in the event name. If the options are - // designated for this general type of event, Angular Hammer - // applies the options directly to the manager instance for - // this element. + angular.forEach(recognizerOpts, function (options) { if (directiveName === 'hmCustom') { - eventName = recognizerOpts.event; + eventName = options.event; } else { - if (!recognizerOpts.type) { - recognizerOpts.type = getRecognizerTypeFromeventName(eventName); - } - if (recognizerOpts.event) { - delete recognizerOpts.event; - } - } + //ignore these options if not custom and not + //matching the event type we are working with: + if(eventName.indexOf(options.type || "") == -1){ + return; + } - if (directiveName === 'hmCustom' || - eventName.indexOf(recognizerOpts.type) > -1) { - setupRecognizerWithOptions( - hammer, - applyManagerOptions(managerOpts, recognizerOpts), - element); - } - } else if (directiveName !== 'hmCustom') { - // If no options are supplied, or the supplied options do not - // match any of the above conditions, Angular Hammer sets up - // the default options that a manager instantiated using - // Hammer() would have. - - recognizerOpts = { - 'type': getRecognizerTypeFromeventName(eventName) - }; - - if (directiveName === 'hmDoubletap') { - recognizerOpts.event = eventName; - recognizerOpts.taps = 2; - - if (hammer.get('tap')) { - recognizerOpts.recognizeWith = 'tap'; + if (options.event) { + delete options.event; } } - if (recognizerOpts.type.indexOf('pan') > -1 && - hammer.get('swipe')) { - recognizerOpts.recognizeWith = 'swipe'; - } + //not a custom directive, so apply the defaults + //depending on the directive we're using. + //(to make things like double tap work) + if(directiveName !== 'hmCustom'){ + + if (directiveName === 'hmDoubletap') { + options.event = eventName; + options.taps = 2; + + if (hammer.get('tap')) { + options.recognizeWith = 'tap'; + } + } + + if (options.type.indexOf('pan') > -1 && + hammer.get('swipe')) { + options.recognizeWith = 'swipe'; + } + + if (options.type.indexOf('pinch') > -1 && + hammer.get('rotate')) { + options.recognizeWith = 'rotate'; + } - if (recognizerOpts.type.indexOf('pinch') > -1 && - hammer.get('rotate')) { - recognizerOpts.recognizeWith = 'rotate'; } + //apply the recognizer options: setupRecognizerWithOptions( hammer, - applyManagerOptions(managerOpts, recognizerOpts), - element); - } else { - eventName = null; - } + applyManagerOptions(managerOpts, options), + element + ); - if (eventName) { + }); + + //apply the event so long as there were actually some + //recognizers applied for it + if (recognizerOpts.length) { hammer.on(eventName, handler); } + } }; }]); @@ -694,7 +669,7 @@

        Index

        Modules

        • diff --git a/doc/index.html b/doc/index.html index f45df56..9fcb9bf 100644 --- a/doc/index.html +++ b/doc/index.html @@ -54,7 +54,7 @@

          Index

          Modules

          • diff --git a/doc/module-hmTouchEvents.html b/doc/module-hmTouchEvents.html index 9b29e3c..a34f0d5 100644 --- a/doc/module-hmTouchEvents.html +++ b/doc/module-hmTouchEvents.html @@ -122,7 +122,7 @@

            Index

            Modules

            • From 0b97ded254584156956d4a6e2d673e79fe168f88 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Jun 2015 11:47:56 +0100 Subject: [PATCH 06/15] mention tweaks and take some ownership of them --- README.md | 6 ++++-- angular.hammer.js | 5 ++++- bower.json | 7 ++++--- package.json | 6 +++--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7b5246a..9976d57 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ -# Angular Hammer v2.1.10 +# Angular Hammer v2.1.10-jsdw -An [Angular.js](https://angularjs.org/) module that enables you to bind custom behavior to [Hammer.js](http://hammerjs.github.io/) touch events. It was derived from the [Angular Hammer](https://github.com/monospaced/angular-hammer) project by [Monospaced](https://github.com/monospaced). +An [Angular.js](https://angularjs.org/) module that enables you to bind custom behavior to [Hammer.js](http://hammerjs.github.io/) touch events. It is a tweaked version of Ryan Mullins' [angular-hammer](https://github.com/RyanMullins/angular-hammer) module, which itself was derived from the [Angular Hammer](https://github.com/monospaced/angular-hammer) project by [Monospaced](https://github.com/monospaced). + +Tweaks from Ryan Mullins version include an additional directive to allow setting of global presets and importing of global presets from `Hammer.defaults.presets`, and some general tidyup. ## Installation diff --git a/angular.hammer.js b/angular.hammer.js index a6bfb20..3a2f1bb 100644 --- a/angular.hammer.js +++ b/angular.hammer.js @@ -1,7 +1,10 @@ // ---- Angular Hammer ---- -// Copyright (c) 2014 Ryan S Mullins +// Copyright (c) 2015 Ryan S Mullins // Licensed under the MIT Software License +// +// modifications by James Wilson +// (function (window, angular, Hammer) { 'use strict'; diff --git a/bower.json b/bower.json index b582a70..960e6d2 100644 --- a/bower.json +++ b/bower.json @@ -1,10 +1,11 @@ { "name": "AngularHammer", - "version": "2.1.10", + "version": "2.1.10-jsdw", "authors": [ - "Ryan S Mullins " + "Ryan S Mullins ", + "James Wilson " ], - "homepage": "https://github.com/RyanMullins/angular-hammer", + "homepage": "https://github.com/jsdw/angular-hammer", "main": "angular.hammer.js", "license": "MIT", "keywords": [ diff --git a/package.json b/package.json index 7d56b08..3a78dcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-hammer", - "version": "2.1.10", + "version": "2.1.10-jsdw", "description": "Hammer.js support for Angular.js applications", "main": "angular.hammer.js", "directories": { @@ -20,10 +20,10 @@ "touch", "gesture" ], - "author": "Ryan S Mullins", + "author": "Ryan S Mullins & James Wilson", "license": "MIT", "bugs": { - "url": "https://github.com/RyanMullins/angular-hammer/issues" + "url": "https://github.com/jsdw/angular-hammer/issues" }, "homepage": "http://ryanmullins.github.io/angular-hammer/", "devDependencies": { From 5cdc4bb987789152c2a29e913753e98496bf90a3 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Jun 2015 11:48:12 +0100 Subject: [PATCH 07/15] update docs/builds --- angular.hammer.min.js | 5 ++++- angular.hammer.min.js.map | 2 +- doc/angular.hammer.js.html | 7 +++++-- doc/index.html | 2 +- doc/module-hmTouchEvents.html | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/angular.hammer.min.js b/angular.hammer.min.js index bb85df2..b9a2288 100644 --- a/angular.hammer.min.js +++ b/angular.hammer.min.js @@ -1,5 +1,8 @@ // ---- Angular Hammer ---- -// Copyright (c) 2014 Ryan S Mullins +// Copyright (c) 2015 Ryan S Mullins // Licensed under the MIT Software License +// +// modifications by James Wilson +// !function(a,b,c){"use strict";function d(a,b){if(void 0===a||void 0===b)return null;var d;return d=b.indexOf("pan")>-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":"tap"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b.type);if(e||(e=d(a,b.type)),b.directions||("pan"===b.type||"swipe"===b.type?b.directions="DIRECTION_ALL":b.type.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b.type.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b.type.indexOf("up")>-1?b.directions="DIRECTION_UP":b.type.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;b-1&&n.get("swipe")&&(a.recognizeWith="swipe"),a.type.indexOf("pinch")>-1&&n.get("rotate")&&(a.recognizeWith="rotate")),g(n,e(o,a),k)}),p.length&&n.on(h,s)}}}])})}(window,window.angular,window.Hammer); //# sourceMappingURL=angular.hammer.min.js.map \ No newline at end of file diff --git a/angular.hammer.min.js.map b/angular.hammer.min.js.map index 954df94..f02e4e6 100644 --- a/angular.hammer.min.js.map +++ b/angular.hammer.min.js.map @@ -1 +1 @@ -{"version":3,"file":"angular.hammer.min.js","sources":["angular.hammer.js"],"names":["window","angular","Hammer","addRecognizer","manager","type","undefined","recognizer","indexOf","Pan","Pinch","Press","Rotate","Swipe","Tap","add","applyManagerOptions","managerOpts","recognizerOpts","preventGhosts","getRecognizerTypeFromeventName","eventName","setupRecognizerWithOptions","options","element","console","error","get","directions","direction","parseDirections","set","recognizeWith","recognizeWithRecognizer","dropRecognizeWith","requireFailure","requireFailureRecognizer","dropRequireFailure","dirs","forEach","split","hasOwnProperty","preventGhostClick","ev","i","coordinates","length","x","y","Math","abs","clientX","threshold","clientY","stopPropagation","preventDefault","resetCoordinates","popCoordinates","splice","registerCoordinates","touches","changedTouches","touch","push","setTimeout","timeout","addEventListener","require","e","log","gestureTypes","NAME","hmTouchEvents","module","provider","self","this","defaultRecognizerOpts","recognizerOptsHash","recognizerFnToName","toString","applyHammerPresets","hammerPresets","defaults","preset","presetArr","name","data","copy","addManagerOption","val","extend","addRecognizerOption","Array","isArray","Error","$get","extendWithDefaultManagerOpts","opts","extendWithDefaultRecognizerOpts","eventType","eventOpts","reduce","o","opt","map","filter","identity","directive","directiveName","$parse","$window","defaultEvents","restrict","link","scope","attrs","hammer","$eval","hmManagerOptions","hmRecognizerOptions","Manager","$on","destroy","handlerName","handlerExpr","handler","event","callHandler","fn","$event","call","phase","$root","$$phase","srcEvent","$apply","taps","on"],"mappings":";;;CAKA,SAAWA,EAAQC,EAASC,GAC1B,YAmYA,SAASC,GAAeC,EAASC,GAC/B,GAAgBC,SAAZF,GAAkCE,SAATD,EAAsB,MAAO,KAE1D,IAAIE,EAiBJ,OAdEA,GADEF,EAAKG,QAAQ,OAAS,GACX,GAAIN,GAAOO,IACfJ,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOQ,MACfL,EAAKG,QAAQ,SAAW,GACpB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OAAOR,GAoBrB/H,GAAQsC,QAAQrB,EAAgB,SAAUK,GAExC,GAAsB,aAAlBsF,EACFxF,EAAYE,EAAQwG,UACf,CAIL,GAA4C,IAAzC1G,EAAUb,QAAQe,EAAQlB,MAAQ,IACnC,MAGEkB,GAAQwG,aACHxG,GAAQwG,MAOE,aAAlBlB,IAEqB,gBAAlBA,IACFtF,EAAQwG,MAAQ1G,EAChBE,EAAQkH,KAAO,EAEXpB,EAAO1F,IAAI,SACbJ,EAAQS,cAAgB,QAIxBT,EAAQlB,KAAKG,QAAQ,OAAS,IAC9B6G,EAAO1F,IAAI,WACbJ,EAAQS,cAAgB,SAGtBT,EAAQlB,KAAKG,QAAQ,SAAW,IAChC6G,EAAO1F,IAAI,YACbJ,EAAQS,cAAgB,WAM5BV,EACE+F,EACArG,EAAoBC,EAAaM,GACjCC,KAOAN,EAAe4B,QACjBuE,EAAOqB,GAAGrH,EAAWyG,WA6PhC9H,OAAQA,OAAOC,QAASD,OAAOE"} \ No newline at end of file +{"version":3,"file":"angular.hammer.min.js","sources":["angular.hammer.js"],"names":["window","angular","Hammer","addRecognizer","manager","type","undefined","recognizer","indexOf","Pan","Pinch","Press","Rotate","Swipe","Tap","add","applyManagerOptions","managerOpts","recognizerOpts","preventGhosts","getRecognizerTypeFromeventName","eventName","setupRecognizerWithOptions","options","element","console","error","get","directions","direction","parseDirections","set","recognizeWith","recognizeWithRecognizer","dropRecognizeWith","requireFailure","requireFailureRecognizer","dropRequireFailure","dirs","forEach","split","hasOwnProperty","preventGhostClick","ev","i","coordinates","length","x","y","Math","abs","clientX","threshold","clientY","stopPropagation","preventDefault","resetCoordinates","popCoordinates","splice","registerCoordinates","touches","changedTouches","touch","push","setTimeout","timeout","addEventListener","require","e","log","gestureTypes","NAME","hmTouchEvents","module","provider","self","this","defaultRecognizerOpts","recognizerOptsHash","recognizerFnToName","toString","applyHammerPresets","hammerPresets","defaults","preset","presetArr","name","data","copy","addManagerOption","val","extend","addRecognizerOption","Array","isArray","Error","$get","extendWithDefaultManagerOpts","opts","extendWithDefaultRecognizerOpts","eventType","eventOpts","reduce","o","opt","map","filter","identity","directive","directiveName","$parse","$window","defaultEvents","restrict","link","scope","attrs","hammer","$eval","hmManagerOptions","hmRecognizerOptions","Manager","$on","destroy","handlerName","handlerExpr","handler","event","callHandler","fn","$event","call","phase","$root","$$phase","srcEvent","$apply","taps","on"],"mappings":";;;;;;CAQA,SAAWA,EAAQC,EAASC,GAC1B,YAmYA,SAASC,GAAeC,EAASC,GAC/B,GAAgBC,SAAZF,GAAkCE,SAATD,EAAsB,MAAO,KAE1D,IAAIE,EAiBJ,OAdEA,GADEF,EAAKG,QAAQ,OAAS,GACX,GAAIN,GAAOO,IACfJ,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOQ,MACfL,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOS,MACfN,EAAKG,QAAQ,UAAY,GACrB,GAAIN,GAAOU,OACfP,EAAKG,QAAQ,SAAW,GACpB,GAAIN,GAAOW,MAEX,GAAIX,GAAOY,IAG1BV,EAAQW,IAAIR,GACLA,EAUT,QAASS,GAAqBC,EAAaC,GAKzC,MAJID,KACFC,EAAeC,cAAgBF,EAAYE,eAGtCD,EAUT,QAASE,GAAgCC,GACvC,MAAIA,GAAUb,QAAQ,OAAS,GACtB,MACEa,EAAUb,QAAQ,SAAW,GAC/B,QACEa,EAAUb,QAAQ,SAAW,GAC/B,QACEa,EAAUb,QAAQ,UAAY,GAChC,SACEa,EAAUb,QAAQ,SAAW,GAC/B,QAEA,MAaX,QAASc,GAA4BlB,EAASmB,EAASC,GACrD,GAAe,MAAXpB,GAA8B,MAAXmB,GAAmC,MAAhBA,EAAQlB,KAChD,MAAOoB,SAAQC,MAAM,mGACwCtB,EAASmB,EAGxE,IAAIhB,GAAaH,EAAQuB,IAAIJ,EAAQlB,KAyBrC,IAvBKE,IACHA,EAAaJ,EAAcC,EAASmB,EAAQlB,OAGzCkB,EAAQK,aACU,QAAjBL,E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jG,EAAQ,GAAIP,GACxCO,EAAQ+D,KAAK,SAAU8B,GACvBF,EAAMO,IAAI,WAAY,WACpBL,EAAOM,YAKX,IAAIC,GAAcR,EAAMP,GACpBgB,EAAcf,EAAOc,GACrBE,EAAU,SAAUC,GAsBlB,QAASC,KACP,GAAIC,GAAKJ,EAAYV,GAAQe,OAASH,GAEpB,mBAAPE,IACTA,EAAGE,KAAKhB,EAAOY,GAzBnB,GAAIK,GAAQjB,EAAMkB,MAAMC,QACpB/H,EAAa8G,EAAO1F,IAAIoG,EAAM1H,KAElC0H,GAAMvG,QAAUA,EAEZjB,IACEA,EAAWgB,QAAQgC,gBACrBwE,EAAMxE,iBAGJhD,EAAWgB,QAAQ+B,iBACrByE,EAAMQ,SAASjF,mBAIL,WAAV8E,GAAgC,YAAVA,EACxBJ,IAEAb,EAAMqB,OAAOR,GAoBrB/H,GAAQsC,QAAQrB,EAAgB,SAAUK,GAExC,GAAsB,aAAlBsF,EACFxF,EAAYE,EAAQwG,UACf,CAIL,GAA4C,IAAzC1G,EAAUb,QAAQe,EAAQlB,MAAQ,IACnC,MAGEkB,GAAQwG,aACHxG,GAAQwG,MAOE,aAAlBlB,IAEqB,gBAAlBA,IACFtF,EAAQwG,MAAQ1G,EAChBE,EAAQkH,KAAO,EAEXpB,EAAO1F,IAAI,SACbJ,EAAQS,cAAgB,QAIxBT,EAAQlB,KAAKG,QAAQ,OAAS,IAC9B6G,EAAO1F,IAAI,WACbJ,EAAQS,cAAgB,SAGtBT,EAAQlB,KAAKG,QAAQ,SAAW,IAChC6G,EAAO1F,IAAI,YACbJ,EAAQS,cAAgB,WAM5BV,EACE+F,EACArG,EAAoBC,EAAaM,GACjCC,KAOAN,EAAe4B,QACjBuE,EAAOqB,GAAGrH,EAAWyG,WA6PhC9H,OAAQA,OAAOC,QAASD,OAAOE"} \ No newline at end of file diff --git a/doc/angular.hammer.js.html b/doc/angular.hammer.js.html index bb3dcba..02122a9 100644 --- a/doc/angular.hammer.js.html +++ b/doc/angular.hammer.js.html @@ -27,8 +27,11 @@

              Source: angular.hammer.js

              // ---- Angular Hammer ----
               
              -// Copyright (c) 2014 Ryan S Mullins <ryan@ryanmullins.org>
              +// Copyright (c) 2015 Ryan S Mullins <ryan@ryanmullins.org>
               // Licensed under the MIT Software License
              +//
              +// modifications by James Wilson <me@unbui.lt>
              +//
               
               (function (window, angular, Hammer) {
                 'use strict';
              @@ -669,7 +672,7 @@ 

              Index

              Modules

              • diff --git a/doc/index.html b/doc/index.html index 9fcb9bf..af72fc7 100644 --- a/doc/index.html +++ b/doc/index.html @@ -54,7 +54,7 @@

                Index

                Modules

                • diff --git a/doc/module-hmTouchEvents.html b/doc/module-hmTouchEvents.html index a34f0d5..736de80 100644 --- a/doc/module-hmTouchEvents.html +++ b/doc/module-hmTouchEvents.html @@ -65,7 +65,7 @@

                  Source:
                  @@ -122,7 +122,7 @@

                  Index

                  Modules

                  • From 40ffc51e157b11bc054e2b3ca5c524f1696b41ee Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Jun 2015 12:55:46 +0100 Subject: [PATCH 08/15] fix bug where general recognizer opts provided would cause no recognizer opts to be used. unsure about how hammer applies defaults if empty recognizer opts supplied but this seems to be fine (ie defaults used if no overriding params) --- angular.hammer.js | 64 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/angular.hammer.js b/angular.hammer.js index 3a2f1bb..e6a8aa5 100644 --- a/angular.hammer.js +++ b/angular.hammer.js @@ -196,44 +196,44 @@ } return angular.extend({}, managerOpts, opts); }, - extendWithDefaultRecognizerOpts: function(eventName, opts){ + extendWithDefaultRecognizerOpts: function(recognizerType, opts){ - var eventType = getRecognizerTypeFromeventName(eventName); - - if(typeof opts == "undefined"){ + if(typeof opts !== "object"){ opts = []; - } else if(!Array.isArray(opts)){ + } + if(!Array.isArray(opts)){ opts = [opts]; } //dont apply anything if this is custom event //(beyond normalizing opts to an array): - if(eventType == "custom") return opts; + if(recognizerType == "custom") return opts; - var eventOpts = recognizerOptsHash[eventType]; + var eventOpts = recognizerOptsHash[recognizerType]; //find any defaults provided and extend them - //together with global defaults: + //together with global defaults, removing them from + //opts: var defaults = angular.extend({}, defaultRecognizerOpts || {}, opts.reduce(function(o, opt){ if(opt.type) return o; return angular.extend(o, opt); }, {})); - - //no opts, but either defaults or eventOpts, so we - //create an opt to get those options in and return: - if(!opts.length) return [angular.extend({type:eventType}, defaults, eventOpts || {})]; + opts = opts.filter(function(opt){ return "type" in opt; }); //one or more opts; extend the opt matching this eventName //with the defaults and event-specific opts set up here. - //remove "default" opts entirely as we merge them in with - //the relevant type here anyway. - return opts.map(function(opt){ - - if(!opt.type) return false; - if(opt.type == eventType) return angular.extend({}, defaults, eventOpts || {}, opt); + //if the event isnt found but opts exist, add one. + var bOptFound = false; + opts = opts.map(function(opt){ + if(opt.type == recognizerType) { + bOptFound = true; + return angular.extend({}, defaults, eventOpts || {}, opt); + } else return opt; + }); + if(!bOptFound) opts.push( angular.extend({type:recognizerType}, defaults, eventOpts || {}) ); - }).filter(angular.identity); + return opts; } }; @@ -266,7 +266,8 @@ var hammer = element.data('hammer'), managerOpts = defaultEvents.extendWithDefaultManagerOpts( scope.$eval(attrs.hmManagerOptions) ), - recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( eventName, scope.$eval(attrs.hmRecognizerOptions) ); + thisRecognizer = getRecognizerTypeFromeventName(eventName), + recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( thisRecognizer, scope.$eval(attrs.hmRecognizerOptions) ); // Check for a manager, make one if needed and destroy it when // the scope is destroyed @@ -312,23 +313,21 @@ } }; - // The recognizer options are normalized to an array. Angular // Hammer iterates through the array of options // trying to find an occurrence of the options.type in the event // name. If it find the type in the event name, it applies those // options to the recognizer for events with that name. If it // does not find the type in the event name it moves on. - angular.forEach(recognizerOpts, function (options) { - if (directiveName === 'hmCustom') { + if (thisRecognizer === 'custom') { eventName = options.event; } else { //ignore these options if not custom and not //matching the event type we are working with: - if(eventName.indexOf(options.type || "") == -1){ + if(thisRecognizer !== options.type){ return; } @@ -340,7 +339,7 @@ //not a custom directive, so apply the defaults //depending on the directive we're using. //(to make things like double tap work) - if(directiveName !== 'hmCustom'){ + if(thisRecognizer === 'custom'){ if (directiveName === 'hmDoubletap') { options.event = eventName; @@ -351,12 +350,12 @@ } } - if (options.type.indexOf('pan') > -1 && + if (options.type == "pan" && hammer.get('swipe')) { options.recognizeWith = 'swipe'; } - if (options.type.indexOf('pinch') > -1 && + if (options.type == "pinch" && hammer.get('rotate')) { options.recognizeWith = 'rotate'; } @@ -372,11 +371,8 @@ }); - //apply the event so long as there were actually some - //recognizers applied for it - if (recognizerOpts.length) { - hammer.on(eventName, handler); - } + //apply the event. potentialls + hammer.on(eventName, handler); } }; @@ -450,8 +446,10 @@ return 'rotate'; } else if (eventName.indexOf('swipe') > -1) { return 'swipe'; - } else { + } else if (eventName.indexOf('tap') > -1) { return 'tap'; + } else { + return "custom"; } } From 4a506b616a9a3cb90e7815a2f3e8f759bfc31d80 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Jun 2015 12:56:09 +0100 Subject: [PATCH 09/15] update builds/docs to latest --- angular.hammer.min.js | 2 +- angular.hammer.min.js.map | 2 +- doc/angular.hammer.js.html | 66 +++++++++++++++++------------------ doc/index.html | 2 +- doc/module-hmTouchEvents.html | 2 +- 5 files changed, 36 insertions(+), 38 deletions(-) diff --git a/angular.hammer.min.js b/angular.hammer.min.js index b9a2288..5b9f82b 100644 --- a/angular.hammer.min.js +++ b/angular.hammer.min.js @@ -4,5 +4,5 @@ // // modifications by James Wilson // -!function(a,b,c){"use strict";function d(a,b){if(void 0===a||void 0===b)return null;var d;return d=b.indexOf("pan")>-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":"tap"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b.type);if(e||(e=d(a,b.type)),b.directions||("pan"===b.type||"swipe"===b.type?b.directions="DIRECTION_ALL":b.type.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b.type.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b.type.indexOf("up")>-1?b.directions="DIRECTION_UP":b.type.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;b-1&&n.get("swipe")&&(a.recognizeWith="swipe"),a.type.indexOf("pinch")>-1&&n.get("rotate")&&(a.recognizeWith="rotate")),g(n,e(o,a),k)}),p.length&&n.on(h,s)}}}])})}(window,window.angular,window.Hammer); +!function(a,b,c){"use strict";function d(a,b){if(void 0===a||void 0===b)return null;var d;return d=b.indexOf("pan")>-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":a.indexOf("tap")>-1?"tap":"custom"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b.type);if(e||(e=d(a,b.type)),b.directions||("pan"===b.type||"swipe"===b.type?b.directions="DIRECTION_ALL":b.type.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b.type.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b.type.indexOf("up")>-1?b.directions="DIRECTION_UP":b.type.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;bSource: angular.hammer.js } return angular.extend({}, managerOpts, opts); }, - extendWithDefaultRecognizerOpts: function(eventName, opts){ + extendWithDefaultRecognizerOpts: function(recognizerType, opts){ - var eventType = getRecognizerTypeFromeventName(eventName); - - if(typeof opts == "undefined"){ + if(typeof opts !== "object"){ opts = []; - } else if(!Array.isArray(opts)){ + } + if(!Array.isArray(opts)){ opts = [opts]; } //dont apply anything if this is custom event //(beyond normalizing opts to an array): - if(eventType == "custom") return opts; + if(recognizerType == "custom") return opts; - var eventOpts = recognizerOptsHash[eventType]; + var eventOpts = recognizerOptsHash[recognizerType]; //find any defaults provided and extend them - //together with global defaults: + //together with global defaults, removing them from + //opts: var defaults = angular.extend({}, defaultRecognizerOpts || {}, opts.reduce(function(o, opt){ if(opt.type) return o; return angular.extend(o, opt); }, {})); - - //no opts, but either defaults or eventOpts, so we - //create an opt to get those options in and return: - if(!opts.length) return [angular.extend({type:eventType}, defaults, eventOpts || {})]; + opts = opts.filter(function(opt){ return "type" in opt; }); //one or more opts; extend the opt matching this eventName //with the defaults and event-specific opts set up here. - //remove "default" opts entirely as we merge them in with - //the relevant type here anyway. - return opts.map(function(opt){ - - if(!opt.type) return false; - if(opt.type == eventType) return angular.extend({}, defaults, eventOpts || {}, opt); + //if the event isnt found but opts exist, add one. + var bOptFound = false; + opts = opts.map(function(opt){ + if(opt.type == recognizerType) { + bOptFound = true; + return angular.extend({}, defaults, eventOpts || {}, opt); + } else return opt; + }); + if(!bOptFound) opts.push( angular.extend({type:recognizerType}, defaults, eventOpts || {}) ); - }).filter(angular.identity); + return opts; } }; @@ -293,7 +293,8 @@

                    Source: angular.hammer.js

                    var hammer = element.data('hammer'), managerOpts = defaultEvents.extendWithDefaultManagerOpts( scope.$eval(attrs.hmManagerOptions) ), - recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( eventName, scope.$eval(attrs.hmRecognizerOptions) ); + thisRecognizer = getRecognizerTypeFromeventName(eventName), + recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( thisRecognizer, scope.$eval(attrs.hmRecognizerOptions) ); // Check for a manager, make one if needed and destroy it when // the scope is destroyed @@ -339,23 +340,21 @@

                    Source: angular.hammer.js

                    } }; - // The recognizer options are normalized to an array. Angular // Hammer iterates through the array of options // trying to find an occurrence of the options.type in the event // name. If it find the type in the event name, it applies those // options to the recognizer for events with that name. If it // does not find the type in the event name it moves on. - angular.forEach(recognizerOpts, function (options) { - if (directiveName === 'hmCustom') { + if (thisRecognizer === 'custom') { eventName = options.event; } else { //ignore these options if not custom and not //matching the event type we are working with: - if(eventName.indexOf(options.type || "") == -1){ + if(thisRecognizer !== options.type){ return; } @@ -367,7 +366,7 @@

                    Source: angular.hammer.js

                    //not a custom directive, so apply the defaults //depending on the directive we're using. //(to make things like double tap work) - if(directiveName !== 'hmCustom'){ + if(thisRecognizer === 'custom'){ if (directiveName === 'hmDoubletap') { options.event = eventName; @@ -378,12 +377,12 @@

                    Source: angular.hammer.js

                    } } - if (options.type.indexOf('pan') > -1 && + if (options.type == "pan" && hammer.get('swipe')) { options.recognizeWith = 'swipe'; } - if (options.type.indexOf('pinch') > -1 && + if (options.type == "pinch" && hammer.get('rotate')) { options.recognizeWith = 'rotate'; } @@ -399,11 +398,8 @@

                    Source: angular.hammer.js

                    }); - //apply the event so long as there were actually some - //recognizers applied for it - if (recognizerOpts.length) { - hammer.on(eventName, handler); - } + //apply the event. potentialls + hammer.on(eventName, handler); } }; @@ -477,8 +473,10 @@

                    Source: angular.hammer.js

                    return 'rotate'; } else if (eventName.indexOf('swipe') > -1) { return 'swipe'; - } else { + } else if (eventName.indexOf('tap') > -1) { return 'tap'; + } else { + return "custom"; } } @@ -672,7 +670,7 @@

                    Index

                    Modules

                    • diff --git a/doc/index.html b/doc/index.html index af72fc7..b15bc2f 100644 --- a/doc/index.html +++ b/doc/index.html @@ -54,7 +54,7 @@

                      Index

                      Modules

                      • diff --git a/doc/module-hmTouchEvents.html b/doc/module-hmTouchEvents.html index 736de80..4f1eae0 100644 --- a/doc/module-hmTouchEvents.html +++ b/doc/module-hmTouchEvents.html @@ -122,7 +122,7 @@

                        Index

                        Modules

                        • From 79ad80d659fed1ae99ab2b277f2b982bbecc7c79 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Jun 2015 13:15:22 +0100 Subject: [PATCH 10/15] boolean got inverted last commit, fixed --- angular.hammer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular.hammer.js b/angular.hammer.js index e6a8aa5..a3d3305 100644 --- a/angular.hammer.js +++ b/angular.hammer.js @@ -339,7 +339,7 @@ //not a custom directive, so apply the defaults //depending on the directive we're using. //(to make things like double tap work) - if(thisRecognizer === 'custom'){ + if(thisRecognizer !== 'custom'){ if (directiveName === 'hmDoubletap') { options.event = eventName; From 8c0018042d8b54aa77453c81ce94c1981a869d29 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Jun 2015 13:15:45 +0100 Subject: [PATCH 11/15] update builds to latest --- angular.hammer.min.js | 2 +- doc/angular.hammer.js.html | 4 ++-- doc/index.html | 2 +- doc/module-hmTouchEvents.html | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/angular.hammer.min.js b/angular.hammer.min.js index 5b9f82b..201ee09 100644 --- a/angular.hammer.min.js +++ b/angular.hammer.min.js @@ -4,5 +4,5 @@ // // modifications by James Wilson // -!function(a,b,c){"use strict";function d(a,b){if(void 0===a||void 0===b)return null;var d;return d=b.indexOf("pan")>-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":a.indexOf("tap")>-1?"tap":"custom"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b.type);if(e||(e=d(a,b.type)),b.directions||("pan"===b.type||"swipe"===b.type?b.directions="DIRECTION_ALL":b.type.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b.type.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b.type.indexOf("up")>-1?b.directions="DIRECTION_UP":b.type.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;b-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":a.indexOf("tap")>-1?"tap":"custom"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b.type);if(e||(e=d(a,b.type)),b.directions||("pan"===b.type||"swipe"===b.type?b.directions="DIRECTION_ALL":b.type.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b.type.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b.type.indexOf("up")>-1?b.directions="DIRECTION_UP":b.type.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;bSource: angular.hammer.js //not a custom directive, so apply the defaults //depending on the directive we're using. //(to make things like double tap work) - if(thisRecognizer === 'custom'){ + if(thisRecognizer !== 'custom'){ if (directiveName === 'hmDoubletap') { options.event = eventName; @@ -670,7 +670,7 @@

                          Index

                          Modules

                          • diff --git a/doc/index.html b/doc/index.html index b15bc2f..38c304c 100644 --- a/doc/index.html +++ b/doc/index.html @@ -54,7 +54,7 @@

                            Index

                            Modules

                            • diff --git a/doc/module-hmTouchEvents.html b/doc/module-hmTouchEvents.html index 4f1eae0..57ed1f5 100644 --- a/doc/module-hmTouchEvents.html +++ b/doc/module-hmTouchEvents.html @@ -122,7 +122,7 @@

                              Index

                              Modules

                              • From 7cce298954e847a6d4b61520629935ce40821600 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 18 Jun 2015 11:54:06 +0100 Subject: [PATCH 12/15] heavy changes including 1. remove checks involving require() as they break if hammer included through other means and browserify is used, 2. simplify a bunch of code including event handler which doesn't need to check digest phase, 3. fix a bunch of bugs with the previous iteration, 4. allow options to target doubletap specifically using eventname, 5. better normalization so less code in link function --- angular.hammer.js | 302 +++++++++++++++++++++------------------------- 1 file changed, 137 insertions(+), 165 deletions(-) diff --git a/angular.hammer.js b/angular.hammer.js index a3d3305..444c96a 100644 --- a/angular.hammer.js +++ b/angular.hammer.js @@ -3,7 +3,7 @@ // Copyright (c) 2015 Ryan S Mullins // Licensed under the MIT Software License // -// modifications by James Wilson +// (fairly heavy) modifications by James Wilson // (function (window, angular, Hammer) { @@ -12,31 +12,10 @@ // Checking to make sure Hammer and Angular are defined if (typeof angular === 'undefined') { - if (typeof require !== 'undefined' && require) { - try { - angular = require('angular'); - } catch (e) { - return console.log('ERROR: Angular Hammer could not require() a reference to angular'); - } - } else if (typeof window.angular !== 'undefined') { - angular = window.angular; - } else { - return console.log('ERROR: Angular Hammer could not find or require() a reference to angular'); - } + throw Error("angular-hammer: AngularJS (window.angular) is undefined but is necessary."); } - if (typeof Hammer === 'undefined') { - if (typeof require !== 'undefined' && require) { - try { - Hammer = require('hammerjs'); - } catch (e) { - return console.log('ERROR: Angular Hammer could not require() a reference to Hammer'); - } - } else if (typeof window.Hammer !== 'undefined') { - Hammer = window.Hammer; - } else { - return console.log('ERROR: Angular Hammer could not find or require() a reference to Hammer'); - } + throw Error("angular-hammer: HammerJS (window.Hammer) is undefined but is necessary."); } /** @@ -117,6 +96,46 @@ recognizerFnToName[ Hammer.Rotate.toString() ] = "rotate"; recognizerFnToName[ Hammer.Swipe.toString() ] = "swipe"; + // + // normalize opts, setting its name as it should be keyed by + // and any must-have options. currently only doubletap is treated + // specially. each _name leads to a new recognizer. + // + function normalizeRecognizerOptions(opts){ + opts = angular.copy(opts); + + if(opts.event){ + + if(opts.event == "doubletap"){ + opts.type = "tap"; + if(!opts.taps) opts.taps = 2; + opts._name = "doubletap"; + } else { + opts._name = false; + } + + } else { + opts._name = opts.type || false; + } + + return opts; + } + // + // create default opts for some eventName. + // again, treat doubletap specially. + // + function defaultOptionsForEvent(eventName){ + if(eventName == "custom"){ + throw Error(NAME+"Provider: no defaults exist for custom events"); + } + var ty = getRecognizerTypeFromeventName(eventName); + return normalizeRecognizerOptions( + eventName == "doubletap" + ? {type:ty, event:"doubletap"} + : {type:ty} + ); + } + // // Make use of presets from Hammer.defaults.preset array // in angular-hammer events. @@ -124,13 +143,15 @@ self.applyHammerPresets = function(){ var hammerPresets = Hammer.defaults.preset; - //add each preset to defaults list so long as there - //is associated config with it: + //add every preset that, when normalized, has a _name. + //this precludes most custom events. angular.forEach(hammerPresets, function(presetArr){ - var name = recognizerFnToName[presetArr[0]]; + var data = presetArr[1]; - if(!data || !name) return; - recognizerOptsHash[name] = angular.copy(data); + if(!data.type) data.type = recognizerFnToName[presetArr[0]]; + data = normalizeRecognizerOptions(data); + if(!data._name) return; + recognizerOptsHash[data._name] = data; }); } @@ -147,39 +168,26 @@ } // - // Add a recognizer option (key/val or object with "type" set): + // Add a recognizer option: // - self.addRecognizerOption = function(name, val){ - if(Array.isArray(name)){ - for(var i = 0; i < name.length; i++) self.addRecognizerOption(name[i]); + self.addRecognizerOption = function(val){ + if(Array.isArray(val)){ + for(var i = 0; i < val.length; i++) self.addRecognizerOption(val[i]); return; } - if(typeof name == "object") { - val = name; - name = val.type; - } - if(typeof val != "object") { - throw Error(NAME+"Provider: recognizer value expected to be object"); + if(typeof val !== "object"){ + throw Error(NAME+"Provider: addRecognizerOption: should be object or array of objects"); } - if(!name){ - defaultRecognizerOpts = val; - } else { + val = normalizeRecognizerOptions(val); + + //hash by name if present, else if no event name, + //set as defaults. + if(val._name){ recognizerOptsHash[val.type] = val; + } else if(!val.event){ + defaultRecognizerOpts = val; } - } - // internal helper funcs: - function doRecognizerOptsExist(type, arr){ - for(var i = 0; i < arr.length; i++){ - if(arr[i].type == type) return true; - } - return false; - } - function doDefaultRecognizerOptsExist(arr){ - for(var i = 0; i < arr.length; i++){ - if(!arr[i].type) return true; - } - return false; } //provide an interface to this that the hm-* directives use @@ -189,15 +197,15 @@ extendWithDefaultManagerOpts: function(opts){ if(typeof opts != "object"){ opts = {}; + } else { + opts = angular.copy(opts); } - var out = {}; for(var name in managerOpts) { if(!opts[name]) opts[name] = angular.copy(managerOpts[name]); } - return angular.extend({}, managerOpts, opts); + return opts; }, - extendWithDefaultRecognizerOpts: function(recognizerType, opts){ - + extendWithDefaultRecognizerOpts: function(eventName, opts){ if(typeof opts !== "object"){ opts = []; } @@ -207,34 +215,40 @@ //dont apply anything if this is custom event //(beyond normalizing opts to an array): - if(recognizerType == "custom") return opts; - - var eventOpts = recognizerOptsHash[recognizerType]; - - //find any defaults provided and extend them - //together with global defaults, removing them from - //opts: - var defaults = angular.extend({}, defaultRecognizerOpts || {}, opts.reduce(function(o, opt){ - if(opt.type) return o; - return angular.extend(o, opt); - }, {})); - opts = opts.filter(function(opt){ return "type" in opt; }); - - //one or more opts; extend the opt matching this eventName - //with the defaults and event-specific opts set up here. - //if the event isnt found but opts exist, add one. - var bOptFound = false; - opts = opts.map(function(opt){ - if(opt.type == recognizerType) { - bOptFound = true; - return angular.extend({}, defaults, eventOpts || {}, opt); + if(eventName == "custom") return opts; + + var recognizerType = getRecognizerTypeFromeventName(eventName); + var specificOpts = recognizerOptsHash[eventName] || recognizerOptsHash[recognizerType]; + + //get the last opt provided that matches the type or eventName + //that we have. normalizing removes any eventnames we dont care about + //(everything but doubletap at the moment). + var foundOpt; + var isExactMatch = false; + var defaults = angular.extend({}, defaultRecognizerOpts || {}, specificOpts || {}); + opts.forEach(function(opt){ + + if(!opt.event && !opt.type){ + return angular.extend(defaults, opt); + } + if(isExactMatch){ + return; + } + + //more specific wins over less specific. + if(opt.event == eventName){ + foundOpt = opt; + isExactMatch = true; + } else if(!opt.event && opt.type == recognizerType){ + foundOpt = opt; } - else return opt; + }); - if(!bOptFound) opts.push( angular.extend({type:recognizerType}, defaults, eventOpts || {}) ); + if(!foundOpt) foundOpt = defaultOptionsForEvent(eventName); + else foundOpt = normalizeRecognizerOptions(foundOpt); - return opts; + return [angular.extend(defaults, foundOpt)]; } }; }; @@ -255,8 +269,9 @@ hmTouchEvents.directive(directiveName, ['$parse', '$window', NAME, function ($parse, $window, defaultEvents) { return { - 'restrict' : 'A', - 'link' : function (scope, element, attrs) { + restrict: 'A', + scope: false, + link: function (scope, element, attrs) { // Check for Hammer and required functionality. // error if they arent found as unexpected behaviour otherwise @@ -266,8 +281,7 @@ var hammer = element.data('hammer'), managerOpts = defaultEvents.extendWithDefaultManagerOpts( scope.$eval(attrs.hmManagerOptions) ), - thisRecognizer = getRecognizerTypeFromeventName(eventName), - recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( thisRecognizer, scope.$eval(attrs.hmRecognizerOptions) ); + recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( eventName, scope.$eval(attrs.hmRecognizerOptions) ); // Check for a manager, make one if needed and destroy it when // the scope is destroyed @@ -279,100 +293,59 @@ }); } - // Instantiate the handler - var handlerName = attrs[directiveName], - handlerExpr = $parse(handlerName), - handler = function (event) { - var phase = scope.$root.$$phase, - recognizer = hammer.get(event.type); - + // Obtain and wrap our handler function to do a couple of bits for + // us if options provided. + var handlerExpr = $parse(attrs[directiveName]).bind(null,scope); + var handler = function (event) { event.element = element; + var recognizer = hammer.get(event.type); if (recognizer) { if (recognizer.options.preventDefault) { event.preventDefault(); } - if (recognizer.options.stopPropagation) { event.srcEvent.stopPropagation(); } } - if (phase === '$apply' || phase === '$digest') { - callHandler(); - } else { - scope.$apply(callHandler); - } - - function callHandler () { - var fn = handlerExpr(scope, {'$event':event}); - - if (typeof fn === 'function') { - fn.call(scope, event); - } - } + scope.$apply(function(){ + handlerExpr({ '$event': event }); + }); }; - // The recognizer options are normalized to an array. Angular - // Hammer iterates through the array of options - // trying to find an occurrence of the options.type in the event - // name. If it find the type in the event name, it applies those - // options to the recognizer for events with that name. If it - // does not find the type in the event name it moves on. + // The recognizer options are normalized to an array. This array + // contains whatever events we wish to add (our prior extending + // takes care of that), but we do a couple of specific things + // depending on this directive so that events play nice together. angular.forEach(recognizerOpts, function (options) { - if (thisRecognizer === 'custom') { - eventName = options.event; - } else { - - //ignore these options if not custom and not - //matching the event type we are working with: - if(thisRecognizer !== options.type){ - return; - } + if(eventName !== 'custom'){ - if (options.event) { - delete options.event; + if (eventName === 'doubletap' && hammer.get('tap')) { + options.recognizeWith = 'tap'; } - } - - //not a custom directive, so apply the defaults - //depending on the directive we're using. - //(to make things like double tap work) - if(thisRecognizer !== 'custom'){ - - if (directiveName === 'hmDoubletap') { - options.event = eventName; - options.taps = 2; - - if (hammer.get('tap')) { - options.recognizeWith = 'tap'; - } - } - - if (options.type == "pan" && - hammer.get('swipe')) { + else if (options.type == "pan" && hammer.get('swipe')) { options.recognizeWith = 'swipe'; } - - if (options.type == "pinch" && - hammer.get('rotate')) { + else if (options.type == "pinch" && hammer.get('rotate')) { options.recognizeWith = 'rotate'; } } - //apply the recognizer options: + //add the recognizer with these options: setupRecognizerWithOptions( hammer, applyManagerOptions(managerOpts, options), element ); - }); + //if custom there may be multiple events to apply, which + //we do here. else, we'll only ever add one. + hammer.on(eventName, handler); - //apply the event. potentialls - hammer.on(eventName, handler); + }); } }; @@ -390,20 +363,20 @@ * @return {Object} Reference to the new gesture recognizer, if * successful, null otherwise. */ - function addRecognizer (manager, type) { - if (manager === undefined || type === undefined) { return null; } + function addRecognizer (manager, name) { + if (manager === undefined || name === undefined) { return null; } var recognizer; - if (type.indexOf('pan') > -1) { + if (name.indexOf('pan') > -1) { recognizer = new Hammer.Pan(); - } else if (type.indexOf('pinch') > -1) { + } else if (name.indexOf('pinch') > -1) { recognizer = new Hammer.Pinch(); - } else if (type.indexOf('press') > -1) { + } else if (name.indexOf('press') > -1) { recognizer = new Hammer.Press(); - } else if (type.indexOf('rotate') > -1) { + } else if (name.indexOf('rotate') > -1) { recognizer = new Hammer.Rotate(); - } else if (type.indexOf('swipe') > -1) { + } else if (name.indexOf('swipe') > -1) { recognizer = new Hammer.Swipe(); } else { recognizer = new Hammer.Tap(); @@ -468,22 +441,21 @@ ' recognizer. Values of the passed manager and options: ', manager, options); } - var recognizer = manager.get(options.type); - + var recognizer = manager.get(options._name); if (!recognizer) { - recognizer = addRecognizer(manager, options.type); + recognizer = addRecognizer(manager, options._name); } if (!options.directions) { - if (options.type === 'pan' || options.type === 'swipe') { + if (options._name === 'pan' || options._name === 'swipe') { options.directions = 'DIRECTION_ALL'; - } else if (options.type.indexOf('left') > -1) { + } else if (options._name.indexOf('left') > -1) { options.directions = 'DIRECTION_LEFT'; - } else if (options.type.indexOf('right') > -1) { + } else if (options._name.indexOf('right') > -1) { options.directions = 'DIRECTION_RIGHT'; - } else if (options.type.indexOf('up') > -1) { + } else if (options._name.indexOf('up') > -1) { options.directions = 'DIRECTION_UP'; - } else if (options.type.indexOf('down') > -1) { + } else if (options._name.indexOf('down') > -1) { options.directions = 'DIRECTION_DOWN'; } else { options.directions = ''; From c154fa2c2fd0bea7ece6060f717d707628bad1ac Mon Sep 17 00:00:00 2001 From: James Date: Thu, 18 Jun 2015 11:54:29 +0100 Subject: [PATCH 13/15] update builds to latest --- angular.hammer.min.js | 4 +- angular.hammer.min.js.map | 2 +- doc/angular.hammer.js.html | 304 +++++++++++++++------------------- doc/index.html | 2 +- doc/module-hmTouchEvents.html | 4 +- 5 files changed, 144 insertions(+), 172 deletions(-) diff --git a/angular.hammer.min.js b/angular.hammer.min.js index 201ee09..89ace5d 100644 --- a/angular.hammer.min.js +++ b/angular.hammer.min.js @@ -2,7 +2,7 @@ // Copyright (c) 2015 Ryan S Mullins // Licensed under the MIT Software License // -// modifications by James Wilson +// (fairly heavy) modifications by James Wilson // -!function(a,b,c){"use strict";function d(a,b){if(void 0===a||void 0===b)return null;var d;return d=b.indexOf("pan")>-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":a.indexOf("tap")>-1?"tap":"custom"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b.type);if(e||(e=d(a,b.type)),b.directions||("pan"===b.type||"swipe"===b.type?b.directions="DIRECTION_ALL":b.type.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b.type.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b.type.indexOf("up")>-1?b.directions="DIRECTION_UP":b.type.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;b-1?new c.Pan:b.indexOf("pinch")>-1?new c.Pinch:b.indexOf("press")>-1?new c.Press:b.indexOf("rotate")>-1?new c.Rotate:b.indexOf("swipe")>-1?new c.Swipe:new c.Tap,a.add(d),d}function e(a,b){return a&&(b.preventGhosts=a.preventGhosts),b}function f(a){return a.indexOf("pan")>-1?"pan":a.indexOf("pinch")>-1?"pinch":a.indexOf("press")>-1?"press":a.indexOf("rotate")>-1?"rotate":a.indexOf("swipe")>-1?"swipe":a.indexOf("tap")>-1?"tap":"custom"}function g(a,b,c){if(null==a||null==b||null==b.type)return console.error("ERROR: Angular Hammer could not setup the recognizer. Values of the passed manager and options: ",a,b);var e=a.get(b._name);if(e||(e=d(a,b._name)),b.directions||("pan"===b._name||"swipe"===b._name?b.directions="DIRECTION_ALL":b._name.indexOf("left")>-1?b.directions="DIRECTION_LEFT":b._name.indexOf("right")>-1?b.directions="DIRECTION_RIGHT":b._name.indexOf("up")>-1?b.directions="DIRECTION_UP":b._name.indexOf("down")>-1?b.directions="DIRECTION_DOWN":b.directions=""),b.direction=h(b.directions),e.set(b),"string"==typeof b.recognizeWith){var f;null==a.get(b.recognizeWith)&&(f=d(a,b.recognizeWith)),null!=f&&e.recognizeWith(f)}if("string"==typeof b.dropRecognizeWith&&null!=a.get(b.dropRecognizeWith)&&e.dropRecognizeWith(a.get(b.dropRecognizeWith)),"string"==typeof b.requireFailure){var g;null==a.get(b.requireFailure)&&(g=d(a,{type:b.requireFailure})),null!=g&&e.requireFailure(g)}"string"==typeof b.dropRequireFailure&&null!=a.get(b.dropRequireFailure)&&e.dropRequireFailure(a.get(b.dropRequireFailure)),b.preventGhosts===!0&&null!=c&&i(c)}function h(a){var d=0;return b.forEach(a.split("|"),function(a){c.hasOwnProperty(a)&&(d|=c[a])}),d}function i(b){function c(a){for(var b=0;bSource: angular.hammer.js // Copyright (c) 2015 Ryan S Mullins <ryan@ryanmullins.org> // Licensed under the MIT Software License // -// modifications by James Wilson <me@unbui.lt> +// (fairly heavy) modifications by James Wilson <me@unbui.lt> // (function (window, angular, Hammer) { @@ -39,31 +39,10 @@

                                Source: angular.hammer.js

                                // Checking to make sure Hammer and Angular are defined if (typeof angular === 'undefined') { - if (typeof require !== 'undefined' && require) { - try { - angular = require('angular'); - } catch (e) { - return console.log('ERROR: Angular Hammer could not require() a reference to angular'); - } - } else if (typeof window.angular !== 'undefined') { - angular = window.angular; - } else { - return console.log('ERROR: Angular Hammer could not find or require() a reference to angular'); - } + throw Error("angular-hammer: AngularJS (window.angular) is undefined but is necessary."); } - if (typeof Hammer === 'undefined') { - if (typeof require !== 'undefined' && require) { - try { - Hammer = require('hammerjs'); - } catch (e) { - return console.log('ERROR: Angular Hammer could not require() a reference to Hammer'); - } - } else if (typeof window.Hammer !== 'undefined') { - Hammer = window.Hammer; - } else { - return console.log('ERROR: Angular Hammer could not find or require() a reference to Hammer'); - } + throw Error("angular-hammer: HammerJS (window.Hammer) is undefined but is necessary."); } /** @@ -144,6 +123,46 @@

                                Source: angular.hammer.js

                                recognizerFnToName[ Hammer.Rotate.toString() ] = "rotate"; recognizerFnToName[ Hammer.Swipe.toString() ] = "swipe"; + // + // normalize opts, setting its name as it should be keyed by + // and any must-have options. currently only doubletap is treated + // specially. each _name leads to a new recognizer. + // + function normalizeRecognizerOptions(opts){ + opts = angular.copy(opts); + + if(opts.event){ + + if(opts.event == "doubletap"){ + opts.type = "tap"; + if(!opts.taps) opts.taps = 2; + opts._name = "doubletap"; + } else { + opts._name = false; + } + + } else { + opts._name = opts.type || false; + } + + return opts; + } + // + // create default opts for some eventName. + // again, treat doubletap specially. + // + function defaultOptionsForEvent(eventName){ + if(eventName == "custom"){ + throw Error(NAME+"Provider: no defaults exist for custom events"); + } + var ty = getRecognizerTypeFromeventName(eventName); + return normalizeRecognizerOptions( + eventName == "doubletap" + ? {type:ty, event:"doubletap"} + : {type:ty} + ); + } + // // Make use of presets from Hammer.defaults.preset array // in angular-hammer events. @@ -151,13 +170,15 @@

                                Source: angular.hammer.js

                                self.applyHammerPresets = function(){ var hammerPresets = Hammer.defaults.preset; - //add each preset to defaults list so long as there - //is associated config with it: + //add every preset that, when normalized, has a _name. + //this precludes most custom events. angular.forEach(hammerPresets, function(presetArr){ - var name = recognizerFnToName[presetArr[0]]; + var data = presetArr[1]; - if(!data || !name) return; - recognizerOptsHash[name] = angular.copy(data); + if(!data.type) data.type = recognizerFnToName[presetArr[0]]; + data = normalizeRecognizerOptions(data); + if(!data._name) return; + recognizerOptsHash[data._name] = data; }); } @@ -174,39 +195,26 @@

                                Source: angular.hammer.js

                                } // - // Add a recognizer option (key/val or object with "type" set): + // Add a recognizer option: // - self.addRecognizerOption = function(name, val){ - if(Array.isArray(name)){ - for(var i = 0; i < name.length; i++) self.addRecognizerOption(name[i]); + self.addRecognizerOption = function(val){ + if(Array.isArray(val)){ + for(var i = 0; i < val.length; i++) self.addRecognizerOption(val[i]); return; } - if(typeof name == "object") { - val = name; - name = val.type; - } - if(typeof val != "object") { - throw Error(NAME+"Provider: recognizer value expected to be object"); + if(typeof val !== "object"){ + throw Error(NAME+"Provider: addRecognizerOption: should be object or array of objects"); } - if(!name){ - defaultRecognizerOpts = val; - } else { + val = normalizeRecognizerOptions(val); + + //hash by name if present, else if no event name, + //set as defaults. + if(val._name){ recognizerOptsHash[val.type] = val; + } else if(!val.event){ + defaultRecognizerOpts = val; } - } - // internal helper funcs: - function doRecognizerOptsExist(type, arr){ - for(var i = 0; i < arr.length; i++){ - if(arr[i].type == type) return true; - } - return false; - } - function doDefaultRecognizerOptsExist(arr){ - for(var i = 0; i < arr.length; i++){ - if(!arr[i].type) return true; - } - return false; } //provide an interface to this that the hm-* directives use @@ -216,15 +224,15 @@

                                Source: angular.hammer.js

                                extendWithDefaultManagerOpts: function(opts){ if(typeof opts != "object"){ opts = {}; + } else { + opts = angular.copy(opts); } - var out = {}; for(var name in managerOpts) { if(!opts[name]) opts[name] = angular.copy(managerOpts[name]); } - return angular.extend({}, managerOpts, opts); + return opts; }, - extendWithDefaultRecognizerOpts: function(recognizerType, opts){ - + extendWithDefaultRecognizerOpts: function(eventName, opts){ if(typeof opts !== "object"){ opts = []; } @@ -234,34 +242,40 @@

                                Source: angular.hammer.js

                                //dont apply anything if this is custom event //(beyond normalizing opts to an array): - if(recognizerType == "custom") return opts; - - var eventOpts = recognizerOptsHash[recognizerType]; - - //find any defaults provided and extend them - //together with global defaults, removing them from - //opts: - var defaults = angular.extend({}, defaultRecognizerOpts || {}, opts.reduce(function(o, opt){ - if(opt.type) return o; - return angular.extend(o, opt); - }, {})); - opts = opts.filter(function(opt){ return "type" in opt; }); - - //one or more opts; extend the opt matching this eventName - //with the defaults and event-specific opts set up here. - //if the event isnt found but opts exist, add one. - var bOptFound = false; - opts = opts.map(function(opt){ - if(opt.type == recognizerType) { - bOptFound = true; - return angular.extend({}, defaults, eventOpts || {}, opt); + if(eventName == "custom") return opts; + + var recognizerType = getRecognizerTypeFromeventName(eventName); + var specificOpts = recognizerOptsHash[eventName] || recognizerOptsHash[recognizerType]; + + //get the last opt provided that matches the type or eventName + //that we have. normalizing removes any eventnames we dont care about + //(everything but doubletap at the moment). + var foundOpt; + var isExactMatch = false; + var defaults = angular.extend({}, defaultRecognizerOpts || {}, specificOpts || {}); + opts.forEach(function(opt){ + + if(!opt.event && !opt.type){ + return angular.extend(defaults, opt); + } + if(isExactMatch){ + return; + } + + //more specific wins over less specific. + if(opt.event == eventName){ + foundOpt = opt; + isExactMatch = true; + } else if(!opt.event && opt.type == recognizerType){ + foundOpt = opt; } - else return opt; + }); - if(!bOptFound) opts.push( angular.extend({type:recognizerType}, defaults, eventOpts || {}) ); + if(!foundOpt) foundOpt = defaultOptionsForEvent(eventName); + else foundOpt = normalizeRecognizerOptions(foundOpt); - return opts; + return [angular.extend(defaults, foundOpt)]; } }; }; @@ -282,8 +296,9 @@

                                Source: angular.hammer.js

                                hmTouchEvents.directive(directiveName, ['$parse', '$window', NAME, function ($parse, $window, defaultEvents) { return { - 'restrict' : 'A', - 'link' : function (scope, element, attrs) { + restrict: 'A', + scope: false, + link: function (scope, element, attrs) { // Check for Hammer and required functionality. // error if they arent found as unexpected behaviour otherwise @@ -293,8 +308,7 @@

                                Source: angular.hammer.js

                                var hammer = element.data('hammer'), managerOpts = defaultEvents.extendWithDefaultManagerOpts( scope.$eval(attrs.hmManagerOptions) ), - thisRecognizer = getRecognizerTypeFromeventName(eventName), - recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( thisRecognizer, scope.$eval(attrs.hmRecognizerOptions) ); + recognizerOpts = defaultEvents.extendWithDefaultRecognizerOpts( eventName, scope.$eval(attrs.hmRecognizerOptions) ); // Check for a manager, make one if needed and destroy it when // the scope is destroyed @@ -306,100 +320,59 @@

                                Source: angular.hammer.js

                                }); } - // Instantiate the handler - var handlerName = attrs[directiveName], - handlerExpr = $parse(handlerName), - handler = function (event) { - var phase = scope.$root.$$phase, - recognizer = hammer.get(event.type); - + // Obtain and wrap our handler function to do a couple of bits for + // us if options provided. + var handlerExpr = $parse(attrs[directiveName]).bind(null,scope); + var handler = function (event) { event.element = element; + var recognizer = hammer.get(event.type); if (recognizer) { if (recognizer.options.preventDefault) { event.preventDefault(); } - if (recognizer.options.stopPropagation) { event.srcEvent.stopPropagation(); } } - if (phase === '$apply' || phase === '$digest') { - callHandler(); - } else { - scope.$apply(callHandler); - } - - function callHandler () { - var fn = handlerExpr(scope, {'$event':event}); - - if (typeof fn === 'function') { - fn.call(scope, event); - } - } + scope.$apply(function(){ + handlerExpr({ '$event': event }); + }); }; - // The recognizer options are normalized to an array. Angular - // Hammer iterates through the array of options - // trying to find an occurrence of the options.type in the event - // name. If it find the type in the event name, it applies those - // options to the recognizer for events with that name. If it - // does not find the type in the event name it moves on. + // The recognizer options are normalized to an array. This array + // contains whatever events we wish to add (our prior extending + // takes care of that), but we do a couple of specific things + // depending on this directive so that events play nice together. angular.forEach(recognizerOpts, function (options) { - if (thisRecognizer === 'custom') { - eventName = options.event; - } else { - - //ignore these options if not custom and not - //matching the event type we are working with: - if(thisRecognizer !== options.type){ - return; - } + if(eventName !== 'custom'){ - if (options.event) { - delete options.event; + if (eventName === 'doubletap' && hammer.get('tap')) { + options.recognizeWith = 'tap'; } - } - - //not a custom directive, so apply the defaults - //depending on the directive we're using. - //(to make things like double tap work) - if(thisRecognizer !== 'custom'){ - - if (directiveName === 'hmDoubletap') { - options.event = eventName; - options.taps = 2; - - if (hammer.get('tap')) { - options.recognizeWith = 'tap'; - } - } - - if (options.type == "pan" && - hammer.get('swipe')) { + else if (options.type == "pan" && hammer.get('swipe')) { options.recognizeWith = 'swipe'; } - - if (options.type == "pinch" && - hammer.get('rotate')) { + else if (options.type == "pinch" && hammer.get('rotate')) { options.recognizeWith = 'rotate'; } } - //apply the recognizer options: + //add the recognizer with these options: setupRecognizerWithOptions( hammer, applyManagerOptions(managerOpts, options), element ); - }); + //if custom there may be multiple events to apply, which + //we do here. else, we'll only ever add one. + hammer.on(eventName, handler); - //apply the event. potentialls - hammer.on(eventName, handler); + }); } }; @@ -417,20 +390,20 @@

                                Source: angular.hammer.js

                                * @return {Object} Reference to the new gesture recognizer, if * successful, null otherwise. */ - function addRecognizer (manager, type) { - if (manager === undefined || type === undefined) { return null; } + function addRecognizer (manager, name) { + if (manager === undefined || name === undefined) { return null; } var recognizer; - if (type.indexOf('pan') > -1) { + if (name.indexOf('pan') > -1) { recognizer = new Hammer.Pan(); - } else if (type.indexOf('pinch') > -1) { + } else if (name.indexOf('pinch') > -1) { recognizer = new Hammer.Pinch(); - } else if (type.indexOf('press') > -1) { + } else if (name.indexOf('press') > -1) { recognizer = new Hammer.Press(); - } else if (type.indexOf('rotate') > -1) { + } else if (name.indexOf('rotate') > -1) { recognizer = new Hammer.Rotate(); - } else if (type.indexOf('swipe') > -1) { + } else if (name.indexOf('swipe') > -1) { recognizer = new Hammer.Swipe(); } else { recognizer = new Hammer.Tap(); @@ -495,22 +468,21 @@

                                Source: angular.hammer.js

                                ' recognizer. Values of the passed manager and options: ', manager, options); } - var recognizer = manager.get(options.type); - + var recognizer = manager.get(options._name); if (!recognizer) { - recognizer = addRecognizer(manager, options.type); + recognizer = addRecognizer(manager, options._name); } if (!options.directions) { - if (options.type === 'pan' || options.type === 'swipe') { + if (options._name === 'pan' || options._name === 'swipe') { options.directions = 'DIRECTION_ALL'; - } else if (options.type.indexOf('left') > -1) { + } else if (options._name.indexOf('left') > -1) { options.directions = 'DIRECTION_LEFT'; - } else if (options.type.indexOf('right') > -1) { + } else if (options._name.indexOf('right') > -1) { options.directions = 'DIRECTION_RIGHT'; - } else if (options.type.indexOf('up') > -1) { + } else if (options._name.indexOf('up') > -1) { options.directions = 'DIRECTION_UP'; - } else if (options.type.indexOf('down') > -1) { + } else if (options._name.indexOf('down') > -1) { options.directions = 'DIRECTION_DOWN'; } else { options.directions = ''; @@ -670,7 +642,7 @@

                                Index

                                Modules

                                • diff --git a/doc/index.html b/doc/index.html index 38c304c..ab65d0d 100644 --- a/doc/index.html +++ b/doc/index.html @@ -54,7 +54,7 @@

                                  Index

                                  Modules

                                  • diff --git a/doc/module-hmTouchEvents.html b/doc/module-hmTouchEvents.html index 57ed1f5..bb20af8 100644 --- a/doc/module-hmTouchEvents.html +++ b/doc/module-hmTouchEvents.html @@ -65,7 +65,7 @@

                                    Source:
                                    @@ -122,7 +122,7 @@

                                    Index

                                    Modules

                                    • From c518dedc753ade3a5d54a81d1dff31da047d62fa Mon Sep 17 00:00:00 2001 From: James Date: Thu, 18 Jun 2015 11:56:55 +0100 Subject: [PATCH 14/15] update version to reflect changes --- README.md | 6 +++--- bower.json | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9976d57..5ab7d52 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Angular Hammer v2.1.10-jsdw +# Angular Hammer v3.0-jsdw -An [Angular.js](https://angularjs.org/) module that enables you to bind custom behavior to [Hammer.js](http://hammerjs.github.io/) touch events. It is a tweaked version of Ryan Mullins' [angular-hammer](https://github.com/RyanMullins/angular-hammer) module, which itself was derived from the [Angular Hammer](https://github.com/monospaced/angular-hammer) project by [Monospaced](https://github.com/monospaced). +An [Angular.js](https://angularjs.org/) module that enables you to bind custom behavior to [Hammer.js](http://hammerjs.github.io/) touch events. It is a heavily modified version of Ryan Mullins' [angular-hammer](https://github.com/RyanMullins/angular-hammer) module, which itself was derived from the [Angular Hammer](https://github.com/monospaced/angular-hammer) project by [Monospaced](https://github.com/monospaced). -Tweaks from Ryan Mullins version include an additional directive to allow setting of global presets and importing of global presets from `Hammer.defaults.presets`, and some general tidyup. +Tweaks from Ryan Mullins version include an additional directive to allow setting of global presets and importing of global presets from `Hammer.defaults.presets`, and other general tidyup. ## Installation diff --git a/bower.json b/bower.json index 960e6d2..735a739 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "AngularHammer", - "version": "2.1.10-jsdw", + "version": "2.2-jsdw", "authors": [ "Ryan S Mullins ", "James Wilson " diff --git a/package.json b/package.json index 3a78dcb..4da65db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-hammer", - "version": "2.1.10-jsdw", + "version": "2.2-jsdw", "description": "Hammer.js support for Angular.js applications", "main": "angular.hammer.js", "directories": { From dcf8878df3ee263902e725823a6ce4d4d5bbee07 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 18 Jun 2015 12:00:10 +0100 Subject: [PATCH 15/15] update docs --- doc/angular.hammer.js.html | 2 +- doc/index.html | 2 +- doc/module-hmTouchEvents.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/angular.hammer.js.html b/doc/angular.hammer.js.html index b92c071..05354e3 100644 --- a/doc/angular.hammer.js.html +++ b/doc/angular.hammer.js.html @@ -642,7 +642,7 @@

                                      Index

                                      Modules

                                      • diff --git a/doc/index.html b/doc/index.html index ab65d0d..addea13 100644 --- a/doc/index.html +++ b/doc/index.html @@ -54,7 +54,7 @@

                                        Index

                                        Modules

                                        • diff --git a/doc/module-hmTouchEvents.html b/doc/module-hmTouchEvents.html index bb20af8..5490c70 100644 --- a/doc/module-hmTouchEvents.html +++ b/doc/module-hmTouchEvents.html @@ -122,7 +122,7 @@

                                          Index

                                          Modules