Skip to content

Commit 1273760

Browse files
authored
🤖 Merge PR DefinitelyTyped#72074 jqueryui: Add typings for $.fn.transfer by @blutorange
1 parent 487a8ba commit 1273760

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

types/jqueryui/index.d.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,30 @@ declare namespace JQueryUI {
10301030
within?: any;
10311031
}
10321032

1033+
/**
1034+
* Options for the {@link JQuery.transfer | transfer} method.
1035+
*/
1036+
interface TransferOptions {
1037+
/**
1038+
* The target of the transfer effect.
1039+
*/
1040+
to: string | Element | ArrayLike<Element>;
1041+
/**
1042+
* A class to add to the transfer element, in addition to `ui-effects-transfer`.
1043+
*/
1044+
className?: string | null;
1045+
/**
1046+
* A string or number determining how long the animation will run. The strings "fast" and "slow" can be supplied to indicate durations of 200 and 600 milliseconds, respectively. The number type indicates the duration in milliseconds.
1047+
* @default 400
1048+
*/
1049+
duration?: string | number;
1050+
/**
1051+
* A string indicating which easing function to use for the transition.
1052+
* @default "swing"
1053+
*/
1054+
easing?: string;
1055+
}
1056+
10331057
// UI //////////////////////////////////////////////////
10341058

10351059
interface MouseOptions {
@@ -1984,6 +2008,22 @@ interface JQuery {
19842008

19852009
position(options: JQueryUI.JQueryPositionOptions): JQuery;
19862010

2011+
/**
2012+
* Transfers the outline of an element to another element.
2013+
*
2014+
* Very useful when trying to visualize interaction between two elements.
2015+
*
2016+
* The transfer element itself has the class ui-effects-transfer, and needs to be styled by you, for example by
2017+
* adding a background or border.
2018+
*
2019+
* See https://api.jqueryui.com/transfer/
2020+
*
2021+
* @param options Options for the transfer operation.
2022+
* @param complete A function to call once the animation is complete, called once per matched element.
2023+
* @returns This JQuery instance for chaining method calls.
2024+
*/
2025+
transfer(options: JQueryUI.TransferOptions, complete?: () => void): this;
2026+
19872027
enableSelection(): JQuery;
19882028
disableSelection(): JQuery;
19892029
focus(delay: number, callback?: Function): JQuery;

types/jqueryui/jqueryui-tests.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,15 @@ function test_effects() {
19401940
$(this).switchClass("big", "blue", 1000, "easeInOutQuad");
19411941
$(this).toggleClass("big-blue", 1000, "easeOutSine");
19421942

1943+
$("#effect").transfer({ to: "#target" });
1944+
$("#effect").transfer({ to: document.createElement("div") });
1945+
$("#effect").transfer({ to: $("#target") });
1946+
$("#effect").transfer({ to: "#target", className: "class" });
1947+
$("#effect").transfer({ to: "#target", duration: "fast" });
1948+
$("#effect").transfer({ to: "#target", duration: 900 });
1949+
$("#effect").transfer({ to: "#target", easing: "fade" });
1950+
$("#effect").transfer({ to: "#target" }, () => {});
1951+
19431952
// test with non-HTMLElement
19441953
var $svg: JQuery<SVGElement> = <unknown> $("<svg>") as JQuery<SVGSVGElement>,
19451954
$ret: JQuery<SVGElement>;
@@ -1951,6 +1960,8 @@ function test_effects() {
19511960
$ret = $svg.toggle(selectedEffect, options, 500);
19521961
$ret = $svg.toggleClass("newClass", 1000);
19531962
$ret = $svg.switchClass("big", "blue", 1000, "easeInOutQuad");
1963+
1964+
$ret = $svg.transfer({ to: $svg });
19541965
}
19551966

19561967
function test_methods() {

0 commit comments

Comments
 (0)