@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
- UNSAFE_componentWillReceiveProps(nextProps) {
47
+ componentDidUpdate(prevProps, prevState) {
48
48
  const {
49
- height
49
+ duration,
50
+ height,
51
+ transitionOverflow
50
52
  } = this.props;
51
53
 
52
54
  // Check if 'height' prop has changed
53
- if (this.contentElement && nextProps.height !== height) {
55
+ if (this.contentElement && height !== prevProps.height) {
54
56
  // Cache content height
55
57
  this.contentElement.style.display = '';
56
- this.contentElement.style.overflow = this.props.transitionOverflow;
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 = this.props.transitionOverflow;
63
- let timeoutDuration = nextProps.duration;
64
+ let timeoutOverflow = transitionOverflow;
65
+ let timeoutDuration = duration;
64
66
  clearTimeout(this.timeoutID);
65
- if (isNumber(nextProps.height)) {
67
+ if (isNumber(height)) {
66
68
  // If new height is a number
67
- newHeight = nextProps.height < 0 ? 0 : nextProps.height;
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
- if (this.state.height === 'auto') {
77
- // If previous height was 'auto'
78
- // set it explicitly to be able to use transition
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((state, props) => ({
86
+ this.setState({
85
87
  height: newHeight,
86
- overflow: props.transitionOverflow
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
- if (prevProps.src !== this.props.src) {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "38.9.1",
3
+ "version": "38.10.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",