@react-stately/virtualizer 3.7.2-nightly.4647 → 3.7.2-nightly.4654
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Layout.main.js +2 -41
- package/dist/Layout.main.js.map +1 -1
- package/dist/Layout.mjs +2 -41
- package/dist/Layout.module.js +2 -41
- package/dist/Layout.module.js.map +1 -1
- package/dist/LayoutInfo.main.js.map +1 -1
- package/dist/LayoutInfo.module.js.map +1 -1
- package/dist/OverscanManager.main.js +8 -43
- package/dist/OverscanManager.main.js.map +1 -1
- package/dist/OverscanManager.mjs +8 -43
- package/dist/OverscanManager.module.js +8 -43
- package/dist/OverscanManager.module.js.map +1 -1
- package/dist/ReusableView.main.js +23 -0
- package/dist/ReusableView.main.js.map +1 -1
- package/dist/ReusableView.mjs +23 -0
- package/dist/ReusableView.module.js +23 -0
- package/dist/ReusableView.module.js.map +1 -1
- package/dist/Virtualizer.main.js +123 -710
- package/dist/Virtualizer.main.js.map +1 -1
- package/dist/Virtualizer.mjs +124 -711
- package/dist/Virtualizer.module.js +124 -711
- package/dist/Virtualizer.module.js.map +1 -1
- package/dist/types.d.ts +64 -225
- package/dist/types.d.ts.map +1 -1
- package/dist/useVirtualizerState.main.js +39 -40
- package/dist/useVirtualizerState.main.js.map +1 -1
- package/dist/useVirtualizerState.mjs +40 -41
- package/dist/useVirtualizerState.module.js +40 -41
- package/dist/useVirtualizerState.module.js.map +1 -1
- package/dist/utils.main.js +1 -27
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.mjs +2 -26
- package/dist/utils.module.js +2 -26
- package/dist/utils.module.js.map +1 -1
- package/package.json +4 -4
- package/src/Layout.ts +10 -55
- package/src/LayoutInfo.ts +2 -2
- package/src/OverscanManager.ts +10 -47
- package/src/ReusableView.ts +36 -7
- package/src/Virtualizer.ts +163 -1058
- package/src/types.ts +16 -38
- package/src/useVirtualizerState.ts +40 -39
- package/src/utils.ts +0 -52
- package/dist/Transaction.main.js +0 -32
- package/dist/Transaction.main.js.map +0 -1
- package/dist/Transaction.mjs +0 -27
- package/dist/Transaction.module.js +0 -27
- package/dist/Transaction.module.js.map +0 -1
- package/dist/tween.main.js +0 -67
- package/dist/tween.main.js.map +0 -1
- package/dist/tween.mjs +0 -61
- package/dist/tween.module.js +0 -61
- package/dist/tween.module.js.map +0 -1
- package/src/Transaction.ts +0 -28
- package/src/tween.ts +0 -83
package/src/types.ts
CHANGED
|
@@ -12,28 +12,19 @@
|
|
|
12
12
|
|
|
13
13
|
import {Collection, Key} from '@react-types/shared';
|
|
14
14
|
import {Layout} from './Layout';
|
|
15
|
-
import {
|
|
16
|
-
import {Rect, RectCorner} from './Rect';
|
|
15
|
+
import {Rect} from './Rect';
|
|
17
16
|
import {ReusableView} from './ReusableView';
|
|
18
|
-
import {Size} from './Size';
|
|
19
|
-
import {Transaction} from './Transaction';
|
|
20
17
|
|
|
21
|
-
export interface InvalidationContext<
|
|
18
|
+
export interface InvalidationContext<O = any> {
|
|
22
19
|
contentChanged?: boolean,
|
|
23
20
|
offsetChanged?: boolean,
|
|
24
21
|
sizeChanged?: boolean,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
afterLayout?(): void,
|
|
28
|
-
afterAnimation?(): void,
|
|
29
|
-
transaction?: Transaction<T, V>
|
|
22
|
+
itemSizeChanged?: boolean,
|
|
23
|
+
layoutOptions?: O
|
|
30
24
|
}
|
|
31
25
|
|
|
32
26
|
export interface VirtualizerDelegate<T extends object, V, W> {
|
|
33
|
-
setVisibleViews(views: W[]): void,
|
|
34
|
-
setContentSize(size: Size): void,
|
|
35
27
|
setVisibleRect(rect: Rect): void,
|
|
36
|
-
getType?(content: T): string,
|
|
37
28
|
renderView(type: string, content: T): V,
|
|
38
29
|
renderWrapper(
|
|
39
30
|
parent: ReusableView<T, V> | null,
|
|
@@ -41,32 +32,19 @@ export interface VirtualizerDelegate<T extends object, V, W> {
|
|
|
41
32
|
children: ReusableView<T, V>[],
|
|
42
33
|
renderChildren: (views: ReusableView<T, V>[]) => W[]
|
|
43
34
|
): W,
|
|
44
|
-
|
|
45
|
-
endAnimations(): void,
|
|
46
|
-
getScrollAnchor?(rect: Rect): Key
|
|
35
|
+
invalidate(ctx: InvalidationContext): void
|
|
47
36
|
}
|
|
48
37
|
|
|
49
|
-
export interface
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
export interface VirtualizerRenderOptions<T extends object, O = any> {
|
|
39
|
+
layout: Layout<T>,
|
|
40
|
+
collection: Collection<T>,
|
|
41
|
+
persistedKeys?: Set<Key>,
|
|
42
|
+
visibleRect: Rect,
|
|
43
|
+
invalidationContext: InvalidationContext,
|
|
44
|
+
isScrolling: boolean,
|
|
45
|
+
layoutOptions?: O
|
|
54
46
|
}
|
|
55
47
|
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
shouldScrollY?: boolean,
|
|
60
|
-
offsetX?: number,
|
|
61
|
-
offsetY?: number
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface VirtualizerOptions<T extends object, V, W> {
|
|
65
|
-
collection?: Collection<T>,
|
|
66
|
-
layout?: Layout<T>,
|
|
67
|
-
delegate?: VirtualizerDelegate<T, V, W>,
|
|
68
|
-
transitionDuration?: number,
|
|
69
|
-
anchorScrollPosition?: boolean,
|
|
70
|
-
anchorScrollPositionAtTop?: boolean,
|
|
71
|
-
shouldOverscan?: boolean
|
|
72
|
-
}
|
|
48
|
+
export type Mutable<T> = {
|
|
49
|
+
-readonly[P in keyof T]: T[P]
|
|
50
|
+
};
|
|
@@ -11,15 +11,16 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {Collection, Key} from '@react-types/shared';
|
|
14
|
+
import {InvalidationContext} from './types';
|
|
14
15
|
import {Layout} from './Layout';
|
|
15
16
|
import {Rect} from './Rect';
|
|
16
17
|
import {ReusableView} from './ReusableView';
|
|
17
18
|
import {Size} from './Size';
|
|
18
|
-
import {useCallback,
|
|
19
|
+
import {useCallback, useMemo, useRef, useState} from 'react';
|
|
19
20
|
import {useLayoutEffect} from '@react-aria/utils';
|
|
20
21
|
import {Virtualizer} from './Virtualizer';
|
|
21
22
|
|
|
22
|
-
interface VirtualizerProps<T extends object, V, W> {
|
|
23
|
+
interface VirtualizerProps<T extends object, V, W, O> {
|
|
23
24
|
renderView(type: string, content: T): V,
|
|
24
25
|
renderWrapper(
|
|
25
26
|
parent: ReusableView<T, V> | null,
|
|
@@ -30,74 +31,75 @@ interface VirtualizerProps<T extends object, V, W> {
|
|
|
30
31
|
layout: Layout<T>,
|
|
31
32
|
collection: Collection<T>,
|
|
32
33
|
onVisibleRectChange(rect: Rect): void,
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
persistedKeys?: Set<Key>,
|
|
35
|
+
layoutOptions?: O
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export interface VirtualizerState<T extends object, V, W> {
|
|
38
39
|
visibleViews: W[],
|
|
39
40
|
setVisibleRect: (rect: Rect) => void,
|
|
40
41
|
contentSize: Size,
|
|
41
|
-
isAnimating: boolean,
|
|
42
42
|
virtualizer: Virtualizer<T, V, W>,
|
|
43
43
|
isScrolling: boolean,
|
|
44
44
|
startScrolling: () => void,
|
|
45
45
|
endScrolling: () => void
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export function useVirtualizerState<T extends object, V, W>(opts: VirtualizerProps<T, V, W>): VirtualizerState<T, V, W> {
|
|
49
|
-
let [
|
|
50
|
-
let [contentSize, setContentSize] = useState(new Size());
|
|
51
|
-
let [isAnimating, setAnimating] = useState(false);
|
|
48
|
+
export function useVirtualizerState<T extends object, V, W, O = any>(opts: VirtualizerProps<T, V, W, O>): VirtualizerState<T, V, W> {
|
|
49
|
+
let [visibleRect, setVisibleRect] = useState(new Rect(0, 0, 0, 0));
|
|
52
50
|
let [isScrolling, setScrolling] = useState(false);
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
virtualizer
|
|
56
|
-
setVisibleViews,
|
|
51
|
+
let [invalidationContext, setInvalidationContext] = useState<InvalidationContext>({});
|
|
52
|
+
let visibleRectChanged = useRef(false);
|
|
53
|
+
let [virtualizer] = useState(() => new Virtualizer<T, V, W>({
|
|
57
54
|
setVisibleRect(rect) {
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
setVisibleRect(rect);
|
|
56
|
+
visibleRectChanged.current = true;
|
|
60
57
|
},
|
|
61
|
-
|
|
58
|
+
// TODO: should changing these invalidate the entire cache?
|
|
62
59
|
renderView: opts.renderView,
|
|
63
60
|
renderWrapper: opts.renderWrapper,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
getScrollAnchor: opts.getScrollAnchor
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
virtualizer.layout = opts.layout;
|
|
70
|
-
virtualizer.collection = opts.collection;
|
|
71
|
-
virtualizer.transitionDuration = opts.transitionDuration;
|
|
61
|
+
invalidate: setInvalidationContext
|
|
62
|
+
}));
|
|
72
63
|
|
|
64
|
+
// onVisibleRectChange must be called from an effect, not during render.
|
|
73
65
|
useLayoutEffect(() => {
|
|
74
|
-
|
|
66
|
+
if (visibleRectChanged.current) {
|
|
67
|
+
visibleRectChanged.current = false;
|
|
68
|
+
opts.onVisibleRectChange(visibleRect);
|
|
69
|
+
}
|
|
75
70
|
});
|
|
76
71
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
let mergedInvalidationContext = useMemo(() => {
|
|
73
|
+
if (opts.layoutOptions != null) {
|
|
74
|
+
return {...invalidationContext, layoutOptions: opts.layoutOptions};
|
|
75
|
+
}
|
|
76
|
+
return invalidationContext;
|
|
77
|
+
}, [invalidationContext, opts.layoutOptions]);
|
|
78
|
+
|
|
79
|
+
let visibleViews = virtualizer.render({
|
|
80
|
+
layout: opts.layout,
|
|
81
|
+
collection: opts.collection,
|
|
82
|
+
persistedKeys: opts.persistedKeys,
|
|
83
|
+
layoutOptions: opts.layoutOptions,
|
|
84
|
+
visibleRect,
|
|
85
|
+
invalidationContext: mergedInvalidationContext,
|
|
86
|
+
isScrolling
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
let contentSize = virtualizer.contentSize;
|
|
82
90
|
|
|
83
|
-
let setVisibleRect = useCallback((rect) => {
|
|
84
|
-
virtualizer.visibleRect = rect;
|
|
85
|
-
}, [virtualizer]);
|
|
86
91
|
let startScrolling = useCallback(() => {
|
|
87
|
-
virtualizer.startScrolling();
|
|
88
92
|
setScrolling(true);
|
|
89
|
-
}, [
|
|
93
|
+
}, []);
|
|
90
94
|
let endScrolling = useCallback(() => {
|
|
91
|
-
virtualizer.endScrolling();
|
|
92
95
|
setScrolling(false);
|
|
93
|
-
}, [
|
|
96
|
+
}, []);
|
|
94
97
|
|
|
95
98
|
let state = useMemo(() => ({
|
|
96
99
|
virtualizer,
|
|
97
100
|
visibleViews,
|
|
98
101
|
setVisibleRect,
|
|
99
102
|
contentSize,
|
|
100
|
-
isAnimating,
|
|
101
103
|
isScrolling,
|
|
102
104
|
startScrolling,
|
|
103
105
|
endScrolling
|
|
@@ -106,7 +108,6 @@ export function useVirtualizerState<T extends object, V, W>(opts: VirtualizerPro
|
|
|
106
108
|
visibleViews,
|
|
107
109
|
setVisibleRect,
|
|
108
110
|
contentSize,
|
|
109
|
-
isAnimating,
|
|
110
111
|
isScrolling,
|
|
111
112
|
startScrolling,
|
|
112
113
|
endScrolling
|
package/src/utils.ts
CHANGED
|
@@ -10,58 +10,6 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export function keyDiff<T>(a: Map<T, any>, b: Map<T, any>): Set<T> {
|
|
14
|
-
let res = new Set<T>();
|
|
15
|
-
|
|
16
|
-
for (let key of a.keys()) {
|
|
17
|
-
if (!b.has(key)) {
|
|
18
|
-
res.add(key);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return res;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Returns the key difference between two maps. Returns a set of
|
|
27
|
-
* keys to add to and remove from a to make it equal to b.
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
export function difference<T>(a: Map<T, any>, b: Map<T, any>) {
|
|
31
|
-
let toRemove = keyDiff(a, b);
|
|
32
|
-
let toAdd = keyDiff(b, a);
|
|
33
|
-
let toUpdate = new Set;
|
|
34
|
-
for (let key of a.keys()) {
|
|
35
|
-
if (b.has(key)) {
|
|
36
|
-
toUpdate.add(key);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return {toRemove, toAdd, toUpdate};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Returns an iterator that yields the items in all of the given iterators.
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
export function* concatIterators<T>(...iterators: Iterable<T>[]) {
|
|
47
|
-
for (let iterator of iterators) {
|
|
48
|
-
yield* iterator;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Inverts the keys and values of an object.
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
export function invert(object) {
|
|
57
|
-
let res = {};
|
|
58
|
-
for (let key in object) {
|
|
59
|
-
res[object[key]] = key;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return res;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
13
|
/** Returns whether two sets are equal. */
|
|
66
14
|
export function isSetEqual<T>(a: Set<T>, b: Set<T>): boolean {
|
|
67
15
|
if (a === b) {
|
package/dist/Transaction.main.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function $parcel$export(e, n, v, s) {
|
|
3
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
$parcel$export(module.exports, "Transaction", () => $d288159e8347722a$export$febc5573c75cefb0);
|
|
7
|
-
/*
|
|
8
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
-
* governing permissions and limitations under the License.
|
|
17
|
-
*/ class $d288159e8347722a$export$febc5573c75cefb0 {
|
|
18
|
-
constructor(){
|
|
19
|
-
this.level = 0;
|
|
20
|
-
this.actions = [];
|
|
21
|
-
this.animated = true;
|
|
22
|
-
this.initialMap = new Map();
|
|
23
|
-
this.finalMap = new Map();
|
|
24
|
-
this.initialLayoutInfo = new Map();
|
|
25
|
-
this.finalLayoutInfo = new Map();
|
|
26
|
-
this.removed = new Map();
|
|
27
|
-
this.toRemove = new Map();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=Transaction.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAOM,MAAM;;aACX,QAAQ;aACR,UAA0B,EAAE;aAC5B,WAAW;aACX,aAA4B,IAAI;aAChC,WAA0B,IAAI;aAC9B,oBAAmC,IAAI;aACvC,kBAAiC,IAAI;aACrC,UAAwC,IAAI;aAC5C,WAAyC,IAAI;;AAC/C","sources":["packages/@react-stately/virtualizer/src/Transaction.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {ReusableView} from './ReusableView';\n\ntype LayoutInfoMap = Map<Key, LayoutInfo>;\nexport class Transaction<T extends object, V> {\n level = 0;\n actions: (() => void)[] = [];\n animated = true;\n initialMap: LayoutInfoMap = new Map();\n finalMap: LayoutInfoMap = new Map();\n initialLayoutInfo: LayoutInfoMap = new Map();\n finalLayoutInfo: LayoutInfoMap = new Map();\n removed: Map<Key, ReusableView<T, V>> = new Map();\n toRemove: Map<Key, ReusableView<T, V>> = new Map();\n}\n"],"names":[],"version":3,"file":"Transaction.main.js.map"}
|
package/dist/Transaction.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/ class $8e135e531d8dcb66$export$febc5573c75cefb0 {
|
|
12
|
-
constructor(){
|
|
13
|
-
this.level = 0;
|
|
14
|
-
this.actions = [];
|
|
15
|
-
this.animated = true;
|
|
16
|
-
this.initialMap = new Map();
|
|
17
|
-
this.finalMap = new Map();
|
|
18
|
-
this.initialLayoutInfo = new Map();
|
|
19
|
-
this.finalLayoutInfo = new Map();
|
|
20
|
-
this.removed = new Map();
|
|
21
|
-
this.toRemove = new Map();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export {$8e135e531d8dcb66$export$febc5573c75cefb0 as Transaction};
|
|
27
|
-
//# sourceMappingURL=Transaction.module.js.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/ class $8e135e531d8dcb66$export$febc5573c75cefb0 {
|
|
12
|
-
constructor(){
|
|
13
|
-
this.level = 0;
|
|
14
|
-
this.actions = [];
|
|
15
|
-
this.animated = true;
|
|
16
|
-
this.initialMap = new Map();
|
|
17
|
-
this.finalMap = new Map();
|
|
18
|
-
this.initialLayoutInfo = new Map();
|
|
19
|
-
this.finalLayoutInfo = new Map();
|
|
20
|
-
this.removed = new Map();
|
|
21
|
-
this.toRemove = new Map();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export {$8e135e531d8dcb66$export$febc5573c75cefb0 as Transaction};
|
|
27
|
-
//# sourceMappingURL=Transaction.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAOM,MAAM;;aACX,QAAQ;aACR,UAA0B,EAAE;aAC5B,WAAW;aACX,aAA4B,IAAI;aAChC,WAA0B,IAAI;aAC9B,oBAAmC,IAAI;aACvC,kBAAiC,IAAI;aACrC,UAAwC,IAAI;aAC5C,WAAyC,IAAI;;AAC/C","sources":["packages/@react-stately/virtualizer/src/Transaction.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from '@react-types/shared';\nimport {LayoutInfo} from './LayoutInfo';\nimport {ReusableView} from './ReusableView';\n\ntype LayoutInfoMap = Map<Key, LayoutInfo>;\nexport class Transaction<T extends object, V> {\n level = 0;\n actions: (() => void)[] = [];\n animated = true;\n initialMap: LayoutInfoMap = new Map();\n finalMap: LayoutInfoMap = new Map();\n initialLayoutInfo: LayoutInfoMap = new Map();\n finalLayoutInfo: LayoutInfoMap = new Map();\n removed: Map<Key, ReusableView<T, V>> = new Map();\n toRemove: Map<Key, ReusableView<T, V>> = new Map();\n}\n"],"names":[],"version":3,"file":"Transaction.module.js.map"}
|
package/dist/tween.main.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
var $f89f15d7f52bce29$exports = require("./Point.main.js");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function $parcel$export(e, n, v, s) {
|
|
5
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
$parcel$export(module.exports, "tween", () => $57c5d36217e1f286$export$dc0b63720788090c);
|
|
9
|
-
$parcel$export(module.exports, "easeOut", () => $57c5d36217e1f286$export$57636bb43b1ccbb0);
|
|
10
|
-
/*
|
|
11
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
-
* governing permissions and limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
// use high res timer if available
|
|
22
|
-
let $57c5d36217e1f286$var$perf = typeof window !== 'undefined' ? window.performance : null;
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
let $57c5d36217e1f286$var$perfNow = $57c5d36217e1f286$var$perf && ($57c5d36217e1f286$var$perf.now || $57c5d36217e1f286$var$perf.webkitNow || $57c5d36217e1f286$var$perf.msNow || $57c5d36217e1f286$var$perf.mozNow);
|
|
25
|
-
let $57c5d36217e1f286$var$getTime = $57c5d36217e1f286$var$perfNow ? $57c5d36217e1f286$var$perfNow.bind($57c5d36217e1f286$var$perf) : function() {
|
|
26
|
-
return Date.now ? Date.now() : new Date().getTime();
|
|
27
|
-
};
|
|
28
|
-
let $57c5d36217e1f286$var$fixTs;
|
|
29
|
-
function $57c5d36217e1f286$export$dc0b63720788090c(begin, end, duration, ease, fn) {
|
|
30
|
-
let canceled = false;
|
|
31
|
-
let raf_id;
|
|
32
|
-
let promise = new Promise((resolve)=>{
|
|
33
|
-
let start = $57c5d36217e1f286$var$getTime();
|
|
34
|
-
let diffX = end.x - begin.x;
|
|
35
|
-
let diffY = end.y - begin.y;
|
|
36
|
-
raf_id = requestAnimationFrame(function run(t) {
|
|
37
|
-
// if we're using a high res timer, make sure timestamp is not the old epoch-based value.
|
|
38
|
-
// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
|
|
39
|
-
if ($57c5d36217e1f286$var$fixTs == null) $57c5d36217e1f286$var$fixTs = t > 1e12 !== $57c5d36217e1f286$var$getTime() > 1e12;
|
|
40
|
-
if ($57c5d36217e1f286$var$fixTs) t = $57c5d36217e1f286$var$getTime();
|
|
41
|
-
// check if we're done
|
|
42
|
-
let delta = t - start;
|
|
43
|
-
if (delta > duration) {
|
|
44
|
-
fn(end);
|
|
45
|
-
resolve();
|
|
46
|
-
} else {
|
|
47
|
-
// call frame callback after computing eased time and get the next frame
|
|
48
|
-
let proceed = fn(new (0, $f89f15d7f52bce29$exports.Point)(begin.x + diffX * ease(delta / duration), begin.y + diffY * ease(delta / duration)));
|
|
49
|
-
if (proceed !== false && !canceled) raf_id = requestAnimationFrame(run);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
promise.cancel = function() {
|
|
54
|
-
canceled = true;
|
|
55
|
-
cancelAnimationFrame(raf_id);
|
|
56
|
-
};
|
|
57
|
-
return promise;
|
|
58
|
-
}
|
|
59
|
-
function $57c5d36217e1f286$export$77860c106b4a6a2e(t) {
|
|
60
|
-
return t;
|
|
61
|
-
}
|
|
62
|
-
function $57c5d36217e1f286$export$57636bb43b1ccbb0(t) {
|
|
63
|
-
return Math.sin(t * Math.PI / 2);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
//# sourceMappingURL=tween.main.js.map
|
package/dist/tween.main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;AAID,kCAAkC;AAClC,IAAI,6BAAO,OAAO,WAAW,cAAc,OAAO,WAAW,GAAG;AAChE,aAAa;AACb,IAAI,gCAAU,8BAAS,CAAA,2BAAK,GAAG,IAAI,2BAAK,SAAS,IAAI,2BAAK,KAAK,IAAI,2BAAK,MAAM,AAAD;AAC7E,IAAI,gCAAU,gCAAU,8BAAQ,IAAI,CAAC,8BAAQ;IAC3C,OAAO,KAAK,GAAG,GAAG,KAAK,GAAG,KAAK,IAAI,OAAO,OAAO;AACnD;AAEA,IAAI;AAMG,SAAS,0CAAM,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IAClD,IAAI,WAAW;IACf,IAAI;IAEJ,IAAI,UAAU,IAAI,QAAQ,CAAA;QACxB,IAAI,QAAQ;QACZ,IAAI,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;QAC3B,IAAI,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;QAE3B,SAAS,sBAAsB,SAAS,IAAI,CAAC;YAC3C,yFAAyF;YACzF,qGAAqG;YACrG,IAAI,+BAAS,MACX,8BAAQ,IAAI,SAAS,kCAAY;YAGnC,IAAI,6BACF,IAAI;YAGN,sBAAsB;YACtB,IAAI,QAAQ,IAAI;YAChB,IAAI,QAAQ,UAAU;gBACpB,GAAG;gBACH;YACF,OAAO;gBACL,wEAAwE;gBACxE,IAAI,UAAU,GAAG,IAAI,CAAA,GAAA,+BAAI,EACvB,MAAM,CAAC,GAAG,QAAQ,KAAK,QAAQ,WAC/B,MAAM,CAAC,GAAG,QAAQ,KAAK,QAAQ;gBAGjC,IAAI,YAAY,SAAS,CAAC,UACxB,SAAS,sBAAsB;YAEnC;QACF;IACF;IAEA,QAAQ,MAAM,GAAG;QACf,WAAW;QACX,qBAAqB;IACvB;IAEA,OAAO;AACT;AAGO,SAAS,0CAAa,CAAC;IAC5B,OAAO;AACT;AAEO,SAAS,0CAAQ,CAAC;IACvB,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,EAAE,GAAG;AAChC","sources":["packages/@react-stately/virtualizer/src/tween.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Point} from './Point';\n\n// use high res timer if available\nlet perf = typeof window !== 'undefined' ? window.performance : null;\n// @ts-ignore\nlet perfNow = perf && (perf.now || perf.webkitNow || perf.msNow || perf.mozNow);\nlet getTime = perfNow ? perfNow.bind(perf) : function () {\n return Date.now ? Date.now() : new Date().getTime();\n};\n\nlet fixTs: boolean;\n\nexport interface CancelablePromise<T> extends Promise<T> {\n cancel(): void\n}\n\nexport function tween(begin, end, duration, ease, fn): CancelablePromise<void> {\n let canceled = false;\n let raf_id: number;\n\n let promise = new Promise(resolve => {\n let start = getTime();\n let diffX = end.x - begin.x;\n let diffY = end.y - begin.y;\n\n raf_id = requestAnimationFrame(function run(t) {\n // if we're using a high res timer, make sure timestamp is not the old epoch-based value.\n // http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision\n if (fixTs == null) {\n fixTs = t > 1e12 !== getTime() > 1e12;\n }\n\n if (fixTs) {\n t = getTime();\n }\n\n // check if we're done\n let delta = t - start;\n if (delta > duration) {\n fn(end);\n resolve();\n } else {\n // call frame callback after computing eased time and get the next frame\n let proceed = fn(new Point(\n begin.x + diffX * ease(delta / duration),\n begin.y + diffY * ease(delta / duration)\n ));\n\n if (proceed !== false && !canceled) {\n raf_id = requestAnimationFrame(run);\n }\n }\n });\n }) as CancelablePromise<void>;\n\n promise.cancel = function () {\n canceled = true;\n cancelAnimationFrame(raf_id);\n };\n\n return promise;\n}\n\n// easing functions\nexport function linearEasing(t) {\n return t;\n}\n\nexport function easeOut(t) {\n return Math.sin(t * Math.PI / 2);\n}\n"],"names":[],"version":3,"file":"tween.main.js.map"}
|
package/dist/tween.mjs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {Point as $3041db3296945e6e$export$baf26146a414f24a} from "./Point.mjs";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
// use high res timer if available
|
|
15
|
-
let $3eb131dcf37ad5f8$var$perf = typeof window !== 'undefined' ? window.performance : null;
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
let $3eb131dcf37ad5f8$var$perfNow = $3eb131dcf37ad5f8$var$perf && ($3eb131dcf37ad5f8$var$perf.now || $3eb131dcf37ad5f8$var$perf.webkitNow || $3eb131dcf37ad5f8$var$perf.msNow || $3eb131dcf37ad5f8$var$perf.mozNow);
|
|
18
|
-
let $3eb131dcf37ad5f8$var$getTime = $3eb131dcf37ad5f8$var$perfNow ? $3eb131dcf37ad5f8$var$perfNow.bind($3eb131dcf37ad5f8$var$perf) : function() {
|
|
19
|
-
return Date.now ? Date.now() : new Date().getTime();
|
|
20
|
-
};
|
|
21
|
-
let $3eb131dcf37ad5f8$var$fixTs;
|
|
22
|
-
function $3eb131dcf37ad5f8$export$dc0b63720788090c(begin, end, duration, ease, fn) {
|
|
23
|
-
let canceled = false;
|
|
24
|
-
let raf_id;
|
|
25
|
-
let promise = new Promise((resolve)=>{
|
|
26
|
-
let start = $3eb131dcf37ad5f8$var$getTime();
|
|
27
|
-
let diffX = end.x - begin.x;
|
|
28
|
-
let diffY = end.y - begin.y;
|
|
29
|
-
raf_id = requestAnimationFrame(function run(t) {
|
|
30
|
-
// if we're using a high res timer, make sure timestamp is not the old epoch-based value.
|
|
31
|
-
// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
|
|
32
|
-
if ($3eb131dcf37ad5f8$var$fixTs == null) $3eb131dcf37ad5f8$var$fixTs = t > 1e12 !== $3eb131dcf37ad5f8$var$getTime() > 1e12;
|
|
33
|
-
if ($3eb131dcf37ad5f8$var$fixTs) t = $3eb131dcf37ad5f8$var$getTime();
|
|
34
|
-
// check if we're done
|
|
35
|
-
let delta = t - start;
|
|
36
|
-
if (delta > duration) {
|
|
37
|
-
fn(end);
|
|
38
|
-
resolve();
|
|
39
|
-
} else {
|
|
40
|
-
// call frame callback after computing eased time and get the next frame
|
|
41
|
-
let proceed = fn(new (0, $3041db3296945e6e$export$baf26146a414f24a)(begin.x + diffX * ease(delta / duration), begin.y + diffY * ease(delta / duration)));
|
|
42
|
-
if (proceed !== false && !canceled) raf_id = requestAnimationFrame(run);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
promise.cancel = function() {
|
|
47
|
-
canceled = true;
|
|
48
|
-
cancelAnimationFrame(raf_id);
|
|
49
|
-
};
|
|
50
|
-
return promise;
|
|
51
|
-
}
|
|
52
|
-
function $3eb131dcf37ad5f8$export$77860c106b4a6a2e(t) {
|
|
53
|
-
return t;
|
|
54
|
-
}
|
|
55
|
-
function $3eb131dcf37ad5f8$export$57636bb43b1ccbb0(t) {
|
|
56
|
-
return Math.sin(t * Math.PI / 2);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export {$3eb131dcf37ad5f8$export$dc0b63720788090c as tween, $3eb131dcf37ad5f8$export$77860c106b4a6a2e as linearEasing, $3eb131dcf37ad5f8$export$57636bb43b1ccbb0 as easeOut};
|
|
61
|
-
//# sourceMappingURL=tween.module.js.map
|
package/dist/tween.module.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {Point as $3041db3296945e6e$export$baf26146a414f24a} from "./Point.module.js";
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
-
* governing permissions and limitations under the License.
|
|
13
|
-
*/
|
|
14
|
-
// use high res timer if available
|
|
15
|
-
let $3eb131dcf37ad5f8$var$perf = typeof window !== 'undefined' ? window.performance : null;
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
let $3eb131dcf37ad5f8$var$perfNow = $3eb131dcf37ad5f8$var$perf && ($3eb131dcf37ad5f8$var$perf.now || $3eb131dcf37ad5f8$var$perf.webkitNow || $3eb131dcf37ad5f8$var$perf.msNow || $3eb131dcf37ad5f8$var$perf.mozNow);
|
|
18
|
-
let $3eb131dcf37ad5f8$var$getTime = $3eb131dcf37ad5f8$var$perfNow ? $3eb131dcf37ad5f8$var$perfNow.bind($3eb131dcf37ad5f8$var$perf) : function() {
|
|
19
|
-
return Date.now ? Date.now() : new Date().getTime();
|
|
20
|
-
};
|
|
21
|
-
let $3eb131dcf37ad5f8$var$fixTs;
|
|
22
|
-
function $3eb131dcf37ad5f8$export$dc0b63720788090c(begin, end, duration, ease, fn) {
|
|
23
|
-
let canceled = false;
|
|
24
|
-
let raf_id;
|
|
25
|
-
let promise = new Promise((resolve)=>{
|
|
26
|
-
let start = $3eb131dcf37ad5f8$var$getTime();
|
|
27
|
-
let diffX = end.x - begin.x;
|
|
28
|
-
let diffY = end.y - begin.y;
|
|
29
|
-
raf_id = requestAnimationFrame(function run(t) {
|
|
30
|
-
// if we're using a high res timer, make sure timestamp is not the old epoch-based value.
|
|
31
|
-
// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
|
|
32
|
-
if ($3eb131dcf37ad5f8$var$fixTs == null) $3eb131dcf37ad5f8$var$fixTs = t > 1e12 !== $3eb131dcf37ad5f8$var$getTime() > 1e12;
|
|
33
|
-
if ($3eb131dcf37ad5f8$var$fixTs) t = $3eb131dcf37ad5f8$var$getTime();
|
|
34
|
-
// check if we're done
|
|
35
|
-
let delta = t - start;
|
|
36
|
-
if (delta > duration) {
|
|
37
|
-
fn(end);
|
|
38
|
-
resolve();
|
|
39
|
-
} else {
|
|
40
|
-
// call frame callback after computing eased time and get the next frame
|
|
41
|
-
let proceed = fn(new (0, $3041db3296945e6e$export$baf26146a414f24a)(begin.x + diffX * ease(delta / duration), begin.y + diffY * ease(delta / duration)));
|
|
42
|
-
if (proceed !== false && !canceled) raf_id = requestAnimationFrame(run);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
promise.cancel = function() {
|
|
47
|
-
canceled = true;
|
|
48
|
-
cancelAnimationFrame(raf_id);
|
|
49
|
-
};
|
|
50
|
-
return promise;
|
|
51
|
-
}
|
|
52
|
-
function $3eb131dcf37ad5f8$export$77860c106b4a6a2e(t) {
|
|
53
|
-
return t;
|
|
54
|
-
}
|
|
55
|
-
function $3eb131dcf37ad5f8$export$57636bb43b1ccbb0(t) {
|
|
56
|
-
return Math.sin(t * Math.PI / 2);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
export {$3eb131dcf37ad5f8$export$dc0b63720788090c as tween, $3eb131dcf37ad5f8$export$77860c106b4a6a2e as linearEasing, $3eb131dcf37ad5f8$export$57636bb43b1ccbb0 as easeOut};
|
|
61
|
-
//# sourceMappingURL=tween.module.js.map
|
package/dist/tween.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAID,kCAAkC;AAClC,IAAI,6BAAO,OAAO,WAAW,cAAc,OAAO,WAAW,GAAG;AAChE,aAAa;AACb,IAAI,gCAAU,8BAAS,CAAA,2BAAK,GAAG,IAAI,2BAAK,SAAS,IAAI,2BAAK,KAAK,IAAI,2BAAK,MAAM,AAAD;AAC7E,IAAI,gCAAU,gCAAU,8BAAQ,IAAI,CAAC,8BAAQ;IAC3C,OAAO,KAAK,GAAG,GAAG,KAAK,GAAG,KAAK,IAAI,OAAO,OAAO;AACnD;AAEA,IAAI;AAMG,SAAS,0CAAM,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IAClD,IAAI,WAAW;IACf,IAAI;IAEJ,IAAI,UAAU,IAAI,QAAQ,CAAA;QACxB,IAAI,QAAQ;QACZ,IAAI,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;QAC3B,IAAI,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC;QAE3B,SAAS,sBAAsB,SAAS,IAAI,CAAC;YAC3C,yFAAyF;YACzF,qGAAqG;YACrG,IAAI,+BAAS,MACX,8BAAQ,IAAI,SAAS,kCAAY;YAGnC,IAAI,6BACF,IAAI;YAGN,sBAAsB;YACtB,IAAI,QAAQ,IAAI;YAChB,IAAI,QAAQ,UAAU;gBACpB,GAAG;gBACH;YACF,OAAO;gBACL,wEAAwE;gBACxE,IAAI,UAAU,GAAG,IAAI,CAAA,GAAA,yCAAI,EACvB,MAAM,CAAC,GAAG,QAAQ,KAAK,QAAQ,WAC/B,MAAM,CAAC,GAAG,QAAQ,KAAK,QAAQ;gBAGjC,IAAI,YAAY,SAAS,CAAC,UACxB,SAAS,sBAAsB;YAEnC;QACF;IACF;IAEA,QAAQ,MAAM,GAAG;QACf,WAAW;QACX,qBAAqB;IACvB;IAEA,OAAO;AACT;AAGO,SAAS,0CAAa,CAAC;IAC5B,OAAO;AACT;AAEO,SAAS,0CAAQ,CAAC;IACvB,OAAO,KAAK,GAAG,CAAC,IAAI,KAAK,EAAE,GAAG;AAChC","sources":["packages/@react-stately/virtualizer/src/tween.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Point} from './Point';\n\n// use high res timer if available\nlet perf = typeof window !== 'undefined' ? window.performance : null;\n// @ts-ignore\nlet perfNow = perf && (perf.now || perf.webkitNow || perf.msNow || perf.mozNow);\nlet getTime = perfNow ? perfNow.bind(perf) : function () {\n return Date.now ? Date.now() : new Date().getTime();\n};\n\nlet fixTs: boolean;\n\nexport interface CancelablePromise<T> extends Promise<T> {\n cancel(): void\n}\n\nexport function tween(begin, end, duration, ease, fn): CancelablePromise<void> {\n let canceled = false;\n let raf_id: number;\n\n let promise = new Promise(resolve => {\n let start = getTime();\n let diffX = end.x - begin.x;\n let diffY = end.y - begin.y;\n\n raf_id = requestAnimationFrame(function run(t) {\n // if we're using a high res timer, make sure timestamp is not the old epoch-based value.\n // http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision\n if (fixTs == null) {\n fixTs = t > 1e12 !== getTime() > 1e12;\n }\n\n if (fixTs) {\n t = getTime();\n }\n\n // check if we're done\n let delta = t - start;\n if (delta > duration) {\n fn(end);\n resolve();\n } else {\n // call frame callback after computing eased time and get the next frame\n let proceed = fn(new Point(\n begin.x + diffX * ease(delta / duration),\n begin.y + diffY * ease(delta / duration)\n ));\n\n if (proceed !== false && !canceled) {\n raf_id = requestAnimationFrame(run);\n }\n }\n });\n }) as CancelablePromise<void>;\n\n promise.cancel = function () {\n canceled = true;\n cancelAnimationFrame(raf_id);\n };\n\n return promise;\n}\n\n// easing functions\nexport function linearEasing(t) {\n return t;\n}\n\nexport function easeOut(t) {\n return Math.sin(t * Math.PI / 2);\n}\n"],"names":[],"version":3,"file":"tween.module.js.map"}
|
package/src/Transaction.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {Key} from '@react-types/shared';
|
|
14
|
-
import {LayoutInfo} from './LayoutInfo';
|
|
15
|
-
import {ReusableView} from './ReusableView';
|
|
16
|
-
|
|
17
|
-
type LayoutInfoMap = Map<Key, LayoutInfo>;
|
|
18
|
-
export class Transaction<T extends object, V> {
|
|
19
|
-
level = 0;
|
|
20
|
-
actions: (() => void)[] = [];
|
|
21
|
-
animated = true;
|
|
22
|
-
initialMap: LayoutInfoMap = new Map();
|
|
23
|
-
finalMap: LayoutInfoMap = new Map();
|
|
24
|
-
initialLayoutInfo: LayoutInfoMap = new Map();
|
|
25
|
-
finalLayoutInfo: LayoutInfoMap = new Map();
|
|
26
|
-
removed: Map<Key, ReusableView<T, V>> = new Map();
|
|
27
|
-
toRemove: Map<Key, ReusableView<T, V>> = new Map();
|
|
28
|
-
}
|