@xenknight/framework7 0.0.6 → 0.0.7

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 (53) hide show
  1. package/components/app/app.less +1 -1
  2. package/components/icon/icon-ios.less +9 -0
  3. package/components/icon/icon-md.less +9 -0
  4. package/components/icon/icon.less +2 -1
  5. package/components/list/list-vars.less +1 -1
  6. package/components/messagebar/messagebar-rtl.css +1 -1
  7. package/components/messagebar/messagebar-vars.less +1 -1
  8. package/components/messagebar/messagebar.css +1 -1
  9. package/components/messages/messages-rtl.css +1 -1
  10. package/components/messages/messages-vars.less +7 -7
  11. package/components/messages/messages.css +1 -1
  12. package/components/navbar-new/navbar-ios.less +135 -0
  13. package/components/navbar-new/navbar-md.less +105 -0
  14. package/components/navbar-new/navbar-vars.less +78 -0
  15. package/components/navbar-new/navbar.d.ts +77 -0
  16. package/components/navbar-new/navbar.js +568 -0
  17. package/components/navbar-new/navbar.less +268 -0
  18. package/components/searchbar-new/remove-diacritics.js +271 -0
  19. package/components/searchbar-new/searchbar-ios.less +131 -0
  20. package/components/searchbar-new/searchbar-md.less +153 -0
  21. package/components/searchbar-new/searchbar-new-class.js +592 -0
  22. package/components/searchbar-new/searchbar-vars.less +75 -0
  23. package/components/searchbar-new/searchbar.js +122 -0
  24. package/components/searchbar-new/searchbar.less +331 -0
  25. package/components/swipeout/swipeout.js +8 -9
  26. package/components/tabs/tabs.js +5 -0
  27. package/components/toolbar-new/tabbar-highlight.js +134 -0
  28. package/components/toolbar-new/toolbar-ios.less +193 -0
  29. package/components/toolbar-new/toolbar-md.less +152 -0
  30. package/components/toolbar-new/toolbar-vars.less +77 -0
  31. package/components/toolbar-new/toolbar.js +223 -0
  32. package/components/toolbar-new/toolbar.less +261 -0
  33. package/framework7-bundle-rtl.css +2198 -387
  34. package/framework7-bundle-rtl.min.css +12 -6
  35. package/framework7-bundle.css +2194 -383
  36. package/framework7-bundle.esm.js +11 -4
  37. package/framework7-bundle.js +2368 -467
  38. package/framework7-bundle.js.map +1 -1
  39. package/framework7-bundle.less +6 -3
  40. package/framework7-bundle.min.css +12 -6
  41. package/framework7-bundle.min.js +4 -4
  42. package/framework7-bundle.min.js.map +1 -1
  43. package/framework7-lite-bundle.esm.js +11 -4
  44. package/framework7-lite.esm.js +11 -4
  45. package/framework7-lite.js +8 -1
  46. package/framework7-rtl.css +2191 -380
  47. package/framework7-rtl.min.css +11 -5
  48. package/framework7.css +2189 -378
  49. package/framework7.esm.js +11 -4
  50. package/framework7.js +8 -1
  51. package/framework7.less +6 -3
  52. package/framework7.min.css +11 -5
  53. package/package.json +1 -1
@@ -0,0 +1,122 @@
1
+ import $ from '../../shared/dom7.js';
2
+ import { extend } from '../../shared/utils.js';
3
+ import SearchbarNew from './searchbar-new-class.js';
4
+ import ConstructorMethods from '../../shared/constructor-methods.js';
5
+ export default {
6
+ name: 'searchbar-new',
7
+ static: {
8
+ SearchbarNew
9
+ },
10
+ create() {
11
+ const app = this;
12
+ app.searchbarNew = ConstructorMethods({
13
+ defaultSelector: '.searchbar-new',
14
+ constructor: SearchbarNew,
15
+ app,
16
+ domProp: 'f7SearchbarNew',
17
+ addMethods: 'clear enable disable toggle search'.split(' ')
18
+ });
19
+ },
20
+ on: {
21
+ tabMounted(tabEl) {
22
+ const app = this;
23
+ $(tabEl).find('.searchbar-new-init').each(searchbarEl => {
24
+ const $searchbarEl = $(searchbarEl);
25
+ app.searchbarNew.create(extend($searchbarEl.dataset(), {
26
+ el: searchbarEl
27
+ }));
28
+ });
29
+ },
30
+ tabBeforeRemove(tabEl) {
31
+ $(tabEl).find('.searchbar-new-init').each(searchbarEl => {
32
+ if (searchbarEl.f7SearchbarNew && searchbarEl.f7SearchbarNew.destroy) {
33
+ searchbarEl.f7SearchbarNew.destroy();
34
+ }
35
+ });
36
+ },
37
+ pageInit(page) {
38
+ const app = this;
39
+ page.$el.find('.searchbar-new-init').each(searchbarEl => {
40
+ const $searchbarEl = $(searchbarEl);
41
+ app.searchbarNew.create(extend($searchbarEl.dataset(), {
42
+ el: searchbarEl
43
+ }));
44
+ });
45
+ if (app.theme === 'ios' && page.view && page.view.router.dynamicNavbar && page.$navbarNewEl && page.$navbarNewEl.length > 0) {
46
+ page.$navbarNewEl.find('.searchbar-new-init').each(searchbarEl => {
47
+ const $searchbarEl = $(searchbarEl);
48
+ app.searchbarNew.create(extend($searchbarEl.dataset(), {
49
+ el: searchbarEl
50
+ }));
51
+ });
52
+ }
53
+ },
54
+ pageBeforeRemove(page) {
55
+ const app = this;
56
+ page.$el.find('.searchbar-new-init').each(searchbarEl => {
57
+ if (searchbarEl.f7SearchbarNew && searchbarEl.f7SearchbarNew.destroy) {
58
+ searchbarEl.f7SearchbarNew.destroy();
59
+ }
60
+ });
61
+ if (app.theme === 'ios' && page.view && page.view.router.dynamicNavbar && page.$navbarNewEl && page.$navbarNewEl.length > 0) {
62
+ page.$navbarNewEl.find('.searchbar-new-init').each(searchbarEl => {
63
+ if (searchbarEl.f7SearchbarNew && searchbarEl.f7SearchbarNew.destroy) {
64
+ searchbarEl.f7SearchbarNew.destroy();
65
+ }
66
+ });
67
+ }
68
+ }
69
+ },
70
+ clicks: {
71
+ '.searchbar-new-clear': function clear($clickedEl, data) {
72
+ if (data === void 0) {
73
+ data = {};
74
+ }
75
+ const app = this;
76
+ const sb = app.searchbarNew.get(data.searchbar);
77
+ if (sb) sb.clear();
78
+ },
79
+ '.searchbar-new-enable': function enable($clickedEl, data) {
80
+ if (data === void 0) {
81
+ data = {};
82
+ }
83
+ const app = this;
84
+ const sb = app.searchbarNew.get(data.searchbar);
85
+ if (sb) sb.enable(true);
86
+ },
87
+ '.searchbar-new-disable': function disable($clickedEl, data) {
88
+ if (data === void 0) {
89
+ data = {};
90
+ }
91
+ const app = this;
92
+ const sb = app.searchbarNew.get(data.searchbar);
93
+ if (sb) sb.disable();
94
+ },
95
+ '.searchbar-new-toggle': function toggle($clickedEl, data) {
96
+ if (data === void 0) {
97
+ data = {};
98
+ }
99
+ const app = this;
100
+ const sb = app.searchbarNew.get(data.searchbar);
101
+ if (sb) sb.toggle();
102
+ }
103
+ },
104
+ vnode: {
105
+ 'searchbar-new-init': {
106
+ insert(vnode) {
107
+ const app = this;
108
+ const searchbarEl = vnode.elm;
109
+ const $searchbarEl = $(searchbarEl);
110
+ app.searchbarNew.create(extend($searchbarEl.dataset(), {
111
+ el: searchbarEl
112
+ }));
113
+ },
114
+ destroy(vnode) {
115
+ const searchbarEl = vnode.elm;
116
+ if (searchbarEl.f7SearchbarNew && searchbarEl.f7SearchbarNew.destroy) {
117
+ searchbarEl.f7SearchbarNew.destroy();
118
+ }
119
+ }
120
+ }
121
+ }
122
+ };
@@ -0,0 +1,331 @@
1
+ /* === Searchbar New === */
2
+ @import './searchbar-vars.less';
3
+
4
+ .searchbar-new {
5
+ --f7-link-highlight-color: var(--f7-link-highlight-black);
6
+ .dark & {
7
+ --f7-link-highlight-color: var(--f7-link-highlight-white);
8
+ }
9
+ width: 100%;
10
+ position: relative;
11
+ z-index: 200;
12
+ height: var(--f7-searchbar-new-height);
13
+ background-color: var(--f7-searchbar-new-bars-bg-color);
14
+ input[type='search']::-webkit-search-decoration {
15
+ display: none;
16
+ }
17
+ .ios .subnavbar & {
18
+ background-color: transparent;
19
+ backdrop-filter: none;
20
+ .hairline-remove(bottom);
21
+ }
22
+ &.no-outline {
23
+ &:after {
24
+ display: none !important;
25
+ }
26
+ }
27
+
28
+ .hairline(bottom, var(--f7-searchbar-new-border-color, var(--f7-bars-border-color)));
29
+
30
+ .page > &:not(.searchbar-new-inline) {
31
+ z-index: 600;
32
+ }
33
+ input[type='text'],
34
+ input[type='search'] {
35
+ box-sizing: border-box;
36
+ width: 100%;
37
+ height: 100%;
38
+ display: block;
39
+ border: var(--f7-searchbar-new-input-border-width) solid
40
+ var(--f7-searchbar-new-input-border-color);
41
+ appearance: none;
42
+ font-family: inherit;
43
+ font-weight: normal;
44
+ color: var(--f7-searchbar-new-input-text-color);
45
+ font-size: var(--f7-searchbar-new-input-font-size);
46
+ background-color: var(--f7-searchbar-new-input-bg-color);
47
+ border-radius: var(--f7-searchbar-new-input-border-radius);
48
+ position: relative;
49
+ padding: 0;
50
+ .ltr({
51
+ padding-left: calc(var(--f7-searchbar-new-input-padding-horizontal) + var(--f7-searchbar-new-input-extra-padding-left, 0px));
52
+ padding-right: calc(var(--f7-searchbar-new-input-padding-horizontal) + var(--f7-searchbar-new-input-extra-padding-right, 0px));;
53
+ });
54
+ .rtl({
55
+ padding-left: calc(var(--f7-searchbar-new-input-padding-horizontal) + var(--f7-searchbar-new-input-extra-padding-right, 0px));;
56
+ padding-right: calc(var(--f7-searchbar-new-input-padding-horizontal) + var(--f7-searchbar-new-input-extra-padding-left, 0px));
57
+ });
58
+ &::placeholder {
59
+ color: var(--f7-searchbar-new-placeholder-color);
60
+ opacity: 1;
61
+ }
62
+ }
63
+ input::-webkit-search-cancel-button {
64
+ appearance: none;
65
+ }
66
+ .searchbar-new-input-wrap {
67
+ flex-shrink: 1;
68
+ width: 100%;
69
+ height: var(--f7-searchbar-new-input-height);
70
+ position: relative;
71
+ }
72
+ a {
73
+ color: var(--f7-searchbar-new-link-color, var(--f7-bars-link-color, var(--f7-theme-color)));
74
+ }
75
+ .page > &:not(.searchbar-new-inline) {
76
+ position: absolute;
77
+ left: 16px;
78
+ right: 16px;
79
+ width: auto;
80
+ top: 0;
81
+ }
82
+ .page-content &:not(.searchbar-new-inline) {
83
+ border-radius: var(--f7-searchbar-new-in-page-content-border-radius);
84
+ margin: var(--f7-searchbar-new-in-page-content-margin);
85
+ width: auto;
86
+ box-shadow: var(--f7-searchbar-new-in-page-content-box-shadow);
87
+ .searchbar-new-inner,
88
+ input[type='text'],
89
+ input[type='search'] {
90
+ border-radius: var(
91
+ --f7-searchbar-new-in-page-content-input-border-radius,
92
+ var(--f7-searchbar-new-input-border-radius)
93
+ );
94
+ }
95
+ }
96
+ .input-clear-button {
97
+ color: var(--f7-searchbar-new-input-clear-button-color, var(--f7-input-clear-button-color));
98
+ }
99
+ }
100
+ .searchbar-new-expandable {
101
+ --f7-searchbar-new-expandable-size: var(--f7-searchbar-new-height);
102
+ position: absolute;
103
+ transition-duration: 300ms;
104
+ pointer-events: none;
105
+ }
106
+ .navbar-new .searchbar-new-expandable {
107
+ .hairline-remove(bottom);
108
+ background: transparent;
109
+ }
110
+ .navbar-new .searchbar-new.searchbar-new-expandable {
111
+ --f7-searchbar-new-expandable-size: calc(var(--f7-navbar-new-height) + var(--f7-safe-area-top));
112
+ .searchbar-new-inner {
113
+ top: var(--f7-safe-area-top);
114
+ height: calc(100% - var(--f7-safe-area-top));
115
+ }
116
+ }
117
+ .toolbar .searchbar-new.searchbar-new-expandable {
118
+ --f7-searchbar-new-expandable-size: var(--f7-toolbar-height);
119
+ }
120
+ .subnavbar .searchbar-new.searchbar-new-expandable {
121
+ --f7-searchbar-new-expandable-size: var(--f7-subnavbar-height);
122
+ }
123
+ .tabbar-icons .searchbar-new.searchbar-new-expandable {
124
+ --f7-searchbar-new-expandable-size: var(--f7-tabbar-icons-height);
125
+ }
126
+ .searchbar-new-inner {
127
+ position: absolute;
128
+ left: 0;
129
+ top: 0;
130
+ width: 100%;
131
+ height: 100%;
132
+ display: flex;
133
+ align-items: center;
134
+ box-sizing: border-box;
135
+ padding: 0 calc(var(--f7-searchbar-new-inner-padding-right) + var(--f7-safe-area-right)) 0
136
+ calc(var(--f7-searchbar-new-inner-padding-left) + var(--f7-safe-area-left));
137
+ }
138
+ .searchbar-new-disable-button {
139
+ cursor: pointer;
140
+ pointer-events: none;
141
+ appearance: none;
142
+ background: none;
143
+ border: none;
144
+ outline: 0;
145
+ padding: 0;
146
+ margin: 0;
147
+ width: auto;
148
+ opacity: 0;
149
+ }
150
+ .searchbar-new-icon {
151
+ pointer-events: none;
152
+ background-position: center;
153
+ background-repeat: no-repeat;
154
+ &:after {
155
+ color: var(--f7-searchbar-new-search-icon-color);
156
+ .core-icons-font();
157
+ }
158
+ }
159
+ .searchbar-new-backdrop {
160
+ position: absolute;
161
+ left: 0;
162
+ top: 0;
163
+ width: 100%;
164
+ height: 100%;
165
+ z-index: 100;
166
+ opacity: 0;
167
+ pointer-events: none;
168
+ transition-duration: 300ms;
169
+ transform: translate3d(0, 0, 0);
170
+ background: var(--f7-searchbar-new-backdrop-bg-color);
171
+ &.searchbar-new-backdrop-in {
172
+ opacity: 1;
173
+ pointer-events: auto;
174
+ }
175
+ .page-content > & {
176
+ position: fixed;
177
+ }
178
+ }
179
+ .searchbar-new-found {
180
+ display: none;
181
+ }
182
+ .searchbar-new-not-found {
183
+ display: none;
184
+ }
185
+ .hidden-by-searchbar-new {
186
+ &,
187
+ .list &,
188
+ .list.li&,
189
+ .list li& {
190
+ display: none !important;
191
+ }
192
+ }
193
+ .navbar-new.with-searchbar-new-expandable-enabled-no-transition,
194
+ .navbar-new.with-searchbar-new-expandable-enabled-no-transition {
195
+ --f7-navbar-new-large-collapse-progress: 1;
196
+ }
197
+ .navbar-new.with-searchbar-new-expandable-enabled,
198
+ .navbar-new.with-searchbar-new-expandable-enabled {
199
+ --f7-navbar-new-large-collapse-progress: 1;
200
+ .navbar-new-bg,
201
+ .title-large,
202
+ .title-large-text {
203
+ transition-duration: 300ms;
204
+ }
205
+ }
206
+ .navbar-new.with-searchbar-new-expandable-closing,
207
+ .navbar-new.with-searchbar-new-expandable-closing {
208
+ .navbar-new-bg,
209
+ .title-large,
210
+ .title-large-text {
211
+ transition-duration: 300ms;
212
+ }
213
+ }
214
+
215
+ .page-content.with-searchbar-new-expandable-enabled {
216
+ height: calc(100% + var(--f7-navbar-new-large-title-height));
217
+ transform: translateY(calc(-1 * var(--f7-navbar-new-large-title-height)));
218
+ transition-duration: 300ms;
219
+ transition-property: transform;
220
+ }
221
+ .page-content.with-searchbar-new-expandable-closing {
222
+ transition-duration: 300ms;
223
+ }
224
+
225
+ // Relation with page
226
+ .navbar-new ~ .page:not(.no-navbar) > .searchbar-new,
227
+ .page > .navbar-new ~ .searchbar-new {
228
+ top: calc(var(--f7-navbar-new-height) + var(--f7-safe-area-top));
229
+ }
230
+
231
+ .navbar-new ~ .page-with-navbar-new-large:not(.no-navbar) .searchbar-new,
232
+ .page-with-navbar-new-large .navbar-new ~ .searchbar-new,
233
+ .page-with-navbar-new-large .navbar-new ~ * .searchbar-new {
234
+ top: calc(
235
+ var(--f7-navbar-new-height) + var(--f7-navbar-new-large-title-height) + var(--f7-safe-area-top)
236
+ );
237
+ transform: translate3d(
238
+ 0,
239
+ calc(
240
+ -1 * var(--f7-navbar-new-large-collapse-progress) * var(--f7-navbar-new-large-title-height)
241
+ ),
242
+ 0
243
+ );
244
+ }
245
+ .page-with-navbar-new-large .page-content .searchbar-new {
246
+ top: 0;
247
+ transform: none;
248
+ }
249
+
250
+ .searchbar-new ~ * {
251
+ --f7-page-searchbar-new-offset: var(--f7-searchbar-new-height);
252
+ }
253
+
254
+ // Toolbar
255
+ .page > .toolbar-top,
256
+ .ios .page > .toolbar-top-ios,
257
+ .md .page > .toolbar-top-md {
258
+ ~ .searchbar-new {
259
+ top: var(--f7-toolbar-height);
260
+ }
261
+ }
262
+ .page > .tabbar-icons.toolbar-top,
263
+ .ios .page > .tabbar-icons.toolbar-top-ios,
264
+ .md .page > .tabbar-icons.toolbar-top-md {
265
+ ~ .searchbar-new {
266
+ top: var(--f7-tabbar-icons-height);
267
+ }
268
+ }
269
+ .page > .navbar-new ~ .toolbar-top,
270
+ .ios .page > .navbar-new ~ .toolbar-top-ios,
271
+ .md .page > .navbar-new ~ .toolbar-top-md {
272
+ ~ .searchbar-new {
273
+ top: calc(var(--f7-navbar-new-height) + var(--f7-toolbar-height) + var(--f7-safe-area-top));
274
+ }
275
+ }
276
+ .page > .navbar-new ~ .tabbar-icons.toolbar-top,
277
+ .ios .page > .navbar-new ~ .tabbar-icons.toolbar-top-ios,
278
+ .md .page > .navbar-new ~ .tabbar-icons.toolbar-top-md {
279
+ ~ .searchbar-new {
280
+ top: calc(
281
+ var(--f7-navbar-new-height) + var(--f7-tabbar-icons-height) + var(--f7-safe-area-top)
282
+ );
283
+ }
284
+ }
285
+
286
+ .searchbar-new.searchbar-new-inline {
287
+ width: auto;
288
+ height: auto;
289
+ background-color: transparent;
290
+ background-image: none;
291
+
292
+ &:after,
293
+ &:before {
294
+ display: none !important;
295
+ }
296
+ .searchbar-new-input-wrap {
297
+ height: var(--f7-searchbar-new-inline-input-height, var(--f7-searchbar-new-input-height));
298
+ }
299
+ .searchbar-new-inner {
300
+ padding: 0;
301
+ position: static;
302
+ width: auto;
303
+ height: auto;
304
+ }
305
+ input[type='text'],
306
+ input[type='search'] {
307
+ font-size: var(
308
+ --f7-searchbar-new-inline-input-font-size,
309
+ var(--f7-searchbar-new-input-font-size)
310
+ );
311
+ border-radius: var(
312
+ --f7-searchbar-new-inline-input-border-radius,
313
+ var(--f7-searchbar-new-input-border-radius)
314
+ );
315
+ .ltr({
316
+ padding-left: calc(var(--f7-searchbar-new-inline-input-padding-horizontal, var(--f7-searchbar-new-input-padding-horizontal)) + var(--f7-searchbar-new-input-extra-padding-left, 0px));
317
+ padding-right: calc(var(--f7-searchbar-new-inline-input-padding-horizontal, var(--f7-searchbar-new-input-padding-horizontal)) + var(--f7-searchbar-new-input-extra-padding-right, 0px));;
318
+ });
319
+ .rtl({
320
+ padding-left: calc(var(--f7-searchbar-new-inline-input-padding-horizontal, var(--f7-searchbar-new-input-padding-horizontal)) + var(--f7-searchbar-new-input-extra-padding-right, 0px));;
321
+ padding-right: calc(var(--f7-searchbar-new-inline-input-padding-horizontal, var(--f7-searchbar-new-input-padding-horizontal)) + var(--f7-searchbar-new-input-extra-padding-left, 0px));
322
+ });
323
+ }
324
+ }
325
+
326
+ .if-ios-theme({
327
+ @import './searchbar-ios.less';
328
+ });
329
+ .if-md-theme({
330
+ @import './searchbar-md.less';
331
+ });
@@ -27,7 +27,6 @@ const Swipeout = {
27
27
  let $overswipeRightButton;
28
28
  let overswipeLeft;
29
29
  let overswipeRight;
30
- const isIOS = app.theme === 'ios';
31
30
  function handleTouchStart(e) {
32
31
  if (!app.swipeout.allow) return;
33
32
  isMoved = false;
@@ -162,7 +161,7 @@ const Swipeout = {
162
161
  buttonOffset = buttonEl.f7SwipeoutButtonOffset;
163
162
  const buttonWidth = $buttonEl[0].f7SwipeoutButtonWidth;
164
163
  if ($overswipeRightButton.length > 0 && $buttonEl.hasClass('swipeout-overswipe') && direction === 'to-left') {
165
- if (isIOS) {
164
+ if (app.theme === 'ios') {
166
165
  const newWidth = overswipeRight ? buttonWidth + buttonOffset - 8 : buttonWidth;
167
166
  const diff = newWidth - buttonWidth;
168
167
  $buttonEl.css({
@@ -188,7 +187,7 @@ const Swipeout = {
188
187
  $buttonEl.removeClass('swipeout-overswipe-active');
189
188
  }
190
189
  }
191
- if (isIOS) {
190
+ if (app.theme === 'ios') {
192
191
  const buttonEndPos = actionsRightWidth - buttonOffset;
193
192
  const buttonStartPos = actionsRightWidth - buttonOffset - buttonWidth;
194
193
  let buttonProgress = (-buttonTranslate - buttonStartPos) / (buttonEndPos - buttonStartPos);
@@ -221,12 +220,12 @@ const Swipeout = {
221
220
  $buttonEl[0].f7SwipeoutButtonWidth = buttonEl.offsetWidth;
222
221
  }
223
222
  if (typeof buttonEl.f7SwipeoutButtonOffset === 'undefined') {
224
- $buttonEl[0].f7SwipeoutButtonOffset = isIOS ? buttonEl.offsetLeft : actionsLeftWidth - buttonEl.offsetLeft - buttonEl.offsetWidth;
223
+ $buttonEl[0].f7SwipeoutButtonOffset = app.theme === 'ios' ? buttonEl.offsetLeft : actionsLeftWidth - buttonEl.offsetLeft - buttonEl.offsetWidth;
225
224
  }
226
225
  const buttonWidth = $buttonEl[0].f7SwipeoutButtonWidth;
227
226
  buttonOffset = buttonEl.f7SwipeoutButtonOffset;
228
227
  if ($overswipeLeftButton.length > 0 && $buttonEl.hasClass('swipeout-overswipe') && direction === 'to-right') {
229
- if (isIOS) {
228
+ if (app.theme === 'ios') {
230
229
  const newWidth = overswipeLeft ? actionsLeftWidth - 16 : buttonWidth;
231
230
  const diff = newWidth - buttonWidth;
232
231
  $buttonEl.css({
@@ -255,7 +254,7 @@ const Swipeout = {
255
254
  if ($leftButtons.length > 1) {
256
255
  $buttonEl.css('z-index', $leftButtons.length - index);
257
256
  }
258
- if (isIOS) {
257
+ if (app.theme === 'ios') {
259
258
  const buttonStartPos = buttonOffset;
260
259
  const buttonEndPos = buttonStartPos + buttonWidth;
261
260
  let buttonProgress = (buttonTranslate - buttonStartPos) / (buttonEndPos - buttonStartPos);
@@ -305,7 +304,7 @@ const Swipeout = {
305
304
  $buttons = direction === 'to-left' ? $rightButtons : $leftButtons;
306
305
  if ($buttons) {
307
306
  for (i = 0; i < $buttons.length; i += 1) {
308
- if (isIOS) {
307
+ if (app.theme === 'ios') {
309
308
  $($buttons[i]).transform(`scale(1)`);
310
309
  } else {
311
310
  $($buttons[i]).transform(`translate3d(${newTranslate}px,0,0)`);
@@ -334,7 +333,7 @@ const Swipeout = {
334
333
  if (typeof buttonOffset === 'undefined') {
335
334
  $buttonEl[0].f7SwipeoutButtonOffset = actionsLeftWidth - buttonEl.offsetLeft - buttonEl.offsetWidth;
336
335
  }
337
- if (isIOS) {
336
+ if (app.theme === 'ios') {
338
337
  $buttonEl.transform(`scale(0)`);
339
338
  } else {
340
339
  $buttonEl.transform(`translate3d(${buttonOffset}px,0,0)`);
@@ -348,7 +347,7 @@ const Swipeout = {
348
347
  if (typeof buttonOffset === 'undefined') {
349
348
  $buttonEl[0].f7SwipeoutButtonOffset = buttonEl.offsetLeft;
350
349
  }
351
- if (isIOS) {
350
+ if (app.theme === 'ios') {
352
351
  $buttonEl.transform(`scale(0)`);
353
352
  } else {
354
353
  $buttonEl.transform(`translate3d(${-buttonOffset}px,0,0)`);
@@ -190,6 +190,11 @@ const Tab = {
190
190
  if (hasHighlight) {
191
191
  app.toolbar.setHighlight($tabbarEl);
192
192
  }
193
+ // Toolbar New Highlight
194
+ const $tabbarNewEl = $tabLinkEl.parents('.tabbar-new, .tabbar-new-icons');
195
+ if (app.toolbarNew && $tabbarNewEl.length > 0) {
196
+ app.toolbarNew.setHighlight($tabbarNewEl);
197
+ }
193
198
  }
194
199
  }
195
200
  return {
@@ -0,0 +1,134 @@
1
+ import { getDocument } from 'ssr-window';
2
+ const startAnimation = data => {
3
+ data.raf = requestAnimationFrame(() => {
4
+ if (!data.setTransform) return;
5
+ const highlightEl = data.highlightEl;
6
+ if (!highlightEl) return;
7
+ highlightEl.style.transform = data.setTransform;
8
+ highlightEl.style.transitionTimingFunction = 'ease-out';
9
+ data.setTransform = null;
10
+ });
11
+ };
12
+ const stopAnimation = data => {
13
+ cancelAnimationFrame(data.raf);
14
+ };
15
+ const setHighlightOnTouch = (data, e) => {
16
+ const {
17
+ rect,
18
+ linkEls,
19
+ highlightEl
20
+ } = data;
21
+ if (!highlightEl) return;
22
+ const {
23
+ clientX
24
+ } = e;
25
+ const highlightWidth = rect.width / linkEls.length;
26
+ const leftOffset = clientX - rect.left - highlightWidth / 2;
27
+ const minLeft = 0;
28
+ const maxLeft = rect.width - highlightWidth;
29
+ const translateX = Math.max(minLeft, Math.min(leftOffset, maxLeft));
30
+ const linkCenters = [...linkEls].map((el, index) => {
31
+ return index * highlightWidth + highlightWidth / 2;
32
+ });
33
+ const closestLinkCenter = linkCenters.reduce((prev, curr) => {
34
+ const highlightCenter = translateX + highlightWidth / 2;
35
+ return Math.abs(curr - highlightCenter) < Math.abs(prev - highlightCenter) ? curr : prev;
36
+ }, linkCenters[0]);
37
+ const closestLinkIndex = linkCenters.indexOf(closestLinkCenter);
38
+ data.newActiveIndex = closestLinkIndex;
39
+ highlightEl.classList.add('tab-link-highlight-pressed');
40
+ data.setTransform = `translateX(${translateX}px)`;
41
+ startAnimation(data);
42
+ };
43
+ const unsetHighlightOnTouch = data => {
44
+ cancelAnimationFrame(data.raf);
45
+ data.setTransform = null;
46
+ const {
47
+ highlightEl
48
+ } = data;
49
+ if (!highlightEl) return;
50
+ highlightEl.classList.remove('tab-link-highlight-pressed');
51
+ const {
52
+ activeIndex,
53
+ newActiveIndex,
54
+ linkEls
55
+ } = data;
56
+ if (activeIndex !== newActiveIndex) {
57
+ linkEls[newActiveIndex].click();
58
+ }
59
+ highlightEl.style.transform = `translateX(${newActiveIndex * 100}%)`;
60
+ highlightEl.style.transitionTimingFunction = '';
61
+ highlightEl.style.transform = `translateX(${newActiveIndex * 100}%)`;
62
+ };
63
+ export const initTabbarNewHighlight = el => {
64
+ const document = getDocument();
65
+ if (!el) return;
66
+ if (el.classList.contains('tabbar-new-scrollable')) {
67
+ return;
68
+ }
69
+ const highlightEl = el.querySelector('.tab-link-highlight');
70
+ const toolbarPaneEl = el.querySelector('.toolbar-new-pane');
71
+ if (!highlightEl || !toolbarPaneEl) return;
72
+ const data = {
73
+ el,
74
+ highlightEl,
75
+ touched: false,
76
+ moved: false,
77
+ rect: null,
78
+ setTransform: null,
79
+ raf: null
80
+ };
81
+ el.f7ToolbarNewHighlightData = data;
82
+ el.f7ToolbarNewOnPointer = e => {
83
+ if (e.type === 'touchstart') {
84
+ e.preventDefault();
85
+ }
86
+ if (e.pointerType !== 'touch') return;
87
+ if (!el) return;
88
+ if (e.type === 'pointerdown') {
89
+ data.linkEls = el.querySelectorAll('.tab-link');
90
+ data.rect = toolbarPaneEl.getBoundingClientRect();
91
+ data.touched = true;
92
+ setHighlightOnTouch(data, e);
93
+ startAnimation(data);
94
+ }
95
+ if (e.type === 'pointermove') {
96
+ if (!data.touched) return;
97
+ data.moved = true;
98
+ setHighlightOnTouch(data, e);
99
+ }
100
+ if (e.type === 'pointerup') {
101
+ if (!data.touched) return;
102
+ data.touched = false;
103
+ data.moved = false;
104
+ unsetHighlightOnTouch(data);
105
+ stopAnimation(data);
106
+ }
107
+ };
108
+ el.addEventListener('touchstart', el.f7ToolbarNewOnPointer, {
109
+ passive: false
110
+ });
111
+ el.addEventListener('pointerdown', el.f7ToolbarNewOnPointer, {
112
+ passive: false
113
+ });
114
+ document.addEventListener('pointermove', el.f7ToolbarNewOnPointer, {
115
+ passive: false
116
+ });
117
+ document.addEventListener('pointerup', el.f7ToolbarNewOnPointer, {
118
+ passive: false
119
+ });
120
+ document.addEventListener('pointercancel', el.f7ToolbarNewOnPointer, {
121
+ passive: false
122
+ });
123
+ };
124
+ export const destroyTabbarNewHighlight = el => {
125
+ if (!el || !el.f7ToolbarNewOnPointer) return;
126
+ const document = getDocument();
127
+ el.removeEventListener('touchstart', el.f7ToolbarNewOnPointer);
128
+ el.removeEventListener('pointerdown', el.f7ToolbarNewOnPointer);
129
+ document.removeEventListener('pointermove', el.f7ToolbarNewOnPointer);
130
+ document.removeEventListener('pointerup', el.f7ToolbarNewOnPointer);
131
+ document.removeEventListener('pointercancel', el.f7ToolbarNewOnPointer);
132
+ el.f7ToolbarNewOnPointer = null;
133
+ el.f7ToolbarNewHighlightData = null;
134
+ };