From 5a64df4bed4414cf07dead40c045020a2718c191 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 20 Mar 2017 00:09:42 -0400 Subject: [PATCH 1/2] Offset: Be more precise about the origins for .offset() and .position() Ref https://github.com/jquery/jquery/pull/3487 --- entries/offset.xml | 6 +++--- entries/position.xml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/entries/offset.xml b/entries/offset.xml index e626ac5a..48cb05c6 100644 --- a/entries/offset.xml +++ b/entries/offset.xml @@ -8,10 +8,10 @@ Get the current coordinates of the first element in the set of matched elements, relative to the document. -

The .offset() method allows us to retrieve the current position of an element relative to the document. Contrast this with .position(), which retrieves the current position relative to the offset parent. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), .offset() is more useful.

+

The .offset() method allows us to retrieve the current position of an element (specifically its border box, which excludes margins) relative to the document. Contrast this with .position(), which retrieves the current position relative to the offset parent. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), .offset() is more useful.

.offset() returns an object containing the properties top and left.

-

Note: jQuery does not support getting the offset coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.

+

Note: jQuery does not support getting the offset coordinates of hidden elements.

While it is possible to get the coordinates of elements with visibility:hidden set, display:none is excluded from the rendering tree and thus has a position that is undefined.

@@ -96,7 +96,7 @@ $( "*", document.body ).click(function( event ) { Set the current coordinates of every element in the set of matched elements, relative to the document. -

The .offset() setter method allows us to reposition an element. The element's position is specified relative to the document. If the element's position style property is currently static, it will be set to relative to allow for this repositioning.

+

The .offset() setter method allows us to reposition an element. The element's border-box position is specified relative to the document. If the element's position style property is currently static, it will be set to relative to allow for this repositioning.

Set the offset of the second paragraph: diff --git a/entries/position.xml b/entries/position.xml index 41bd0fb7..4d59adf1 100644 --- a/entries/position.xml +++ b/entries/position.xml @@ -6,10 +6,10 @@ Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. -

The .position() method allows us to retrieve the current position of an element relative to the offset parent. Contrast this with .offset(), which retrieves the current position relative to the document. When positioning a new element near another one and within the same containing DOM element, .position() is the more useful.

+

The .position() method allows us to retrieve the current position of an element (specifically its margin box) relative to the offset parent (specifically its padding box, which excludes margins and borders). Contrast this with .offset(), which retrieves the current position relative to the document. When positioning a new element near another one and within the same containing DOM element, .position() is the more useful.

Returns an object containing the properties top and left.

-

Note: jQuery does not support getting the position coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.

+

Note: jQuery does not support getting the position coordinates of hidden elements.

From db722f69b2f5ddcc98ee3498f701927211c2b3a3 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 20 Mar 2017 10:02:48 -0400 Subject: [PATCH 2/2] Offset: Restore a warning for the IE<11 failing case --- entries/offset.xml | 2 +- entries/position.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/entries/offset.xml b/entries/offset.xml index 48cb05c6..9a588ca2 100644 --- a/entries/offset.xml +++ b/entries/offset.xml @@ -11,7 +11,7 @@

The .offset() method allows us to retrieve the current position of an element (specifically its border box, which excludes margins) relative to the document. Contrast this with .position(), which retrieves the current position relative to the offset parent. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), .offset() is more useful.

.offset() returns an object containing the properties top and left.

-

Note: jQuery does not support getting the offset coordinates of hidden elements.

+

Note: jQuery does not support getting the offset coordinates of hidden elements or accounting for margins set on the <html> document element.

While it is possible to get the coordinates of elements with visibility:hidden set, display:none is excluded from the rendering tree and thus has a position that is undefined.

diff --git a/entries/position.xml b/entries/position.xml index 4d59adf1..3eed46b4 100644 --- a/entries/position.xml +++ b/entries/position.xml @@ -9,7 +9,7 @@

The .position() method allows us to retrieve the current position of an element (specifically its margin box) relative to the offset parent (specifically its padding box, which excludes margins and borders). Contrast this with .offset(), which retrieves the current position relative to the document. When positioning a new element near another one and within the same containing DOM element, .position() is the more useful.

Returns an object containing the properties top and left.

-

Note: jQuery does not support getting the position coordinates of hidden elements.

+

Note: jQuery does not support getting the position coordinates of hidden elements or accounting for margins set on the <html> document element.