forked from think2011/collision-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collisionChecker.min.js
1 lines (1 loc) · 1.04 KB
/
collisionChecker.min.js
1
(function(t,e){if(typeof define==="function"&&define.amd){define([],e)}else if(typeof exports==="object"){module.exports=e()}else{t.collisionChecker=e()}})(this,function(){function t(e,n){var o=n instanceof Element?"node":"event";var i=e.getBoundingClientRect();var c={node:function(){var t=n.getBoundingClientRect();var e=!(t.bottom<i.top||t.left>i.right||t.top>i.bottom||t.right<i.left);return{hit:e,top:e&&t.top<=i.top,right:e&&t.right>=i.right,bottom:e&&t.top>=i.top,left:e&&t.left<=i.left}},event:function(){var e=t.getEventInfo(window.event);var n=!(e.clientY<i.top||e.clientX>i.right||e.clientY>i.bottom||e.clientX<i.left);return{hit:n,top:n&&e.clientY<=i.top+i.height/2,right:n&&e.clientX>=i.left+i.width/2,bottom:n&&e.clientY>=i.top+i.height/2,left:n&&e.clientX<=i.left+i.width/2}}};return c[o]()}t.getEventInfo=function(e){return t.isTouch()?e.targetTouches[0]:e};t.isTouch=function(t){return"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch||navigator.maxTouchPoints>0||window.navigator.msMaxTouchPoints>0};return t});