framework7 7.0.0-beta.10 → 7.0.0-beta.15
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/components/actions/actions-class.js +6 -1
- package/components/actions/actions-rtl.css +1 -1
- package/components/actions/actions.css +1 -1
- package/components/actions/actions.d.ts +2 -0
- package/components/actions/actions.js +1 -0
- package/components/actions/actions.lazy.js +1 -1
- package/components/actions/actions.less +3 -0
- package/components/breadcrumbs/breadcrumbs-aurora.less +2 -0
- package/components/breadcrumbs/breadcrumbs-ios.less +2 -0
- package/components/breadcrumbs/breadcrumbs-md.less +2 -0
- package/components/breadcrumbs/breadcrumbs-rtl.css +1 -0
- package/components/breadcrumbs/breadcrumbs-vars.less +36 -0
- package/components/breadcrumbs/breadcrumbs.css +1 -0
- package/components/breadcrumbs/breadcrumbs.d.ts +15 -0
- package/components/breadcrumbs/breadcrumbs.js +13 -0
- package/components/breadcrumbs/breadcrumbs.lazy.js +1 -0
- package/components/breadcrumbs/breadcrumbs.less +100 -0
- package/components/calendar/calendar-class.js +206 -122
- package/components/calendar/calendar-rtl.css +1 -1
- package/components/calendar/calendar-vars.less +6 -10
- package/components/calendar/calendar.css +1 -1
- package/components/calendar/calendar.d.ts +2 -0
- package/components/calendar/calendar.js +1 -0
- package/components/calendar/calendar.lazy.js +1 -1
- package/components/calendar/calendar.less +20 -16
- package/components/list-index/list-index.d.ts +1 -1
- package/components/modal/modal-class.js +10 -0
- package/components/notification/notification.d.ts +4 -4
- package/components/picker/picker-class.js +6 -6
- package/components/picker/picker-column.js +34 -270
- package/components/picker/picker-rtl.css +1 -1
- package/components/picker/picker.css +1 -1
- package/components/picker/picker.d.ts +2 -13
- package/components/picker/picker.js +0 -5
- package/components/picker/picker.lazy.js +1 -1
- package/components/picker/picker.less +28 -10
- package/components/popover/popover-class.js +15 -2
- package/components/popover/popover-rtl.css +1 -1
- package/components/popover/popover.css +1 -1
- package/components/popover/popover.d.ts +2 -0
- package/components/popover/popover.js +1 -0
- package/components/popover/popover.lazy.js +1 -1
- package/components/popover/popover.less +3 -0
- package/components/popup/popup-class.js +6 -1
- package/components/popup/popup-rtl.css +1 -1
- package/components/popup/popup.css +1 -1
- package/components/popup/popup.d.ts +4 -0
- package/components/popup/popup.js +1 -0
- package/components/popup/popup.lazy.js +1 -1
- package/components/popup/popup.less +4 -0
- package/components/preloader/preloader-ios.less +3 -0
- package/components/preloader/preloader-rtl.css +1 -1
- package/components/preloader/preloader.css +1 -1
- package/components/preloader/preloader.d.ts +4 -0
- package/components/progressbar/progressbar-aurora.less +32 -13
- package/components/progressbar/progressbar-ios.less +19 -7
- package/components/progressbar/progressbar-md.less +64 -28
- package/components/progressbar/progressbar-rtl.css +1 -1
- package/components/progressbar/progressbar.css +1 -1
- package/components/progressbar/progressbar.js +1 -1
- package/components/progressbar/progressbar.lazy.js +1 -1
- package/components/progressbar/progressbar.less +16 -4
- package/components/range/range.d.ts +23 -5
- package/components/sheet/sheet-class.js +6 -1
- package/components/sheet/sheet-rtl.css +1 -1
- package/components/sheet/sheet.css +1 -1
- package/components/sheet/sheet.d.ts +2 -0
- package/components/sheet/sheet.js +1 -0
- package/components/sheet/sheet.lazy.js +1 -1
- package/components/sheet/sheet.less +3 -0
- package/components/sortable/sortable.d.ts +5 -1
- package/components/sortable/sortable.js +15 -2
- package/components/sortable/sortable.lazy.js +1 -1
- package/components/statusbar/statusbar.d.ts +9 -9
- package/components/swiper/swiper-rtl.css +1 -1
- package/components/swiper/swiper.css +1 -1
- package/components/swiper/swiper.lazy.js +1 -1
- package/components/tabs/tabs.js +4 -5
- package/components/tabs/tabs.lazy.js +1 -1
- package/components/toast/toast.d.ts +2 -2
- package/components/toolbar/toolbar-aurora.less +0 -13
- package/components/toolbar/toolbar-md.less +0 -13
- package/components/toolbar/toolbar.js +1 -1
- package/components/toolbar/toolbar.less +13 -0
- package/components/view/view-class.js +8 -1
- package/components/view/view.d.ts +5 -1
- package/components/view/view.js +2 -0
- package/components/virtual-list/virtual-list-class.js +44 -7
- package/components/virtual-list/virtual-list.d.ts +2 -2
- package/components/virtual-list/virtual-list.lazy.js +1 -1
- package/framework7-bundle-rtl.css +252 -150
- package/framework7-bundle-rtl.min.css +4 -4
- package/framework7-bundle.css +237 -134
- package/framework7-bundle.esm.js +5 -4
- package/framework7-bundle.js +982 -724
- package/framework7-bundle.js.map +1 -1
- package/framework7-bundle.less +4 -3
- package/framework7-bundle.min.css +4 -4
- package/framework7-bundle.min.js +4 -4
- package/framework7-bundle.min.js.map +1 -1
- package/framework7-lite-bundle.esm.js +5 -4
- package/framework7-lite.esm.js +3 -3
- package/framework7-rtl.css +12 -21
- package/framework7-rtl.min.css +4 -4
- package/framework7-types.d.ts +5 -1
- package/framework7.css +11 -19
- package/framework7.d.ts +4 -0
- package/framework7.esm.js +3 -3
- package/framework7.js +49 -17
- package/framework7.js.map +1 -1
- package/framework7.less +3 -3
- package/framework7.min.css +4 -4
- package/framework7.min.js +4 -4
- package/framework7.min.js.map +1 -1
- package/modules/component/component.d.ts +2 -2
- package/modules/device/device.js +1 -1
- package/modules/router/back.js +11 -1
- package/modules/router/tab.js +1 -1
- package/package.json +10 -5
- package/shared/get-device.d.ts +0 -2
- package/shared/get-device.js +1 -2
package/components/tabs/tabs.js
CHANGED
|
@@ -211,12 +211,11 @@ const Tab = {
|
|
|
211
211
|
if ($tabLinkEl && $tabLinkEl.length > 0) {
|
|
212
212
|
$tabLinkEl.addClass('tab-link-active'); // Material Highlight
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
const $tabbarEl = $tabLinkEl.parents('.tabbar, .tabbar-labels');
|
|
215
|
+
const hasHighlight = app.toolbar && $tabbarEl.length > 0 && ($tabbarEl.hasClass('tabbar-highlight') || app.theme !== 'ios');
|
|
216
216
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
217
|
+
if (hasHighlight) {
|
|
218
|
+
app.toolbar.setHighlight($tabbarEl);
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
221
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function framework7ComponentLoader(t,a){void 0===a&&(a=!0);var e=t.$,n=t.utils,i=(t.getDevice,t.getSupport,t.Class,t.Modal,t.ConstructorMethods,t.ModalMethods,n.extend);const s={show(...t){const a=this;let n,i,s,r,l;1===t.length&&t[0]&&t[0].constructor===Object?(n=t[0].tabEl,i=t[0].tabLinkEl,s=t[0].animate,r=t[0].tabRoute,l=t[0].animatedInit):([n,i,s,r]=t,"boolean"==typeof t[1]&&([n,s,i,r]=t,t.length>2&&i.constructor===Object&&([n,s,r,i]=t))),void 0===s&&(s=!0);const o=e(n);if(r&&o[0]&&(o[0].f7TabRoute=r),!l&&(0===o.length||o.hasClass("tab-active")))return{$newTabEl:o,newTabEl:o[0]};let b;i&&(b=e(i));const h=o.parent(".tabs");if(0===h.length)return{$newTabEl:o,newTabEl:o[0]};a.swipeout&&(a.swipeout.allowOpen=!0);const d=[];function g(){d.forEach((t=>{t()}))}let c,p=!1;if(h.parent().hasClass("tabs-animated-wrap")){h.parent()[s?"removeClass":"addClass"]("not-animated");const t=parseFloat(h.css("transition-duration").replace(",","."));s&&t&&(h.transitionEnd(g),p=!0);const e=100*(a.rtl?o.index():-o.index());h.transform(`translate3d(${e}%,0,0)`)}h.parent().hasClass("tabs-swipeable-wrap")&&a.swiper&&(c=h.parent()[0].swiper,c&&c.activeIndex!==o.index()?(p=!0,c.once("slideChangeTransitionEnd",(()=>{g()})).slideTo(o.index(),s?void 0:0)):c&&c.animating&&(p=!0,c.once("slideChangeTransitionEnd",(()=>{g()}))));const u=h.children(".tab-active");if(u.removeClass("tab-active"),!l&&(!c||c&&!c.animating||c&&r)&&(u.hasClass("view")&&u.children(".page").length&&u.children(".page").each((t=>{e(t).trigger("page:tabhide"),a.emit("pageTabHide",t)})),u.trigger("tab:hide"),a.emit("tabHide",u[0])),o.addClass("tab-active"),!l&&(!c||c&&!c.animating||c&&r)&&(o.hasClass("view")&&o.children(".page").length&&o.children(".page").each((t=>{e(t).trigger("page:tabshow"),a.emit("pageTabShow",t)})),o.trigger("tab:show"),a.emit("tabShow",o[0])),!b&&(b=e("string"==typeof n?`.tab-link[href="${n}"]`:`.tab-link[href="#${o.attr("id")}"]`),(!b||b&&0===b.length)&&e("[data-tab]").each((t=>{o.is(e(t).attr("data-tab"))&&(b=e(t))})),r&&(!b||b&&0===b.length)&&(b=e(`[data-route-tab-id="${r.route.tab.id}"]`),0===b.length&&(b=e(`.tab-link[href="${r.url}"]`))),b.length>1&&o.parents(".page").length&&(b=b.filter((t=>e(t).parents(".page")[0]===o.parents(".page")[0])),"ios"===a.theme&&0===b.length&&r))){const t=o.parents(".page"),n=e(a.navbar.getElByPage(t));b=n.find(`[data-route-tab-id="${r.route.tab.id}"]`),0===b.length&&(b=n.find(`.tab-link[href="${r.url}"]`))}if(b.length>0){let t;if(u&&u.length>0){const a=u.attr("id");a&&(t=e(`.tab-link[href="#${a}"]`),(!t||t&&0===t.length)&&(t=e(`.tab-link[data-route-tab-id="${a}"]`))),(!t||t&&0===t.length)&&e("[data-tab]").each((a=>{u.is(e(a).attr("data-tab"))&&(t=e(a))})),(!t||t&&0===t.length)&&(t=b.siblings(".tab-link-active"))}else r&&(t=b.siblings(".tab-link-active"));if(t&&t.length>1&&u&&u.parents(".page").length&&(t=t.filter((t=>e(t).parents(".page")[0]===u.parents(".page")[0]))),t&&t.length>0&&t.removeClass("tab-link-active"),b&&b.length>0
|
|
1
|
+
(function framework7ComponentLoader(t,a){void 0===a&&(a=!0);var e=t.$,n=t.utils,i=(t.getDevice,t.getSupport,t.Class,t.Modal,t.ConstructorMethods,t.ModalMethods,n.extend);const s={show(...t){const a=this;let n,i,s,r,l;1===t.length&&t[0]&&t[0].constructor===Object?(n=t[0].tabEl,i=t[0].tabLinkEl,s=t[0].animate,r=t[0].tabRoute,l=t[0].animatedInit):([n,i,s,r]=t,"boolean"==typeof t[1]&&([n,s,i,r]=t,t.length>2&&i.constructor===Object&&([n,s,r,i]=t))),void 0===s&&(s=!0);const o=e(n);if(r&&o[0]&&(o[0].f7TabRoute=r),!l&&(0===o.length||o.hasClass("tab-active")))return{$newTabEl:o,newTabEl:o[0]};let b;i&&(b=e(i));const h=o.parent(".tabs");if(0===h.length)return{$newTabEl:o,newTabEl:o[0]};a.swipeout&&(a.swipeout.allowOpen=!0);const d=[];function g(){d.forEach((t=>{t()}))}let c,p=!1;if(h.parent().hasClass("tabs-animated-wrap")){h.parent()[s?"removeClass":"addClass"]("not-animated");const t=parseFloat(h.css("transition-duration").replace(",","."));s&&t&&(h.transitionEnd(g),p=!0);const e=100*(a.rtl?o.index():-o.index());h.transform(`translate3d(${e}%,0,0)`)}h.parent().hasClass("tabs-swipeable-wrap")&&a.swiper&&(c=h.parent()[0].swiper,c&&c.activeIndex!==o.index()?(p=!0,c.once("slideChangeTransitionEnd",(()=>{g()})).slideTo(o.index(),s?void 0:0)):c&&c.animating&&(p=!0,c.once("slideChangeTransitionEnd",(()=>{g()}))));const u=h.children(".tab-active");if(u.removeClass("tab-active"),!l&&(!c||c&&!c.animating||c&&r)&&(u.hasClass("view")&&u.children(".page").length&&u.children(".page").each((t=>{e(t).trigger("page:tabhide"),a.emit("pageTabHide",t)})),u.trigger("tab:hide"),a.emit("tabHide",u[0])),o.addClass("tab-active"),!l&&(!c||c&&!c.animating||c&&r)&&(o.hasClass("view")&&o.children(".page").length&&o.children(".page").each((t=>{e(t).trigger("page:tabshow"),a.emit("pageTabShow",t)})),o.trigger("tab:show"),a.emit("tabShow",o[0])),!b&&(b=e("string"==typeof n?`.tab-link[href="${n}"]`:`.tab-link[href="#${o.attr("id")}"]`),(!b||b&&0===b.length)&&e("[data-tab]").each((t=>{o.is(e(t).attr("data-tab"))&&(b=e(t))})),r&&(!b||b&&0===b.length)&&(b=e(`[data-route-tab-id="${r.route.tab.id}"]`),0===b.length&&(b=e(`.tab-link[href="${r.url}"]`))),b.length>1&&o.parents(".page").length&&(b=b.filter((t=>e(t).parents(".page")[0]===o.parents(".page")[0])),"ios"===a.theme&&0===b.length&&r))){const t=o.parents(".page"),n=e(a.navbar.getElByPage(t));b=n.find(`[data-route-tab-id="${r.route.tab.id}"]`),0===b.length&&(b=n.find(`.tab-link[href="${r.url}"]`))}if(b.length>0){let t;if(u&&u.length>0){const a=u.attr("id");a&&(t=e(`.tab-link[href="#${a}"]`),(!t||t&&0===t.length)&&(t=e(`.tab-link[data-route-tab-id="${a}"]`))),(!t||t&&0===t.length)&&e("[data-tab]").each((a=>{u.is(e(a).attr("data-tab"))&&(t=e(a))})),(!t||t&&0===t.length)&&(t=b.siblings(".tab-link-active"))}else r&&(t=b.siblings(".tab-link-active"));if(t&&t.length>1&&u&&u.parents(".page").length&&(t=t.filter((t=>e(t).parents(".page")[0]===u.parents(".page")[0]))),t&&t.length>0&&t.removeClass("tab-link-active"),b&&b.length>0){b.addClass("tab-link-active");const t=b.parents(".tabbar, .tabbar-labels");a.toolbar&&t.length>0&&(t.hasClass("tabbar-highlight")||"ios"!==a.theme)&&a.toolbar.setHighlight(t)}}return{$newTabEl:o,newTabEl:o[0],$oldTabEl:u,oldTabEl:u[0],onTabsChanged:function(t){d.push(t)},animated:p}}};var r={name:"tabs",create(){i(this,{tab:{show:s.show.bind(this)}})},on:{"pageInit tabMounted":function(t){const a=e(t.el||t).find(".tabs-animated-wrap > .tabs > .tab-active")[0];if(!a)return;this.tab.show({tabEl:a,animatedInit:!0,animate:!1})}},clicks:{".tab-link":function(t,a={}){if(t.attr("href")&&0===t.attr("href").indexOf("#")||t.attr("data-tab")){this.tab.show({tabEl:a.tab||t.attr("href"),tabLinkEl:t,animate:a.animate})}}}};if(a){if(t.prototype.modules&&t.prototype.modules[r.name])return;t.use(r),t.instance&&(t.instance.useModuleParams(r,t.instance.params),t.instance.useModule(r))}return r}(Framework7, typeof Framework7AutoInstallComponent === 'undefined' ? undefined : Framework7AutoInstallComponent))
|
|
@@ -10,19 +10,6 @@
|
|
|
10
10
|
}
|
|
11
11
|
.tabbar,
|
|
12
12
|
.tabbar-labels {
|
|
13
|
-
.tab-link-highlight {
|
|
14
|
-
position: absolute;
|
|
15
|
-
left: 0;
|
|
16
|
-
height: 2px;
|
|
17
|
-
background: var(--f7-tabbar-link-active-border-color, var(--f7-theme-color));
|
|
18
|
-
transition-duration: 300ms;
|
|
19
|
-
.ltr({
|
|
20
|
-
left: 0;
|
|
21
|
-
});
|
|
22
|
-
.rtl({
|
|
23
|
-
right: 0;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
13
|
.toolbar-inner {
|
|
27
14
|
padding-left: 0;
|
|
28
15
|
padding-right: 0;
|
|
@@ -26,19 +26,6 @@
|
|
|
26
26
|
overflow: hidden;
|
|
27
27
|
position: relative;
|
|
28
28
|
}
|
|
29
|
-
.tab-link-highlight {
|
|
30
|
-
position: absolute;
|
|
31
|
-
left: 0;
|
|
32
|
-
height: 2px;
|
|
33
|
-
background: var(--f7-tabbar-link-active-border-color, var(--f7-theme-color));
|
|
34
|
-
transition-duration: 300ms;
|
|
35
|
-
.ltr({
|
|
36
|
-
left: 0;
|
|
37
|
-
});
|
|
38
|
-
.rtl({
|
|
39
|
-
right: 0;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
29
|
}
|
|
43
30
|
|
|
44
31
|
.tabbar-labels {
|
|
@@ -3,8 +3,8 @@ import { nextFrame, bindMethods } from '../../shared/utils.js';
|
|
|
3
3
|
const Toolbar = {
|
|
4
4
|
setHighlight(tabbarEl) {
|
|
5
5
|
const app = this;
|
|
6
|
-
if (app.theme === 'ios') return;
|
|
7
6
|
const $tabbarEl = $(tabbarEl);
|
|
7
|
+
if (app.theme === 'ios' && !$tabbarEl.hasClass('tabbar-highlight')) return;
|
|
8
8
|
if ($tabbarEl.length === 0 || !($tabbarEl.hasClass('tabbar') || $tabbarEl.hasClass('tabbar-labels'))) return;
|
|
9
9
|
let $highlightEl = $tabbarEl.find('.tab-link-highlight');
|
|
10
10
|
const tabLinksCount = $tabbarEl.find('.tab-link').length;
|
|
@@ -153,6 +153,19 @@
|
|
|
153
153
|
height: var(--f7-tabbar-icon-size);
|
|
154
154
|
line-height: var(--f7-tabbar-icon-size);
|
|
155
155
|
}
|
|
156
|
+
.tab-link-highlight {
|
|
157
|
+
position: absolute;
|
|
158
|
+
left: 0;
|
|
159
|
+
height: 2px;
|
|
160
|
+
background: var(--f7-tabbar-link-active-border-color, var(--f7-theme-color));
|
|
161
|
+
transition-duration: 300ms;
|
|
162
|
+
.ltr({
|
|
163
|
+
left: 0;
|
|
164
|
+
});
|
|
165
|
+
.rtl({
|
|
166
|
+
right: 0;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
156
169
|
}
|
|
157
170
|
.tabbar-labels {
|
|
158
171
|
--f7-toolbar-height: var(--f7-tabbar-labels-height);
|
|
@@ -207,7 +207,14 @@ class View extends Framework7Class {
|
|
|
207
207
|
view.initMasterDetail();
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
view.
|
|
210
|
+
if (view.params.initRouterOnTabShow && view.$el.hasClass('tab') && !view.$el.hasClass('tab-active')) {
|
|
211
|
+
view.$el.once('tab:show', () => {
|
|
212
|
+
view.router.init();
|
|
213
|
+
});
|
|
214
|
+
} else {
|
|
215
|
+
view.router.init();
|
|
216
|
+
}
|
|
217
|
+
|
|
211
218
|
view.$el.trigger('view:init');
|
|
212
219
|
view.emit('local::init viewInit', view);
|
|
213
220
|
}
|
|
@@ -26,6 +26,8 @@ export namespace View {
|
|
|
26
26
|
destroy(): void;
|
|
27
27
|
}
|
|
28
28
|
interface Parameters {
|
|
29
|
+
/** If enabled and View is tab, it won't initialize router and load initial page until View tab becomes visible */
|
|
30
|
+
initRouterOnTabShow?: boolean;
|
|
29
31
|
/** View name. If view was created with name, then it may be accessed via app.views.[name] */
|
|
30
32
|
name?: string;
|
|
31
33
|
/** Specify whether this is View is main or not. If not passed then will be determined based on whether its element has view-main class or not */
|
|
@@ -142,7 +144,7 @@ export namespace View {
|
|
|
142
144
|
auroraSwipeBackAnimateShadow?: boolean;
|
|
143
145
|
/** Enable/disable opacity animation during swipe back action. You can disable it to improve performance. For Aurora theme */
|
|
144
146
|
auroraSwipeBackAnimateOpacity?: boolean;
|
|
145
|
-
/** If you develop web app (not
|
|
147
|
+
/** If you develop web app (not Cordova/Capacitor or Home Screen web app) it is useful to enable hash navigation (browser url will look like "http://my-webapp.com/#!/about.html"). User as well will be able to navigate through app's history by using browser's default back and forward buttons. */
|
|
146
148
|
browserHistory?: boolean;
|
|
147
149
|
/** Browser history root URL, for example "http://my-app.com/". It is useful only in case when you use empty ("") browserHistorySeparator */
|
|
148
150
|
browserHistoryRoot?: string;
|
|
@@ -158,6 +160,8 @@ export namespace View {
|
|
|
158
160
|
browserHistoryInitialMatch?: boolean;
|
|
159
161
|
/** When enabled (by default), it will store router history in localStorage and try to restore it on next web app visit */
|
|
160
162
|
browserHistoryStoreHistory?: boolean;
|
|
163
|
+
/** When "replace" (by default), it will replace state on routable tabs change, otherwise (if "push"), it will add to history every routable tab change, so it will be possible to switch back between tabs with browser back button */
|
|
164
|
+
browserHistoryTabs?: 'replace' | 'push';
|
|
161
165
|
/** Object with events handlers.. */
|
|
162
166
|
on?: {
|
|
163
167
|
[event in keyof Events]?: Events[event];
|
package/components/view/view.js
CHANGED
|
@@ -48,6 +48,7 @@ export default {
|
|
|
48
48
|
params: {
|
|
49
49
|
view: {
|
|
50
50
|
init: true,
|
|
51
|
+
initRouterOnTabShow: false,
|
|
51
52
|
name: undefined,
|
|
52
53
|
main: false,
|
|
53
54
|
router: true,
|
|
@@ -98,6 +99,7 @@ export default {
|
|
|
98
99
|
browserHistoryOnLoad: true,
|
|
99
100
|
browserHistoryInitialMatch: false,
|
|
100
101
|
browserHistoryStoreHistory: true,
|
|
102
|
+
browserHistoryTabs: 'replace',
|
|
101
103
|
// Animate Pages
|
|
102
104
|
animate: true,
|
|
103
105
|
// iOS Dynamic Navbar
|
|
@@ -122,7 +122,8 @@ class VirtualList extends Framework7Class {
|
|
|
122
122
|
rowsToRender: undefined,
|
|
123
123
|
maxBufferHeight: 0,
|
|
124
124
|
listHeight: undefined,
|
|
125
|
-
dynamicHeight: typeof vl.params.height === 'function'
|
|
125
|
+
dynamicHeight: typeof vl.params.height === 'function',
|
|
126
|
+
autoHeight: vl.params.height === 'auto'
|
|
126
127
|
}); // Install Modules
|
|
127
128
|
|
|
128
129
|
vl.useModules(); // Attach events
|
|
@@ -163,10 +164,13 @@ class VirtualList extends Framework7Class {
|
|
|
163
164
|
return vl;
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
setListSize() {
|
|
167
|
+
setListSize(autoHeightRerender) {
|
|
167
168
|
const vl = this;
|
|
168
169
|
const items = vl.filteredItems || vl.items;
|
|
169
|
-
|
|
170
|
+
|
|
171
|
+
if (!autoHeightRerender) {
|
|
172
|
+
vl.pageHeight = vl.$scrollableParentEl[0].offsetHeight;
|
|
173
|
+
}
|
|
170
174
|
|
|
171
175
|
if (vl.dynamicHeight) {
|
|
172
176
|
vl.listHeight = 0;
|
|
@@ -177,6 +181,31 @@ class VirtualList extends Framework7Class {
|
|
|
177
181
|
vl.listHeight += itemHeight;
|
|
178
182
|
vl.heights.push(itemHeight);
|
|
179
183
|
}
|
|
184
|
+
} else if (vl.autoHeight) {
|
|
185
|
+
vl.listHeight = 0;
|
|
186
|
+
if (!vl.heights) vl.heights = [];
|
|
187
|
+
if (!vl.heightsCalculated) vl.heightsCalculated = [];
|
|
188
|
+
const renderedItems = {};
|
|
189
|
+
vl.$itemsWrapEl.find(`[data-virtual-list-index]`).forEach(el => {
|
|
190
|
+
renderedItems[parseInt(el.getAttribute('data-virtual-list-index'), 10)] = el;
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
194
|
+
const renderedItem = renderedItems[i];
|
|
195
|
+
|
|
196
|
+
if (renderedItem) {
|
|
197
|
+
if (!vl.heightsCalculated.includes(i)) {
|
|
198
|
+
vl.heights[i] = renderedItem.offsetHeight;
|
|
199
|
+
vl.heightsCalculated.push(i);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (typeof vl.heights[i] === 'undefined') {
|
|
204
|
+
vl.heights[i] = 40;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
vl.listHeight += vl.heights[i];
|
|
208
|
+
}
|
|
180
209
|
} else {
|
|
181
210
|
vl.listHeight = Math.ceil(items.length / vl.params.cols) * vl.params.height;
|
|
182
211
|
vl.rowsPerScreen = Math.ceil(vl.pageHeight / vl.params.height);
|
|
@@ -211,7 +240,7 @@ class VirtualList extends Framework7Class {
|
|
|
211
240
|
let heightBeforeFirstItem = 0;
|
|
212
241
|
let heightBeforeLastItem = 0;
|
|
213
242
|
|
|
214
|
-
if (vl.dynamicHeight) {
|
|
243
|
+
if (vl.dynamicHeight || vl.autoHeight) {
|
|
215
244
|
let itemTop = 0;
|
|
216
245
|
let itemHeight;
|
|
217
246
|
vl.maxBufferHeight = vl.pageHeight;
|
|
@@ -278,7 +307,7 @@ class VirtualList extends Framework7Class {
|
|
|
278
307
|
|
|
279
308
|
|
|
280
309
|
if (i === fromIndex) {
|
|
281
|
-
if (vl.dynamicHeight) {
|
|
310
|
+
if (vl.dynamicHeight || vl.autoHeight) {
|
|
282
311
|
topPosition = heightBeforeFirstItem;
|
|
283
312
|
} else {
|
|
284
313
|
topPosition = i * vl.params.height / vl.params.cols;
|
|
@@ -296,7 +325,7 @@ class VirtualList extends Framework7Class {
|
|
|
296
325
|
|
|
297
326
|
|
|
298
327
|
if (!vl.updatableScroll) {
|
|
299
|
-
if (vl.dynamicHeight) {
|
|
328
|
+
if (vl.dynamicHeight || vl.autoHeight) {
|
|
300
329
|
vl.itemsWrapEl.style.height = `${heightBeforeLastItem}px`;
|
|
301
330
|
} else {
|
|
302
331
|
vl.itemsWrapEl.style.height = `${i * vl.params.height / vl.params.cols}px`;
|
|
@@ -336,6 +365,12 @@ class VirtualList extends Framework7Class {
|
|
|
336
365
|
items: renderExternalItems
|
|
337
366
|
});
|
|
338
367
|
}
|
|
368
|
+
|
|
369
|
+
if (vl.autoHeight) {
|
|
370
|
+
requestAnimationFrame(() => {
|
|
371
|
+
vl.setListSize(true);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
339
374
|
} // Filter
|
|
340
375
|
|
|
341
376
|
|
|
@@ -372,7 +407,7 @@ class VirtualList extends Framework7Class {
|
|
|
372
407
|
if (index > vl.items.length) return false;
|
|
373
408
|
let itemTop = 0;
|
|
374
409
|
|
|
375
|
-
if (vl.dynamicHeight) {
|
|
410
|
+
if (vl.dynamicHeight || vl.autoHeight) {
|
|
376
411
|
for (let i = 0; i < index; i += 1) {
|
|
377
412
|
itemTop += vl.heights[i];
|
|
378
413
|
}
|
|
@@ -400,6 +435,7 @@ class VirtualList extends Framework7Class {
|
|
|
400
435
|
const vl = this;
|
|
401
436
|
|
|
402
437
|
if (vl.isVisible()) {
|
|
438
|
+
vl.heightsCalculated = [];
|
|
403
439
|
vl.setListSize();
|
|
404
440
|
vl.render(true);
|
|
405
441
|
}
|
|
@@ -600,6 +636,7 @@ class VirtualList extends Framework7Class {
|
|
|
600
636
|
vl.domCache = {};
|
|
601
637
|
}
|
|
602
638
|
|
|
639
|
+
vl.heightsCalculated = [];
|
|
603
640
|
vl.setListSize();
|
|
604
641
|
vl.render(true);
|
|
605
642
|
}
|
|
@@ -80,8 +80,8 @@ export namespace VirtualList {
|
|
|
80
80
|
rowsAfter?: number;
|
|
81
81
|
/** Number of items per row. Doesn't compatible when using Virtual List with dynamic height (default 1) */
|
|
82
82
|
cols?: number;
|
|
83
|
-
/** If number - list item height in px. If function then function should return item height. By default equals to 44 for iOS theme, 48 for MD theme, and 38 for Aurora theme */
|
|
84
|
-
height?: number | Function;
|
|
83
|
+
/** If number - list item height in px. If function then function should return item height. If "auto" - will automatically calculate each items heights. By default equals to 44 for iOS theme, 48 for MD theme, and 38 for Aurora theme */
|
|
84
|
+
height?: number | Function | string;
|
|
85
85
|
/** This optional function allows to use custom function to render item HTML. It could be used instead of template parameter */
|
|
86
86
|
renderItem?(item: any): string;
|
|
87
87
|
/** This optional function allows to render DOM items using some custom method. Useful in case it is used (e.g.) with Vue/React plugin to pass DOM rendering and manipulation to Vue/React. renderParameters conaints object with the following properties: fromIndex, toIndex, listHeight, topPosition, items */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function framework7ComponentLoader(e,t){void 0===t&&(t=!0);var
|
|
1
|
+
(function framework7ComponentLoader(e,t){void 0===t&&(t=!0);var s=e.$,a=e.utils,l=e.getDevice,r=(e.getSupport,e.Class),i=(e.Modal,e.ConstructorMethods),n=(e.ModalMethods,a.extend),o=a.deleteProps;class h extends r{constructor(e,t={}){super(t,[e]);const a=this,r=l(),i=getDocument();let o;"md"===e.theme?o=48:"ios"===e.theme?o=44:"aurora"===e.theme&&(o=38);const h={cols:1,height:o,cache:!0,dynamicHeightBufferSize:1,showFilteredItemsOnly:!1,renderExternal:void 0,setListHeight:!0,searchByItem:void 0,searchAll:void 0,ul:null,createUl:!0,scrollableParentEl:void 0,renderItem:e=>`\n <li>\n <div class="item-content">\n <div class="item-inner">\n <div class="item-title">${e}</div>\n </div>\n </div>\n </li>\n `.trim(),on:{}};if(a.useModulesParams(h),a.params=n(h,t),void 0!==a.params.height&&a.params.height||(a.params.height=o),a.$el=s(t.el),a.el=a.$el[0],0===a.$el.length)return;a.$el[0].f7VirtualList=a,a.items=a.params.items,a.params.showFilteredItemsOnly&&(a.filteredItems=[]),a.params.renderItem&&(a.renderItem=a.params.renderItem),a.$pageContentEl=a.$el.parents(".page-content"),a.pageContentEl=a.$pageContentEl[0],a.$scrollableParentEl=a.params.scrollableParentEl?s(a.params.scrollableParentEl).eq(0):a.$pageContentEl,!a.$scrollableParentEl.length&&a.$pageContentEl.length&&(a.$scrollableParentEl=a.$pageContentEl),a.scrollableParentEl=a.$scrollableParentEl[0],void 0!==a.params.updatableScroll?a.updatableScroll=a.params.updatableScroll:(a.updatableScroll=!0,r.ios&&r.osVersion.split(".")[0]<8&&(a.updatableScroll=!1));const m=a.params.ul;let c;a.$ul=m?s(a.params.ul):a.$el.children("ul"),0===a.$ul.length&&a.params.createUl&&(a.$el.append("<ul></ul>"),a.$ul=a.$el.children("ul")),a.ul=a.$ul[0],c=a.ul||a.params.createUl?a.$ul:a.$el,n(a,{$itemsWrapEl:c,itemsWrapEl:c[0],domCache:{},displayDomCache:{},tempDomElement:i.createElement("ul"),lastRepaintY:null,fragment:i.createDocumentFragment(),pageHeight:void 0,rowsPerScreen:void 0,rowsBefore:void 0,rowsAfter:void 0,rowsToRender:void 0,maxBufferHeight:0,listHeight:void 0,dynamicHeight:"function"==typeof a.params.height,autoHeight:"auto"===a.params.height}),a.useModules();const p=a.handleScroll.bind(a),d=a.handleResize.bind(a);let g,f,u,I;return a.attachEvents=function(){g=a.$el.parents(".page").eq(0),f=a.$el.parents(".tab").filter((e=>0===s(e).parent(".tabs").parent(".tabs-animated-wrap, .tabs-swipeable-wrap").length)).eq(0),u=a.$el.parents(".panel").eq(0),I=a.$el.parents(".popup").eq(0),a.$scrollableParentEl.on("scroll",p),g.length&&g.on("page:reinit",d),f.length&&f.on("tab:show",d),u.length&&u.on("panel:open",d),I.length&&I.on("popup:open",d),e.on("resize",d)},a.detachEvents=function(){a.$scrollableParentEl.off("scroll",p),g.length&&g.off("page:reinit",d),f.length&&f.off("tab:show",d),u.length&&u.off("panel:open",d),I.length&&I.off("popup:open",d),e.off("resize",d)},a.init(),a}setListSize(e){const t=this,s=t.filteredItems||t.items;if(e||(t.pageHeight=t.$scrollableParentEl[0].offsetHeight),t.dynamicHeight){t.listHeight=0,t.heights=[];for(let e=0;e<s.length;e+=1){const a=t.params.height(s[e]);t.listHeight+=a,t.heights.push(a)}}else if(t.autoHeight){t.listHeight=0,t.heights||(t.heights=[]),t.heightsCalculated||(t.heightsCalculated=[]);const e={};t.$itemsWrapEl.find("[data-virtual-list-index]").forEach((t=>{e[parseInt(t.getAttribute("data-virtual-list-index"),10)]=t}));for(let a=0;a<s.length;a+=1){const s=e[a];s&&(t.heightsCalculated.includes(a)||(t.heights[a]=s.offsetHeight,t.heightsCalculated.push(a))),void 0===t.heights[a]&&(t.heights[a]=40),t.listHeight+=t.heights[a]}}else t.listHeight=Math.ceil(s.length/t.params.cols)*t.params.height,t.rowsPerScreen=Math.ceil(t.pageHeight/t.params.height),t.rowsBefore=t.params.rowsBefore||2*t.rowsPerScreen,t.rowsAfter=t.params.rowsAfter||t.rowsPerScreen,t.rowsToRender=t.rowsPerScreen+t.rowsBefore+t.rowsAfter,t.maxBufferHeight=t.rowsBefore/2*t.params.height;(t.updatableScroll||t.params.setListHeight)&&t.$itemsWrapEl.css({height:`${t.listHeight}px`})}render(e,t){const s=this;e&&(s.lastRepaintY=null);let a=-(s.$el[0].getBoundingClientRect().top-s.$scrollableParentEl[0].getBoundingClientRect().top);if(void 0!==t&&(a=t),!(null===s.lastRepaintY||Math.abs(a-s.lastRepaintY)>s.maxBufferHeight||!s.updatableScroll&&s.$scrollableParentEl[0].scrollTop+s.pageHeight>=s.$scrollableParentEl[0].scrollHeight))return;s.lastRepaintY=a;const l=s.filteredItems||s.items;let r,i,n,o=0,h=0;if(s.dynamicHeight||s.autoHeight){let e,t=0;s.maxBufferHeight=s.pageHeight;for(let l=0;l<s.heights.length;l+=1)e=s.heights[l],void 0===r&&(t+e>=a-2*s.pageHeight*s.params.dynamicHeightBufferSize?r=l:o+=e),void 0===i&&((t+e>=a+2*s.pageHeight*s.params.dynamicHeightBufferSize||l===s.heights.length-1)&&(i=l+1),h+=e),t+=e;i=Math.min(i,l.length)}else r=(parseInt(a/s.params.height,10)-s.rowsBefore)*s.params.cols,r<0&&(r=0),i=Math.min(r+s.rowsToRender*s.params.cols,l.length);const m=[];let c;for(s.reachEnd=!1,c=r;c<i;c+=1){let e;const t=s.items.indexOf(l[c]);c===r&&(s.currentFromIndex=t),c===i-1&&(s.currentToIndex=t),s.filteredItems?s.items[t]===s.filteredItems[s.filteredItems.length-1]&&(s.reachEnd=!0):t===s.items.length-1&&(s.reachEnd=!0),s.params.renderExternal?m.push(l[c]):s.domCache[t]?(e=s.domCache[t],e.f7VirtualListIndex=t):(s.renderItem?s.tempDomElement.innerHTML=s.renderItem(l[c],t).trim():s.tempDomElement.innerHTML=l[c].toString().trim(),e=s.tempDomElement.childNodes[0],s.params.cache&&(s.domCache[t]=e),e.f7VirtualListIndex=t),c===r&&(n=s.dynamicHeight||s.autoHeight?o:c*s.params.height/s.params.cols),s.params.renderExternal||(e.style.top=`${n}px`,s.emit("local::itemBeforeInsert vlItemBeforeInsert",s,e,l[c]),s.fragment.appendChild(e))}s.updatableScroll||(s.dynamicHeight||s.autoHeight?s.itemsWrapEl.style.height=`${h}px`:s.itemsWrapEl.style.height=c*s.params.height/s.params.cols+"px"),s.params.renderExternal?l&&0===l.length&&(s.reachEnd=!0):(s.emit("local::beforeClear vlBeforeClear",s,s.fragment),s.itemsWrapEl.innerHTML="",s.emit("local::itemsBeforeInsert vlItemsBeforeInsert",s,s.fragment),l&&0===l.length?(s.reachEnd=!0,s.params.emptyTemplate&&(s.itemsWrapEl.innerHTML=s.params.emptyTemplate)):s.itemsWrapEl.appendChild(s.fragment),s.emit("local::itemsAfterInsert vlItemsAfterInsert",s,s.fragment)),void 0!==t&&e&&s.$scrollableParentEl.scrollTop(t,0),s.params.renderExternal&&s.params.renderExternal(s,{fromIndex:r,toIndex:i,listHeight:s.listHeight,topPosition:n,items:m}),s.autoHeight&&requestAnimationFrame((()=>{s.setListSize(!0)}))}filterItems(e,t=!0){const s=this;s.filteredItems=[];for(let t=0;t<e.length;t+=1)s.filteredItems.push(s.items[e[t]]);t&&(s.$scrollableParentEl[0].scrollTop=0),s.update()}resetFilter(){const e=this;e.params.showFilteredItemsOnly?e.filteredItems=[]:(e.filteredItems=null,delete e.filteredItems),e.update()}scrollToItem(e){const t=this;if(e>t.items.length)return!1;let s=0;if(t.dynamicHeight||t.autoHeight)for(let a=0;a<e;a+=1)s+=t.heights[a];else s=e*t.params.height;const a=t.$el[0].offsetTop;return t.render(!0,a+s-parseInt(t.$scrollableParentEl.css("padding-top"),10)),!0}handleScroll(){this.render()}isVisible(){const e=this;return!!(e.el.offsetWidth||e.el.offsetHeight||e.el.getClientRects().length)}handleResize(){const e=this;e.isVisible()&&(e.heightsCalculated=[],e.setListSize(),e.render(!0))}appendItems(e){const t=this;for(let s=0;s<e.length;s+=1)t.items.push(e[s]);t.update()}appendItem(e){this.appendItems([e])}replaceAllItems(e){const t=this;t.items=e,delete t.filteredItems,t.domCache={},t.update()}replaceItem(e,t){const s=this;s.items[e]=t,s.params.cache&&delete s.domCache[e],s.update()}prependItems(e){const t=this;for(let s=e.length-1;s>=0;s-=1)t.items.unshift(e[s]);if(t.params.cache){const s={};Object.keys(t.domCache).forEach((a=>{s[parseInt(a,10)+e.length]=t.domCache[a]})),t.domCache=s}t.update()}prependItem(e){this.prependItems([e])}moveItem(e,t){const s=this,a=e;let l=t;if(a===l)return;const r=s.items.splice(a,1)[0];if(l>=s.items.length?(s.items.push(r),l=s.items.length-1):s.items.splice(l,0,r),s.params.cache){const e={};Object.keys(s.domCache).forEach((t=>{const r=parseInt(t,10),i=a<l?a:l,n=a<l?l:a,o=a<l?-1:1;(r<i||r>n)&&(e[r]=s.domCache[r]),r===i&&(e[n]=s.domCache[r]),r>i&&r<=n&&(e[r+o]=s.domCache[r])})),s.domCache=e}s.update()}insertItemBefore(e,t){const s=this;if(0!==e)if(e>=s.items.length)s.appendItem(t);else{if(s.items.splice(e,0,t),s.params.cache){const t={};Object.keys(s.domCache).forEach((a=>{const l=parseInt(a,10);l>=e&&(t[l+1]=s.domCache[l])})),s.domCache=t}s.update()}else s.prependItem(t)}deleteItems(e){const t=this;let s,a=0;for(let l=0;l<e.length;l+=1){let r=e[l];void 0!==s&&r>s&&(a=-l),r+=a,s=e[l];const i=t.items.splice(r,1)[0];if(t.filteredItems&&t.filteredItems.indexOf(i)>=0&&t.filteredItems.splice(t.filteredItems.indexOf(i),1),t.params.cache){const e={};Object.keys(t.domCache).forEach((s=>{const a=parseInt(s,10);a===r?delete t.domCache[r]:parseInt(s,10)>r?e[a-1]=t.domCache[s]:e[a]=t.domCache[s]})),t.domCache=e}}t.update()}deleteAllItems(){const e=this;e.items=[],delete e.filteredItems,e.params.cache&&(e.domCache={}),e.update()}deleteItem(e){this.deleteItems([e])}clearCache(){this.domCache={}}update(e){const t=this;e&&t.params.cache&&(t.domCache={}),t.heightsCalculated=[],t.setListSize(),t.render(!0)}init(){const e=this;e.attachEvents(),e.setListSize(),e.render()}destroy(){let e=this;e.detachEvents(),e.$el[0].f7VirtualList=null,delete e.$el[0].f7VirtualList,o(e),e=null}}var m={name:"virtualList",static:{VirtualList:h},create(){this.virtualList=i({defaultSelector:".virtual-list",constructor:h,app:this,domProp:"f7VirtualList"})}};if(t){if(e.prototype.modules&&e.prototype.modules[m.name])return;e.use(m),e.instance&&(e.instance.useModuleParams(m,e.instance.params),e.instance.useModule(m))}return m}(Framework7, typeof Framework7AutoInstallComponent === 'undefined' ? undefined : Framework7AutoInstallComponent))
|