nodebb-theme-harmony 1.0.0-beta.46 → 1.0.0-beta.47

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/harmony.js +21 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-theme-harmony",
3
- "version": "1.0.0-beta.46",
3
+ "version": "1.0.0-beta.47",
4
4
  "nbbpm": {
5
5
  "compatibility": "^3.0.0"
6
6
  },
package/public/harmony.js CHANGED
@@ -56,18 +56,27 @@ $(document).ready(function () {
56
56
  });
57
57
 
58
58
  const bottomBar = $('[component="bottombar"]');
59
- $('body').on('shown.bs.dropdown', '.sticky-tools', function () {
59
+ const $body = $('body');
60
+ const $window = $(window);
61
+ $body.on('shown.bs.dropdown', '.sticky-tools', function () {
60
62
  bottomBar.addClass('hidden');
61
63
  });
62
- $('body').on('hidden.bs.dropdown', '.sticky-tools', function () {
64
+ $body.on('hidden.bs.dropdown', '.sticky-tools', function () {
63
65
  bottomBar.removeClass('hidden');
64
66
  });
65
67
 
66
68
  let lastScrollTop = 0;
67
- const $window = $(window);
69
+ let newPostsLoaded = false;
70
+
71
+
68
72
  function onWindowScroll() {
69
73
  const st = $window.scrollTop();
70
- if (st !== lastScrollTop) {
74
+ if (newPostsLoaded) {
75
+ newPostsLoaded = false;
76
+ lastScrollTop = st;
77
+ return;
78
+ }
79
+ if (st !== lastScrollTop && !navigator.scrollActive) {
71
80
  const diff = Math.abs(st - lastScrollTop);
72
81
  const scrolledDown = st > lastScrollTop;
73
82
  const scrolledUp = st < lastScrollTop;
@@ -77,13 +86,14 @@ $(document).ready(function () {
77
86
  -bottomBar.find('.bottombar-nav').outerHeight(true) :
78
87
  0,
79
88
  });
80
- lastScrollTop = st;
81
89
  }
82
90
  }
91
+ lastScrollTop = st;
83
92
  }
84
93
 
85
94
  const delayedScroll = utils.throttle(onWindowScroll, 250);
86
95
  function enableAutohide() {
96
+ $window.off('scroll', delayedScroll);
87
97
  if (config.theme.autohideBottombar) {
88
98
  lastScrollTop = $window.scrollTop();
89
99
  $window.on('scroll', delayedScroll);
@@ -93,17 +103,19 @@ $(document).ready(function () {
93
103
  hooks.on('action:posts.loading', function () {
94
104
  $window.off('scroll', delayedScroll);
95
105
  });
96
- hooks.on('action:posts.loaded', enableAutohide);
106
+ hooks.on('action:posts.loaded', function () {
107
+ newPostsLoaded = true;
108
+ enableAutohide();
109
+ });
97
110
  hooks.on('action:ajaxify.end', function () {
98
111
  $window.off('scroll', delayedScroll);
99
- $('body').removeClass('chat-loaded');
112
+ $body.removeClass('chat-loaded');
100
113
  bottomBar.css({ bottom: 0 });
101
114
  enableAutohide();
102
115
  });
103
116
  hooks.on('action:chat.loaded', function () {
104
- $('body').toggleClass('chat-loaded', !!(ajaxify.data.template.chats && ajaxify.data.roomId));
117
+ $body.toggleClass('chat-loaded', !!(ajaxify.data.template.chats && ajaxify.data.roomId));
105
118
  });
106
- enableAutohide();
107
119
  });
108
120
  }
109
121