mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-30 17:04:20 +08:00
jQuery: JSDoc'd coordinates and added test suite
Added interface to cover coordinates definition.
This commit is contained in:
@@ -1669,6 +1669,21 @@ function test_width() {
|
||||
});
|
||||
}
|
||||
|
||||
function test_coordinates() {
|
||||
var p = $("p:last");
|
||||
var offset = p.offset();
|
||||
p.html("left: " + offset.left + ", top: " + offset.top);
|
||||
|
||||
$("*", document.body).click(function (event) {
|
||||
var offset = $(this).offset();
|
||||
event.stopPropagation();
|
||||
$("#result").text(this.tagName +
|
||||
" coords ( " + offset.left + ", " + offset.top + " )");
|
||||
});
|
||||
|
||||
$("p:last").offset({ top: 10, left: 30 });
|
||||
}
|
||||
|
||||
function test_hide() {
|
||||
$('.target').hide();
|
||||
$('#clickme').click(function () {
|
||||
|
||||
27
jquery/jquery.d.ts
vendored
27
jquery/jquery.d.ts
vendored
@@ -348,6 +348,14 @@ interface JQueryEventConstructor {
|
||||
new (name: string, eventProperties?: any): JQueryEventObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* The interface used to specify coordinates.
|
||||
*/
|
||||
interface JQueryCoordinates {
|
||||
left: number;
|
||||
top: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The interface used to specify easing functions.
|
||||
*/
|
||||
@@ -1023,9 +1031,22 @@ interface JQuery {
|
||||
*/
|
||||
innerWidth(): number;
|
||||
|
||||
offset(): { left: number; top: number; };
|
||||
offset(coordinates: any): JQuery;
|
||||
offset(func: (index: any, coords: any) => any): JQuery;
|
||||
/**
|
||||
* Get the current coordinates of the first element in the set of matched elements, relative to the document.
|
||||
*/
|
||||
offset(): JQueryCoordinates;
|
||||
/**
|
||||
* An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
|
||||
*
|
||||
* @param coordinates An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
|
||||
*/
|
||||
offset(coordinates: JQueryCoordinates): JQuery;
|
||||
/**
|
||||
* An object containing the properties top and left, which are integers indicating the new top and left coordinates for the elements.
|
||||
*
|
||||
* @param func A function to return the coordinates to set. Receives the index of the element in the collection as the first argument and the current coordinates as the second argument. The function should return an object with the new top and left properties.
|
||||
*/
|
||||
offset(func: (index: number, coords: JQueryCoordinates) => JQueryCoordinates): JQuery;
|
||||
|
||||
outerHeight(includeMargin?: boolean): number;
|
||||
outerHeight(value: number, includeMargin?: boolean): JQuery;
|
||||
|
||||
Reference in New Issue
Block a user