@skyscanner/backpack-web 38.9.1 → 38.10.0
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.
|
@@ -44,47 +44,49 @@ class AnimateHeight extends Component {
|
|
|
44
44
|
this.contentElement.style.display = 'none';
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
componentDidUpdate(prevProps, prevState) {
|
|
48
48
|
const {
|
|
49
|
-
|
|
49
|
+
duration,
|
|
50
|
+
height,
|
|
51
|
+
transitionOverflow
|
|
50
52
|
} = this.props;
|
|
51
53
|
|
|
52
54
|
// Check if 'height' prop has changed
|
|
53
|
-
if (this.contentElement &&
|
|
55
|
+
if (this.contentElement && height !== prevProps.height) {
|
|
54
56
|
// Cache content height
|
|
55
57
|
this.contentElement.style.display = '';
|
|
56
|
-
this.contentElement.style.overflow =
|
|
58
|
+
this.contentElement.style.overflow = transitionOverflow;
|
|
57
59
|
const contentHeight = this.contentElement.offsetHeight;
|
|
58
60
|
this.contentElement.style.overflow = '';
|
|
59
61
|
let newHeight = null;
|
|
60
62
|
let shouldSetTimeout = false;
|
|
61
63
|
let timeoutHeight = null;
|
|
62
|
-
let timeoutOverflow =
|
|
63
|
-
let timeoutDuration =
|
|
64
|
+
let timeoutOverflow = transitionOverflow;
|
|
65
|
+
let timeoutDuration = duration;
|
|
64
66
|
clearTimeout(this.timeoutID);
|
|
65
|
-
if (isNumber(
|
|
67
|
+
if (isNumber(height)) {
|
|
66
68
|
// If new height is a number
|
|
67
|
-
newHeight =
|
|
69
|
+
newHeight = height < 0 ? 0 : height;
|
|
68
70
|
} else {
|
|
69
|
-
// If not, animate to content height
|
|
70
|
-
// and then reset to auto
|
|
71
|
+
// If not, animate to content height and then reset to auto
|
|
71
72
|
newHeight = contentHeight;
|
|
72
73
|
shouldSetTimeout = true;
|
|
73
74
|
timeoutHeight = 'auto';
|
|
74
75
|
timeoutOverflow = 'visible';
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
|
|
78
|
+
// If previous height was 'auto'
|
|
79
|
+
// set it explicitly to be able to use transition
|
|
80
|
+
if (prevState.height === 'auto') {
|
|
79
81
|
shouldSetTimeout = true;
|
|
80
82
|
timeoutHeight = newHeight;
|
|
81
83
|
newHeight = contentHeight;
|
|
82
84
|
timeoutDuration = 50;
|
|
83
85
|
}
|
|
84
|
-
this.setState(
|
|
86
|
+
this.setState({
|
|
85
87
|
height: newHeight,
|
|
86
|
-
overflow:
|
|
87
|
-
})
|
|
88
|
+
overflow: transitionOverflow
|
|
89
|
+
});
|
|
88
90
|
if (shouldSetTimeout) {
|
|
89
91
|
this.timeoutID = setTimeout(() => {
|
|
90
92
|
this.setState({
|
|
@@ -25,7 +25,6 @@ declare class BpkBackgroundImage extends Component<BpkBackgroundImageProps> {
|
|
|
25
25
|
};
|
|
26
26
|
constructor(props: BpkBackgroundImageProps);
|
|
27
27
|
componentDidMount(): void;
|
|
28
|
-
UNSAFE_componentWillReceiveProps(newProps: BpkBackgroundImageProps): void;
|
|
29
28
|
componentDidUpdate(prevProps: BpkBackgroundImageProps): void;
|
|
30
29
|
onBackgroundImageError: () => void;
|
|
31
30
|
onBackgroundImageLoad: () => void;
|
|
@@ -43,13 +43,12 @@ class BpkBackgroundImage extends Component {
|
|
|
43
43
|
this.startImageLoad();
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
UNSAFE_componentWillReceiveProps(newProps) {
|
|
47
|
-
if (!this.props.inView && newProps.inView) {
|
|
48
|
-
this.startImageLoad();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
46
|
componentDidUpdate(prevProps) {
|
|
52
|
-
|
|
47
|
+
const {
|
|
48
|
+
inView,
|
|
49
|
+
src
|
|
50
|
+
} = this.props;
|
|
51
|
+
if (prevProps.src !== src || inView && !prevProps.inView) {
|
|
53
52
|
this.startImageLoad();
|
|
54
53
|
}
|
|
55
54
|
}
|