@twreporter/universal-header 2.2.9-rc.5 → 2.2.9
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/CHANGELOG.md +28 -0
- package/lib/containers/header.js +32 -11
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.2.9](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.9-rc.7...@twreporter/universal-header@2.2.9) (2022-06-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @twreporter/universal-header
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.2.9-rc.7](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.9-rc.6...@twreporter/universal-header@2.2.9-rc.7) (2022-06-06)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @twreporter/universal-header
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [2.2.9-rc.6](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.9-rc.5...@twreporter/universal-header@2.2.9-rc.6) (2022-05-30)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* clean members to null ([116fd6a](https://github.com/twreporter/twreporter-npm-packages/commit/116fd6a51a00daec61a6d80c4ddb4121e33b5ffd))
|
|
28
|
+
* fix header part ([b5afe9b](https://github.com/twreporter/twreporter-npm-packages/commit/b5afe9bec836c5806377edf09592daae23cfd03a))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
## [2.2.9-rc.5](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.9-rc.4...@twreporter/universal-header@2.2.9-rc.5) (2022-05-27)
|
|
7
35
|
|
|
8
36
|
**Note:** Version bump only for package @twreporter/universal-header
|
package/lib/containers/header.js
CHANGED
|
@@ -39,8 +39,6 @@ var _get = _interopRequireDefault(require("lodash/get"));
|
|
|
39
39
|
|
|
40
40
|
var _map = _interopRequireDefault(require("lodash/map"));
|
|
41
41
|
|
|
42
|
-
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
43
|
-
|
|
44
42
|
var _excluded = ["releaseBranch", "isAuthed", "isLinkExternal", "theme"];
|
|
45
43
|
|
|
46
44
|
var _templateObject, _templateObject2, _templateObject3;
|
|
@@ -87,8 +85,7 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
|
|
|
87
85
|
|
|
88
86
|
var _ = {
|
|
89
87
|
get: _get["default"],
|
|
90
|
-
map: _map["default"]
|
|
91
|
-
throttle: _throttle["default"]
|
|
88
|
+
map: _map["default"]
|
|
92
89
|
};
|
|
93
90
|
var HIDE_HEADER_THRESHOLD = 46;
|
|
94
91
|
var TRANSFORM_HEADER_THRESHOLD = 40;
|
|
@@ -125,7 +122,9 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
125
122
|
toUseNarrow: false,
|
|
126
123
|
hideHeader: false
|
|
127
124
|
};
|
|
128
|
-
_this.
|
|
125
|
+
_this.lastKnownPageYOffset = 0;
|
|
126
|
+
_this.ticking = false;
|
|
127
|
+
_this.handleScroll = _this.__handleScroll.bind(_assertThisInitialized(_this)); // Below parameters are used to calculate scroll transform status.
|
|
129
128
|
|
|
130
129
|
_this.currentY = 0;
|
|
131
130
|
_this.readyY = 0;
|
|
@@ -145,16 +144,38 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
145
144
|
key: "componentWillUnmount",
|
|
146
145
|
value: function componentWillUnmount() {
|
|
147
146
|
window.removeEventListener('scroll', this.handleScroll);
|
|
147
|
+
this.lastKnownPageYOffset = null;
|
|
148
|
+
this.ticking = null;
|
|
148
149
|
this.handleScroll = null;
|
|
149
150
|
this.currentY = null;
|
|
150
151
|
this.readyY = null;
|
|
151
152
|
this.isTransforming = null;
|
|
152
153
|
this.transformTimer = null;
|
|
153
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Wrap __handleScroll() with requestAnimationFrame() to avoid triggering browser reflow due to reading window.pageYOffset.
|
|
157
|
+
* ref: https://developer.mozilla.org/en-US/docs/web/api/document/scroll_event#Example
|
|
158
|
+
*/
|
|
159
|
+
|
|
154
160
|
}, {
|
|
155
161
|
key: "__handleScroll",
|
|
156
|
-
value: function __handleScroll(
|
|
157
|
-
var
|
|
162
|
+
value: function __handleScroll() {
|
|
163
|
+
var _this2 = this;
|
|
164
|
+
|
|
165
|
+
this.lastKnownPageYOffset = window.pageYOffset;
|
|
166
|
+
|
|
167
|
+
if (!this.ticking) {
|
|
168
|
+
window.requestAnimationFrame(function () {
|
|
169
|
+
_this2.__updateScrollState(_this2.lastKnownPageYOffset);
|
|
170
|
+
|
|
171
|
+
_this2.ticking = false;
|
|
172
|
+
});
|
|
173
|
+
this.ticking = true;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "__updateScrollState",
|
|
178
|
+
value: function __updateScrollState(currentScrollTop) {
|
|
158
179
|
var scrollDirection = currentScrollTop > this.currentY ? 'down' : 'up';
|
|
159
180
|
this.currentY = currentScrollTop;
|
|
160
181
|
|
|
@@ -165,7 +186,7 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
165
186
|
}, {
|
|
166
187
|
key: "__getScrollState",
|
|
167
188
|
value: function __getScrollState(scrollTop, scrollDirection) {
|
|
168
|
-
var
|
|
189
|
+
var _this3 = this;
|
|
169
190
|
|
|
170
191
|
var isCurrentNarrow = this.state.toUseNarrow;
|
|
171
192
|
var nextToUseNarrow = scrollTop > TRANSFORM_HEADER_THRESHOLD;
|
|
@@ -200,9 +221,9 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
200
221
|
if (!this.transformTimer) {
|
|
201
222
|
this.isTransforming = true;
|
|
202
223
|
this.transformTimer = setTimeout(function () {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
224
|
+
_this3.isTransforming = false;
|
|
225
|
+
_this3.readyY = _this3.currentY;
|
|
226
|
+
_this3.transformTimer = null;
|
|
206
227
|
}, TRANSFORM_TIMEOUT);
|
|
207
228
|
}
|
|
208
229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twreporter/universal-header",
|
|
3
|
-
"version": "2.2.9
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"description": "Universal header of TWReporter sites",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@twreporter/core": "^1.4.
|
|
22
|
-
"@twreporter/react-components": "^8.9.0
|
|
21
|
+
"@twreporter/core": "^1.4.1",
|
|
22
|
+
"@twreporter/react-components": "^8.9.0",
|
|
23
23
|
"lodash": "^4.17.11",
|
|
24
24
|
"prop-types": "^15.6.2",
|
|
25
25
|
"querystring": "^0.2.0",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"files": [
|
|
35
35
|
"lib"
|
|
36
36
|
],
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "073c0fdf93dbca043d66e4a5bdf2285c789c7111"
|
|
38
38
|
}
|