From 309077ffb65fd9aa49c25fcfbe0a0c2f7f1699bb Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 9 Apr 2014 13:21:39 -0400 Subject: [PATCH] make a setting for normalizing the offset and check that getBoundingClientRect function exists before trying to call it --- jquery.mousewheel.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jquery.mousewheel.js b/jquery.mousewheel.js index 0a57c3605..ff5d2471c 100755 --- a/jquery.mousewheel.js +++ b/jquery.mousewheel.js @@ -70,7 +70,8 @@ }, settings: { - adjustOldDeltas: true + adjustOldDeltas: true, // see shouldAdjustOldDeltas() below + normalizeOffset: true // calls getBoundingClientRect for each event } }; @@ -166,11 +167,13 @@ delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta); deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta); deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta); - + // Normalise offsetX and offsetY properties - var boundingRect = this.getBoundingClientRect(); - offsetX = event.clientX - boundingRect.left; - offsetY = event.clientY - boundingRect.top; + if ( special.settings.normalizeOffset && this.getBoundingClientRect ) { + var boundingRect = this.getBoundingClientRect(); + offsetX = event.clientX - boundingRect.left; + offsetY = event.clientY - boundingRect.top; + } // Add information to the event object event.deltaX = deltaX;