Permalink
Browse files

Make mouse events work in Safari by replacing clientX, clientY, and g…

…etBoundingClientRect with jQuery versions.
  • Loading branch information...
1 parent 3a376ee commit 40a3d12e3be183dfb95932ec63f3e8e0f19f44b3 @gregveen committed Jan 29, 2009
Showing with 3 additions and 23 deletions.
  1. +3 −23 primer.js
View
@@ -32,31 +32,11 @@ Primer.prototype = {
this.setupExt()
var self = this
- // jelc.eq(0).mousemove(function(e) {
- // var bounds
- // console.log('gah')
- // if (e.currentTarget.getBoundingClientRect()) {
- // bounds = e.currentTarget.getBoundingClientRect()
- // } else {
- // bounds = e.currentTarget.offset()
- // }
- // // var bounds = e.currentTarget.getBoundingClientRect()
- // e.localX = e.clientX - bounds.left
- // e.localY = e.clientY - bounds.top
- // console.log(e.localX + ', ' + e.localY)
- // self.ghost(e)
- // })
jelc.eq(0).bind("mousemove", function(e){
- var bounds
- if (e.currentTarget.offsetTop && e.currentTarget.offsetLeft) {
- bounds = { 'top': e.currentTarget.offsetTop, 'left': e.currentTarget.offsetLeft}
- } else {
- bounds = e.currentTarget.getBoundingClientRect()
- }
- e.localX = e.clientX - bounds.left
- e.localY = e.clientY - bounds.top
- console.log(e.localX + ', ' + e.localY)
+ var bounds = $(e.currentTarget).offset()
+ e.localX = e.pageX - bounds.left
+ e.localY = e.pageY - bounds.top
self.ghost(e)
})

0 comments on commit 40a3d12

Please sign in to comment.