Skip to content

Commit

Permalink
Add workaround for absence of getBoundingClientRect support.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregveen committed Jan 19, 2009
1 parent 4b81607 commit 3a376ee
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions primer.js
Expand Up @@ -32,12 +32,34 @@ Primer.prototype = {
this.setupExt()

var self = this
jelc.eq(0).mousemove(function(e) {
var bounds = e.currentTarget.getBoundingClientRect()
// 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)
self.ghost(e)
})

},

get primer() {
Expand Down

0 comments on commit 3a376ee

Please sign in to comment.