Skip to content

Commit

Permalink
Merge pull request #12 from thelucre/master
Browse files Browse the repository at this point in the history
support touchstart/touchend with domevents & linkify
  • Loading branch information
jeromeetienne committed Apr 7, 2016
2 parents f27ec92 + d5e5b28 commit 1100828
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions threex.domevents.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ THREEx.DomEvents.eventNames = [
"mousemove",
"mousedown",
"mouseup",
"contextmenu"
"contextmenu",
"touchstart",
"touchend"
];

THREEx.DomEvents.prototype._getRelativeMouseXY = function(domEvent){
Expand Down Expand Up @@ -420,8 +422,8 @@ THREEx.DomEvents.prototype._onContextmenu = function(event)
// # handle touch events


THREEx.DomEvents.prototype._onTouchStart = function(event){ return this._onTouchEvent('mousedown', event); }
THREEx.DomEvents.prototype._onTouchEnd = function(event){ return this._onTouchEvent('mouseup' , event); }
THREEx.DomEvents.prototype._onTouchStart = function(event){ return this._onTouchEvent('touchstart', event); }
THREEx.DomEvents.prototype._onTouchEnd = function(event){ return this._onTouchEvent('touchend' , event); }

THREEx.DomEvents.prototype._onTouchMove = function(domEvent)
{
Expand Down
6 changes: 5 additions & 1 deletion threex.linkify.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ THREEx.Linkify = function(domEvents, mesh, url, withBoundingBox){
domEvents.bind(eventTarget, 'click', function(event){
window.open(url, '_blank');
})

domEvents.bind(eventTarget, 'touchend', function(event){
window.open(url, '_blank');
})

// bind 'mouseover'
domEvents.bind(eventTarget, 'mouseover', function(event){
Expand All @@ -56,4 +60,4 @@ THREEx.Linkify = function(domEvents, mesh, url, withBoundingBox){
this.destroy = function(){
console.log('not yet implemented')
}
}
}

0 comments on commit 1100828

Please sign in to comment.