aboutsummaryrefslogtreecommitdiffstats
path: root/src/offset.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/offset.js')
-rw-r--r--src/offset.js43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/offset.js b/src/offset.js
index cfc260da2..d73166a99 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -1,13 +1,18 @@
-define([
- "./core",
- "./var/strundefined",
- "./core/access",
- "./core/init",
- "./css",
- "./selector" // contains
-], function( jQuery, strundefined, access ) {
-
-var docElem = window.document.documentElement;
+define(function( require ) {
+
+var
+ jQuery = require( "./core" ),
+ strundefined = require( "./var/strundefined" ),
+ access = require( "./core/access" ),
+ rnumnonpx = require( "./css/var/rnumnonpx" ),
+ curCSS = require( "./css/curCSS" ).curCSS,
+ addGetHookIf = require( "./css/addGetHookIf" ),
+ support = require( "./css/support" ),
+ docElem = window.document.documentElement;
+
+require( "./core/init" );
+require( "./css" );
+require( "./selector" ); // contains
/**
* Gets a window from an element
@@ -181,5 +186,23 @@ jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( me
};
});
+// Add the top/left cssHooks using jQuery.fn.position
+// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
+// getComputedStyle returns percent when specified for top/left/bottom/right
+// rather than make the css module depend on the offset module, we just check for it here
+jQuery.each( [ "top", "left" ], function( i, prop ) {
+ addGetHookIf( jQuery.cssHooks[ prop ], support.pixelPosition,
+ function ( elem, computed ) {
+ if ( computed ) {
+ computed = curCSS( elem, prop );
+ // if curCSS returns percentage, fallback to offset
+ return rnumnonpx.test( computed ) ?
+ jQuery( elem ).position()[ prop ] + "px" :
+ computed;
+ }
+ }
+ );
+});
+
return jQuery;
});