Skip to content

Commit fd56931

Browse files
committed
https://github.com/framework7io/framework7/pull/4364
1 parent 3f58783 commit fd56931

File tree

16 files changed

+91
-51
lines changed

16 files changed

+91
-51
lines changed

src/core/components/data-table/data-table-class.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import Framework7Class from '../../shared/class.js';
44

55
class DataTable extends Framework7Class {
66
constructor(app, params = {}) {
7+
// El
8+
const $el = $(params.el);
9+
// Because temporarily does not support virtual lists, so if the element does not exist, we can return directly.
10+
if ($el[0].f7DataTable) return $el[0].f7DataTable;
11+
712
super(params, [app]);
813

914
const table = this;
@@ -15,19 +20,11 @@ class DataTable extends Framework7Class {
1520

1621
table.params = extend(defaults, params);
1722

18-
// El
19-
const $el = $(table.params.el);
2023
if ($el.length === 0) return undefined;
2124

2225
table.$el = $el;
2326
table.el = $el[0];
2427

25-
if (table.$el[0].f7DataTable) {
26-
const instance = table.$el[0].f7DataTable;
27-
table.destroy();
28-
return instance;
29-
}
30-
3128
table.$el[0].f7DataTable = table;
3229

3330
extend(table, {

src/core/components/form/form.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ const FormStorage = {
6868
const $formEl = $(formEl);
6969
const formId = $formEl.attr('id');
7070
if (!formId) return;
71+
// Check using data attribute
72+
if ($formEl[0]._f7FormStorageInitialized) {
73+
return;
74+
}
7175
const initialData = app.form.getFormData(formId);
7276
if (initialData) {
7377
app.form.fillFromData($formEl, initialData);
@@ -80,10 +84,12 @@ const FormStorage = {
8084
app.emit('formStoreData', $formEl[0], data);
8185
}
8286
$formEl.on('change submit', store);
87+
$formEl[0]._f7FormStorageInitialized = true; // Set flag
8388
},
8489
destroy(formEl) {
8590
const $formEl = $(formEl);
8691
$formEl.off('change submit');
92+
delete $formEl[0]._f7FormStorageInitialized; // Clear flag
8793
},
8894
};
8995

src/core/components/infinite-scroll/infinite-scroll.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const InfiniteScroll = {
4242
app.infiniteScroll.handle(this, e);
4343
}
4444
$el.each((element) => {
45+
// skip if already initialized
46+
if (element.f7InfiniteScrollHandler) return;
4547
element.f7InfiniteScrollHandler = scrollHandler;
4648
element.addEventListener('scroll', element.f7InfiniteScrollHandler);
4749
});

src/core/components/pull-to-refresh/pull-to-refresh-class.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import { getDevice } from '../../shared/get-device.js';
55

66
class PullToRefresh extends Framework7Class {
77
constructor(app, el) {
8+
const $el = $(el);
9+
if ($el[0].f7PullToRefresh) return $el[0].f7PullToRefresh;
10+
811
super({}, [app]);
912
const ptr = this;
1013
const device = getDevice();
11-
const $el = $(el);
1214
const $preloaderEl = $el.find('.ptr-preloader');
1315

1416
ptr.$el = $el;
@@ -27,7 +29,8 @@ class PullToRefresh extends Framework7Class {
2729
ptr.done = function done() {
2830
const $transitionTarget = isMaterial ? $preloaderEl : $el;
2931
const onTranstionEnd = (e) => {
30-
if ($(e.target).closest($preloaderEl).length) return;
32+
// Material Design platform currently does not support bottom preloader animation.
33+
if (!isMaterial && $(e.target).closest($preloaderEl).length) return;
3134
$el.removeClass('ptr-transitioning ptr-pull-up ptr-pull-down ptr-closing');
3235
$el.trigger('ptr:done');
3336
ptr.emit('local::done ptrDone', $el[0]);
@@ -204,7 +207,7 @@ class PullToRefresh extends Framework7Class {
204207
((!ptr.bottom && ptrScrollableEl.scrollTop > 0) ||
205208
(ptr.bottom &&
206209
ptrScrollableEl.scrollTop <
207-
ptrScrollableEl.scrollHeight - ptrScrollableEl.offsetHeight))
210+
ptrScrollableEl.scrollHeight - ptrScrollableEl.offsetHeight))
208211
) {
209212
targetIsScrollable = true;
210213
}
@@ -453,7 +456,7 @@ class PullToRefresh extends Framework7Class {
453456
((!ptr.bottom && ptrScrollableEl.scrollTop > 0) ||
454457
(ptr.bottom &&
455458
ptrScrollableEl.scrollTop <
456-
ptrScrollableEl.scrollHeight - ptrScrollableEl.offsetHeight))
459+
ptrScrollableEl.scrollHeight - ptrScrollableEl.offsetHeight))
457460
) {
458461
targetIsScrollable = true;
459462
}

src/core/components/swiper/swiper.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Swiper from 'swiper/bundle';
44
import { register } from 'swiper/element/bundle';
55
import $ from '../../shared/dom7.js';
66
import ConstructorMethods from '../../shared/constructor-methods.js';
7+
import { extend } from '../../shared/utils.js';
78

89
register();
910

@@ -19,8 +20,14 @@ function initSwiper(swiperEl) {
1920
const app = this;
2021
const $swiperEl = $(swiperEl);
2122
if ($swiperEl.length === 0) return;
22-
const isElement = $swiperEl[0].swiper && $swiperEl[0].swiper.isElement;
23+
if (!$swiperEl[0].swiper) return;
2324
if ($swiperEl[0].swiper && !$swiperEl[0].swiper.isElement) return;
25+
26+
// skip if already initialized
27+
if ($swiperEl[0]._f7SwiperInitialized) return;
28+
$swiperEl[0]._f7SwiperInitialized = true;
29+
30+
const isElement = $swiperEl[0].swiper && $swiperEl[0].swiper.isElement;
2431
let initialSlide;
2532
let params = {};
2633
let isTabs;
@@ -113,11 +120,13 @@ export default {
113120
},
114121
create() {
115122
const app = this;
116-
app.swiper = ConstructorMethods({
117-
defaultSelector: '.swiper',
123+
app.swiper = extend(ConstructorMethods({
124+
defaultSelector: ".swiper",
118125
constructor: Swiper,
119-
domProp: 'swiper',
120-
});
126+
domProp: "swiper"
127+
}), {
128+
init: initSwiper.bind(app)
129+
})
121130
},
122131
on: {
123132
pageMounted(page) {

src/core/components/toolbar/toolbar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const Toolbar = {
4545
let highlightTranslate;
4646

4747
if ($tabbarEl.hasClass('tabbar-scrollable') && $activeLink && $activeLink[0]) {
48+
if ($activeLink[0].offsetWidth == 0) {
49+
console.warn("ToolBar: ToolBar's scrollable indicator width is 0 because the first active tab width measured as 0.");
50+
};
4851
highlightWidth = `${$activeLink[0].offsetWidth}px`;
4952
highlightTranslate = `${$activeLink[0].offsetLeft}px`;
5053
} else {

src/react/components/chip.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const Chip = (props) => {
4545
};
4646

4747
const onDeleteClick = (event) => {
48-
event.stopPropagation();
4948
emit(props, 'delete', event);
5049
};
5150

src/react/components/page-content.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,15 @@ const PageContent = (props) => {
104104
f7.on('ptrPullEnd', onPtrPullEnd);
105105
f7.on('ptrRefresh', onPtrRefresh);
106106
f7.on('ptrDone', onPtrDone);
107+
// PTR only initializes in pageInit callback.
108+
// If page-content is added after page initialization, check if PTR exists.
109+
// If not, create it manually.
110+
f7.ptr.create(elRef.current);
107111
}
108112
if (infinite) {
109113
f7.on('infinite', onInfinite);
114+
// Same logic applies to infinite scroll
115+
f7.infiniteScroll.create(elRef.current);
110116
}
111117
});
112118
};

src/react/components/tabs.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useIsomorphicLayoutEffect } from '../shared/use-isomorphic-layout-effec
33
import { classNames, getExtraAttrs } from '../shared/utils.js';
44
import { colorClasses } from '../shared/mixins.js';
55
import { TabsSwipeableContext } from '../shared/tabs-swipeable-context.js';
6+
import { f7ready, f7 } from '../shared/f7.js';
67
import { setRef } from '../shared/set-ref.js';
78
/* dts-imports
89
import { SwiperOptions } from 'swiper';
@@ -28,6 +29,13 @@ const Tabs = (props) => {
2829
const elRef = useRef(null);
2930

3031
useIsomorphicLayoutEffect(() => {
32+
if (swipeable) {
33+
f7ready(() => {
34+
// It only initializes in pageInit callback
35+
// We may need to manually call init() to update the instance
36+
f7.swiper.init(elRef.current)
37+
});
38+
}
3139
if (!swipeable || !swiperParams) return;
3240
if (!elRef.current) return;
3341
Object.assign(elRef.current, swiperParams);

src/svelte/components/chip.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
const icon = $derived(useIcon(restProps));
4545
4646
function onDeleteClick(e) {
47-
e.stopPropagation();
4847
restProps.onDelete?.(e);
4948
restProps.ondelete?.(e);
5049
}

0 commit comments

Comments
 (0)