From 529edc09889f2908aa42a0a49e68da49f01c4a32 Mon Sep 17 00:00:00 2001 From: fat Date: Thu, 6 Mar 2014 21:17:53 -0800 Subject: [PATCH] cleanup fingerblast and rebuid docs --- docs/assets/js/docs.min.js | 2 +- docs/assets/js/fingerblast.js | 417 +++++++++++++++++----------------- 2 files changed, 204 insertions(+), 215 deletions(-) diff --git a/docs/assets/js/docs.min.js b/docs/assets/js/docs.min.js index d64ddab..98b1a11 100644 --- a/docs/assets/js/docs.min.js +++ b/docs/assets/js/docs.min.js @@ -7,4 +7,4 @@ * v2.0.1 designed by @connors. * ===================================================== */ -function FingerBlast(a){"use strict";this.element="string"==typeof a?document.querySelector(a):a,this.listen()}$(function(){"use strict";var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=function(){l=0,m=[],n=$(window),a=$(document),o=$(document.body),b=b||$(".js-device"),h=$(".js-jump-menu"),i=$(".js-component-group"),j=$(".component-example a"),k=$(".component"),m=k.map(function(){return $(this).offset().top}),d=$(window).height()/3,c=$(window).width(),e=$(document).height(),f=parseInt($(".docs-content").css("padding-bottom"),10),g=$(".docs-footer").outerHeight(!1),q=$(".js-docs-component-toolbar"),c>=768&&(b.initialLeft=b.offset().left,b.initialTop=b.initialTop||b.offset().top,b.dockingOffset=($(window).height()-b.height())/2),t(),u(),v(),p||s()},s=function(){p=!0,b.on("click",function(a){a.preventDefault()}),$(".js-docs-nav-trigger").on("click",function(){var a=$(".docs-nav-group"),b=$(".js-docs-nav-trigger");b.toggleClass("active"),a.toggleClass("active")}),h.click(function(a){a.stopPropagation(),a.preventDefault(),i.toggleClass("active")}),a.on("click",function(){i.removeClass("active")}),$(".platform-switch").on("click",function(){var a=$(".docs-components"),b=$(this).attr("data-platform");a.hasClass("platform-ios")?(a.removeClass("platform-ios"),a.addClass(b)):a.hasClass("platform-android")?(a.removeClass("platform-android"),a.addClass(b)):a.addClass(b),$(this).siblings(".active").removeClass("active"),$(this).addClass("active")}),n.on("scroll",u),n.on("scroll",v)},t=function(){if(c=$(window).width(),768>=c){var a=$(".content");a.length>1&&$(a[0]).remove()}},u=function(){function a(a){$("#iwindow").html(a)}if(!(768>=c)){var e,f=n.scrollTop();b.initialTop-f<=b.dockingOffset?(b[0].className="device device-fixed",b.css({top:b.dockingOffset})):(b[0].className="device",b[0].setAttribute("style",""));for(var g=k.length;g--;)if(m[g]-f=b?q.addClass("visible"):b>=a&&(q.removeClass("visible"),i.removeClass("active"))};$(window).on("load resize",r),$(window).on("load",function(){new FingerBlast(".device-content")})}),FingerBlast.prototype={x:0/0,y:0/0,startDistance:0/0,startAngle:0/0,mouseIsDown:!1,listen:function(){"use strict";function a(a,b){var c,d,e;if("compareDocumentPosition"in b)return!!(16&b.compareDocumentPosition(a));if("contains"in b)return b!==a&&b.contains(a);for(c=b.getElementsByTagName("*"),d=0;e=c[d++];)if(e===a)return!0;return!1}var b=this.activate.bind(this),c=this.deactivate.bind(this);this.element.addEventListener("mouseover",function(c){var d=c.relatedTarget;d===this||a(d,this)||b()}),this.element.addEventListener("mouseout",function(b){var d=b.relatedTarget;d===this||a(d,this)||c(b)})},activate:function(){"use strict";this.active||(this.element.addEventListener("mousedown",this.touchStart=this.touchStart.bind(this),!0),this.element.addEventListener("mousemove",this.touchMove=this.touchMove.bind(this),!0),this.element.addEventListener("mouseup",this.touchEnd=this.touchEnd.bind(this),!0),this.element.addEventListener("click",this.click=this.click.bind(this),!0),this.active=!0)},deactivate:function(a){"use strict";this.active=!1,this.mouseIsDown&&this.touchEnd(a),this.element.removeEventListener("mousedown",this.touchStart,!0),this.element.removeEventListener("mousemove",this.touchMove,!0),this.element.removeEventListener("mouseup",this.touchEnd,!0),this.element.removeEventListener("click",this.click,!0)},click:function(a){"use strict";a.synthetic||(a.preventDefault(),a.stopPropagation())},touchStart:function(a){"use strict";a.synthetic||/input|textarea/.test(a.target.tagName.toLowerCase())||(this.mouseIsDown=!0,a.preventDefault(),a.stopPropagation(),this.fireTouchEvents("touchstart",a))},touchMove:function(a){"use strict";a.synthetic||(a.preventDefault(),a.stopPropagation(),this.move(a.clientX,a.clientY),this.mouseIsDown&&this.fireTouchEvents("touchmove",a))},touchEnd:function(a){"use strict";a.synthetic||(this.mouseIsDown=!1,a.preventDefault(),a.stopPropagation(),this.fireTouchEvents("touchend",a),this.target&&(this.target.dispatchEvent(this.createMouseEvent("mouseover",a)),this.target.dispatchEvent(this.createMouseEvent("mousemove",a)),this.target.dispatchEvent(this.createMouseEvent("mousedown",a))))},fireTouchEvents:function(a,b){"use strict";var c=[],d=[];if(this.target){var e="on"+a;if(e in this.target&&(console.warn("Converting `"+e+"` property to event listener.",this.target),this.target.addEventListener(a,this.target[e],!1),delete this.target[e]),this.target.hasAttribute(e)){console.warn("Converting `"+e+"` attribute to event listener.",this.target);var f=new GLOBAL.Function("event",this.target.getAttribute(e));this.target.addEventListener(a,f,!1),this.target.removeAttribute(e)}var g=this.createMouseEvent(a,b);if(c.push(g),c.length>1){var h=c[0].pageX-c[1].pageX,i=c[0].pageY-c[1].pageY,j=Math.sqrt(Math.pow(h,2)+Math.pow(i,2)),k=Math.atan2(h,i)*(180/Math.PI),l="gesturechange";"touchstart"===a&&(l="gesturestart",this.startDistance=j,this.startAngle=k),"touchend"===a&&(l="gestureend"),c.forEach(function(a){var b=this.createMouseEvent.call(a._finger,l,a);d.push(b)}.bind(this)),c.concat(d).forEach(function(a){a.scale=j/this.startDistance,a.rotation=this.startAngle-k})}c.forEach(function(a){a.touches=c.filter(function(a){return~a.type.indexOf("touch")&&"touchend"!==a.type}),a.changedTouches=c.filter(function(b){return~b.type.indexOf("touch")&&b._finger.target===a._finger.target}),a.targetTouches=a.changedTouches.filter(function(a){return~a.type.indexOf("touch")&&"touchend"!==a.type})}),c.concat(d).forEach(function(a,b){a.identifier=b,a._finger.target.dispatchEvent(a)})}},createMouseEvent:function(a,b){"use strict";var c=document.createEvent("MouseEvent");return c.initMouseEvent(a,!0,!0,b.view,b.detail,this.x||b.screenX,this.y||b.screenY,this.x||b.clientX,this.y||b.clientY,b.ctrlKey,b.shiftKey,b.altKey,b.metaKey,b.button,this.target||b.relatedTarget),c.synthetic=!0,c._finger=this,c},move:function(a,b){"use strict";isNaN(a)||isNaN(b)?this.target=null:(this.x=a,this.y=b,this.mouseIsDown||(this.target=document.elementFromPoint(a,b)))}}; \ No newline at end of file +$(function(){"use strict";var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=function(){l=0,m=[],n=$(window),a=$(document),o=$(document.body),b=b||$(".js-device"),h=$(".js-jump-menu"),i=$(".js-component-group"),j=$(".component-example a"),k=$(".component"),m=k.map(function(){return $(this).offset().top}),d=$(window).height()/3,c=$(window).width(),e=$(document).height(),f=parseInt($(".docs-content").css("padding-bottom"),10),g=$(".docs-footer").outerHeight(!1),q=$(".js-docs-component-toolbar"),b.length&&(c>=768&&(b.initialLeft=b.offset().left,b.initialTop=b.initialTop||b.offset().top,b.dockingOffset=($(window).height()-b.height())/2),t(),u(),v(),p||s())},s=function(){p=!0,b.on("click",function(a){a.preventDefault()}),$(".js-docs-nav-trigger").on("click",function(){var a=$(".docs-nav-group"),b=$(".js-docs-nav-trigger");b.toggleClass("active"),a.toggleClass("active")}),h.click(function(a){a.stopPropagation(),a.preventDefault(),i.toggleClass("active")}),a.on("click",function(){i.removeClass("active")}),$(".platform-switch").on("click",function(){var a=$(".docs-components"),b=$(this).attr("data-platform");a.hasClass("platform-ios")?(a.removeClass("platform-ios"),a.addClass(b)):a.hasClass("platform-android")?(a.removeClass("platform-android"),a.addClass(b)):a.addClass(b),$(this).siblings(".active").removeClass("active"),$(this).addClass("active")}),n.on("scroll",u),n.on("scroll",v)},t=function(){if(c=$(window).width(),768>=c){var a=$(".content");a.length>1&&$(a[0]).remove()}},u=function(){function a(a){$("#iwindow").html(a)}if(!(768>=c)){var e,f=n.scrollTop();b.initialTop-f<=b.dockingOffset?(b[0].className="device device-fixed",b.css({top:b.dockingOffset})):(b[0].className="device",b[0].setAttribute("style",""));for(var g=k.length;g--;)if(m[g]-f=b?q.addClass("visible"):b>=a&&(q.removeClass("visible"),i.removeClass("active"))};$(window).on("load resize",r),$(window).on("load",function(){window.FingerBlast&&new FingerBlast(".device-content")})}),function(){"use strict";function a(a){this.element="string"==typeof a?document.querySelector(a):a,this.element&&this.listen()}a.prototype={x:0/0,y:0/0,startDistance:0/0,startAngle:0/0,mouseIsDown:!1,listen:function(){function a(a,b){var c,d,e;if("compareDocumentPosition"in b)return!!(16&b.compareDocumentPosition(a));if("contains"in b)return b!==a&&b.contains(a);for(c=b.getElementsByTagName("*"),d=0;e=c[d++];)if(e===a)return!0;return!1}var b=this.activate.bind(this),c=this.deactivate.bind(this);this.element.addEventListener("mouseover",function(c){var d=c.relatedTarget;d===this||a(d,this)||b()}),this.element.addEventListener("mouseout",function(b){var d=b.relatedTarget;d===this||a(d,this)||c(b)})},activate:function(){this.active||(this.element.addEventListener("mousedown",this.touchStart=this.touchStart.bind(this),!0),this.element.addEventListener("mousemove",this.touchMove=this.touchMove.bind(this),!0),this.element.addEventListener("mouseup",this.touchEnd=this.touchEnd.bind(this),!0),this.element.addEventListener("click",this.click=this.click.bind(this),!0),this.active=!0)},deactivate:function(a){this.active=!1,this.mouseIsDown&&this.touchEnd(a),this.element.removeEventListener("mousedown",this.touchStart,!0),this.element.removeEventListener("mousemove",this.touchMove,!0),this.element.removeEventListener("mouseup",this.touchEnd,!0),this.element.removeEventListener("click",this.click,!0)},click:function(a){a.synthetic||(a.preventDefault(),a.stopPropagation())},touchStart:function(a){a.synthetic||/input|textarea/.test(a.target.tagName.toLowerCase())||(this.mouseIsDown=!0,a.preventDefault(),a.stopPropagation(),this.fireTouchEvents("touchstart",a))},touchMove:function(a){a.synthetic||(a.preventDefault(),a.stopPropagation(),this.move(a.clientX,a.clientY),this.mouseIsDown&&this.fireTouchEvents("touchmove",a))},touchEnd:function(a){a.synthetic||(this.mouseIsDown=!1,a.preventDefault(),a.stopPropagation(),this.fireTouchEvents("touchend",a),this.target&&(this.target.dispatchEvent(this.createMouseEvent("mouseover",a)),this.target.dispatchEvent(this.createMouseEvent("mousemove",a)),this.target.dispatchEvent(this.createMouseEvent("mousedown",a))))},fireTouchEvents:function(a,b){var c=[],d=[];if(this.target){var e="on"+a;if(e in this.target&&(console.warn("Converting `"+e+"` property to event listener.",this.target),this.target.addEventListener(a,this.target[e],!1),delete this.target[e]),this.target.hasAttribute(e)){console.warn("Converting `"+e+"` attribute to event listener.",this.target);var f=new GLOBAL.Function("event",this.target.getAttribute(e));this.target.addEventListener(a,f,!1),this.target.removeAttribute(e)}var g=this.createMouseEvent(a,b);if(c.push(g),c.length>1){var h=c[0].pageX-c[1].pageX,i=c[0].pageY-c[1].pageY,j=Math.sqrt(Math.pow(h,2)+Math.pow(i,2)),k=Math.atan2(h,i)*(180/Math.PI),l="gesturechange";"touchstart"===a&&(l="gesturestart",this.startDistance=j,this.startAngle=k),"touchend"===a&&(l="gestureend"),c.forEach(function(a){var b=this.createMouseEvent.call(a._finger,l,a);d.push(b)}.bind(this)),c.concat(d).forEach(function(a){a.scale=j/this.startDistance,a.rotation=this.startAngle-k})}c.forEach(function(a){a.touches=c.filter(function(a){return~a.type.indexOf("touch")&&"touchend"!==a.type}),a.changedTouches=c.filter(function(b){return~b.type.indexOf("touch")&&b._finger.target===a._finger.target}),a.targetTouches=a.changedTouches.filter(function(a){return~a.type.indexOf("touch")&&"touchend"!==a.type})}),c.concat(d).forEach(function(a,b){a.identifier=b,a._finger.target.dispatchEvent(a)})}},createMouseEvent:function(a,b){var c=document.createEvent("MouseEvent");return c.initMouseEvent(a,!0,!0,b.view,b.detail,this.x||b.screenX,this.y||b.screenY,this.x||b.clientX,this.y||b.clientY,b.ctrlKey,b.shiftKey,b.altKey,b.metaKey,b.button,this.target||b.relatedTarget),c.synthetic=!0,c._finger=this,c},move:function(a,b){isNaN(a)||isNaN(b)?this.target=null:(this.x=a,this.y=b,this.mouseIsDown||(this.target=document.elementFromPoint(a,b)))}},window.FingerBlast=a}(); \ No newline at end of file diff --git a/docs/assets/js/fingerblast.js b/docs/assets/js/fingerblast.js index eb882bb..44165fc 100644 --- a/docs/assets/js/fingerblast.js +++ b/docs/assets/js/fingerblast.js @@ -5,267 +5,256 @@ /* jshint bitwise: false */ /* global GLOBAL: true */ -function FingerBlast(element) { - 'use strict'; - - this.element = typeof element === 'string' ? document.querySelector(element) : element; - this.listen(); -} - -FingerBlast.prototype = { - x: NaN, - y: NaN, - - startDistance: NaN, - startAngle: NaN, +(function () { - mouseIsDown: false, + 'use strict'; - listen: function () { - 'use strict'; + function FingerBlast(element) { + this.element = typeof element === 'string' ? document.querySelector(element) : element; - var activate = this.activate.bind(this); - var deactivate = this.deactivate.bind(this); + if (this.element) { + this.listen(); + } + } - function contains (element, ancestor) { - var descendants, index, descendant; - if ('compareDocumentPosition' in ancestor) { - return !!(ancestor.compareDocumentPosition(element) & 16); - } else if ('contains' in ancestor) { - return ancestor !== element && ancestor.contains(element); - } else { - for ((descendants = ancestor.getElementsByTagName('*')), index = 0; (descendant = descendants[index++]);) { - if (descendant === element) { - return true; + FingerBlast.prototype = { + x: NaN, + y: NaN, + + startDistance: NaN, + startAngle: NaN, + + mouseIsDown: false, + + listen: function () { + var activate = this.activate.bind(this); + var deactivate = this.deactivate.bind(this); + + function contains (element, ancestor) { + var descendants, index, descendant; + if ('compareDocumentPosition' in ancestor) { + return !!(ancestor.compareDocumentPosition(element) & 16); + } else if ('contains' in ancestor) { + return ancestor !== element && ancestor.contains(element); + } else { + for ((descendants = ancestor.getElementsByTagName('*')), index = 0; (descendant = descendants[index++]);) { + if (descendant === element) { + return true; + } } + return false; } - return false; } - } - this.element.addEventListener('mouseover', function (e) { - var target = e.relatedTarget; - if (target !== this && !contains(target, this)) { - activate(); - } - }); + this.element.addEventListener('mouseover', function (e) { + var target = e.relatedTarget; + if (target !== this && !contains(target, this)) { + activate(); + } + }); - this.element.addEventListener('mouseout', function (e) { - var target = e.relatedTarget; - if (target !== this && !contains(target, this)) { - deactivate(e); - } - }); - }, + this.element.addEventListener('mouseout', function (e) { + var target = e.relatedTarget; + if (target !== this && !contains(target, this)) { + deactivate(e); + } + }); + }, - activate: function () { - 'use strict'; + activate: function () { + if (this.active) { + return; + } + this.element.addEventListener('mousedown', (this.touchStart = this.touchStart.bind(this)), true); + this.element.addEventListener('mousemove', (this.touchMove = this.touchMove.bind(this)), true); + this.element.addEventListener('mouseup', (this.touchEnd = this.touchEnd.bind(this)), true); + this.element.addEventListener('click', (this.click = this.click.bind(this)), true); + this.active = true; + }, + + deactivate: function (e) { + this.active = false; + if (this.mouseIsDown) { + this.touchEnd(e); + } + this.element.removeEventListener('mousedown', this.touchStart, true); + this.element.removeEventListener('mousemove', this.touchMove, true); + this.element.removeEventListener('mouseup', this.touchEnd, true); + this.element.removeEventListener('click', this.click, true); + }, + + click: function (e) { + if (e.synthetic) { + return; + } + e.preventDefault(); + e.stopPropagation(); + }, - if (this.active) { - return; - } - this.element.addEventListener('mousedown', (this.touchStart = this.touchStart.bind(this)), true); - this.element.addEventListener('mousemove', (this.touchMove = this.touchMove.bind(this)), true); - this.element.addEventListener('mouseup', (this.touchEnd = this.touchEnd.bind(this)), true); - this.element.addEventListener('click', (this.click = this.click.bind(this)), true); - this.active = true; - }, - - deactivate: function (e) { - 'use strict'; - - this.active = false; - if (this.mouseIsDown) { - this.touchEnd(e); - } - this.element.removeEventListener('mousedown', this.touchStart, true); - this.element.removeEventListener('mousemove', this.touchMove, true); - this.element.removeEventListener('mouseup', this.touchEnd, true); - this.element.removeEventListener('click', this.click, true); - }, + touchStart: function (e) { + if (e.synthetic || /input|textarea/.test(e.target.tagName.toLowerCase())) { + return; + } - click: function (e) { - 'use strict'; + this.mouseIsDown = true; - if (e.synthetic) { - return; - } - e.preventDefault(); - e.stopPropagation(); - }, + e.preventDefault(); + e.stopPropagation(); - touchStart: function (e) { - 'use strict'; + this.fireTouchEvents('touchstart', e); + }, - if (e.synthetic || /input|textarea/.test(e.target.tagName.toLowerCase())) { - return; - } + touchMove: function (e) { + if (e.synthetic) { + return; + } - this.mouseIsDown = true; + e.preventDefault(); + e.stopPropagation(); - e.preventDefault(); - e.stopPropagation(); + this.move(e.clientX, e.clientY); - this.fireTouchEvents('touchstart', e); - }, + if (this.mouseIsDown) { + this.fireTouchEvents('touchmove', e); + } + }, - touchMove: function (e) { - 'use strict'; + touchEnd: function (e) { + if (e.synthetic) { + return; + } - if (e.synthetic) { - return; - } + this.mouseIsDown = false; - e.preventDefault(); - e.stopPropagation(); + e.preventDefault(); + e.stopPropagation(); - this.move(e.clientX, e.clientY); + this.fireTouchEvents('touchend', e); - if (this.mouseIsDown) { - this.fireTouchEvents('touchmove', e); - } - }, + if (!this.target) { + return; + } - touchEnd: function (e) { - 'use strict'; + // Mobile Safari moves all the mouse events to fire after the touchend event. + this.target.dispatchEvent(this.createMouseEvent('mouseover', e)); + this.target.dispatchEvent(this.createMouseEvent('mousemove', e)); + this.target.dispatchEvent(this.createMouseEvent('mousedown', e)); + }, - if (e.synthetic) { - return; - } + fireTouchEvents: function (eventName, originalEvent) { + var events = []; + var gestures = []; - this.mouseIsDown = false; + if (!this.target) { + return; + } - e.preventDefault(); - e.stopPropagation(); + // Convert 'ontouch*' properties and attributes to listeners. + var onEventName = 'on' + eventName; - this.fireTouchEvents('touchend', e); + if (onEventName in this.target) { + console.warn('Converting `' + onEventName + '` property to event listener.', this.target); + this.target.addEventListener(eventName, this.target[onEventName], false); + delete this.target[onEventName]; + } - if (!this.target) { - return; - } + if (this.target.hasAttribute(onEventName)) { + console.warn('Converting `' + onEventName + '` attribute to event listener.', this.target); + var handler = new GLOBAL.Function('event', this.target.getAttribute(onEventName)); + this.target.addEventListener(eventName, handler, false); + this.target.removeAttribute(onEventName); + } - // Mobile Safari moves all the mouse events to fire after the touchend event. - this.target.dispatchEvent(this.createMouseEvent('mouseover', e)); - this.target.dispatchEvent(this.createMouseEvent('mousemove', e)); - this.target.dispatchEvent(this.createMouseEvent('mousedown', e)); - }, + // Set up a new event with the coordinates of the finger. + var touch = this.createMouseEvent(eventName, originalEvent); - fireTouchEvents: function (eventName, originalEvent) { - 'use strict'; + events.push(touch); - var events = []; - var gestures = []; + // Figure out scale and rotation. + if (events.length > 1) { + var x = events[0].pageX - events[1].pageX; + var y = events[0].pageY - events[1].pageY; - if (!this.target) { - return; - } + var distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); + var angle = Math.atan2(x, y) * (180 / Math.PI); - // Convert 'ontouch*' properties and attributes to listeners. - var onEventName = 'on' + eventName; + var gestureName = 'gesturechange'; - if (onEventName in this.target) { - console.warn('Converting `' + onEventName + '` property to event listener.', this.target); - this.target.addEventListener(eventName, this.target[onEventName], false); - delete this.target[onEventName]; - } + if (eventName === 'touchstart') { + gestureName = 'gesturestart'; + this.startDistance = distance; + this.startAngle = angle; + } - if (this.target.hasAttribute(onEventName)) { - console.warn('Converting `' + onEventName + '` attribute to event listener.', this.target); - var handler = new GLOBAL.Function('event', this.target.getAttribute(onEventName)); - this.target.addEventListener(eventName, handler, false); - this.target.removeAttribute(onEventName); - } + if (eventName === 'touchend') { + gestureName = 'gestureend'; + } - // Set up a new event with the coordinates of the finger. - var touch = this.createMouseEvent(eventName, originalEvent); + events.forEach(function(event) { + var gesture = this.createMouseEvent.call(event._finger, gestureName, event); + gestures.push(gesture); + }.bind(this)); - events.push(touch); + events.concat(gestures).forEach(function(event) { + event.scale = distance / this.startDistance; + event.rotation = this.startAngle - angle; + }); + } - // Figure out scale and rotation. - if (events.length > 1) { - var x = events[0].pageX - events[1].pageX; - var y = events[0].pageY - events[1].pageY; + // Loop through the events array and fill in each touch array. + events.forEach(function(touch) { + touch.touches = events.filter(function(e) { + return ~e.type.indexOf('touch') && e.type !== 'touchend'; + }); - var distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); - var angle = Math.atan2(x, y) * (180 / Math.PI); + touch.changedTouches = events.filter(function(e) { + return ~e.type.indexOf('touch') && e._finger.target === touch._finger.target; + }); - var gestureName = 'gesturechange'; + touch.targetTouches = touch.changedTouches.filter(function(e) { + return ~e.type.indexOf('touch') && e.type !== 'touchend'; + }); + }); - if (eventName === 'touchstart') { - gestureName = 'gesturestart'; - this.startDistance = distance; - this.startAngle = angle; - } + // Then fire the events. + events.concat(gestures).forEach(function(event, i) { + event.identifier = i; + event._finger.target.dispatchEvent(event); + }); + }, - if (eventName === 'touchend') { - gestureName = 'gestureend'; - } + createMouseEvent: function (eventName, originalEvent) { + var e = document.createEvent('MouseEvent'); - events.forEach(function(event) { - var gesture = this.createMouseEvent.call(event._finger, gestureName, event); - gestures.push(gesture); - }.bind(this)); + e.initMouseEvent(eventName, true, true, + originalEvent.view, originalEvent.detail, + this.x || originalEvent.screenX, this.y || originalEvent.screenY, + this.x || originalEvent.clientX, this.y || originalEvent.clientY, + originalEvent.ctrlKey, originalEvent.shiftKey, + originalEvent.altKey, originalEvent.metaKey, + originalEvent.button, this.target || originalEvent.relatedTarget + ); - events.concat(gestures).forEach(function(event) { - event.scale = distance / this.startDistance; - event.rotation = this.startAngle - angle; - }); - } + e.synthetic = true; + e._finger = this; - // Loop through the events array and fill in each touch array. - events.forEach(function(touch) { - touch.touches = events.filter(function(e) { - return ~e.type.indexOf('touch') && e.type !== 'touchend'; - }); + return e; + }, - touch.changedTouches = events.filter(function(e) { - return ~e.type.indexOf('touch') && e._finger.target === touch._finger.target; - }); + move: function (x, y) { + if (isNaN(x) || isNaN(y)) { + this.target = null; + } else { + this.x = x; + this.y = y; - touch.targetTouches = touch.changedTouches.filter(function(e) { - return ~e.type.indexOf('touch') && e.type !== 'touchend'; - }); - }); - - // Then fire the events. - events.concat(gestures).forEach(function(event, i) { - event.identifier = i; - event._finger.target.dispatchEvent(event); - }); - }, - - createMouseEvent: function (eventName, originalEvent) { - 'use strict'; - - var e = document.createEvent('MouseEvent'); - - e.initMouseEvent(eventName, true, true, - originalEvent.view, originalEvent.detail, - this.x || originalEvent.screenX, this.y || originalEvent.screenY, - this.x || originalEvent.clientX, this.y || originalEvent.clientY, - originalEvent.ctrlKey, originalEvent.shiftKey, - originalEvent.altKey, originalEvent.metaKey, - originalEvent.button, this.target || originalEvent.relatedTarget - ); - - e.synthetic = true; - e._finger = this; - - return e; - }, - - move: function (x, y) { - 'use strict'; - - if (isNaN(x) || isNaN(y)) { - this.target = null; - } else { - this.x = x; - this.y = y; - - if (!this.mouseIsDown) { - this.target = document.elementFromPoint(x, y); + if (!this.mouseIsDown) { + this.target = document.elementFromPoint(x, y); + } } } - } -}; \ No newline at end of file + }; + + window.FingerBlast = FingerBlast; + +}());