@gem-sdk/components 2.0.0-dev.745 → 2.0.0-dev.747
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/dist/cjs/carousel/components/root/CustomSwiper.js +20 -8
- package/dist/cjs/carousel/index.js +1 -0
- package/dist/cjs/product/index.js +1 -0
- package/dist/esm/carousel/components/root/CustomSwiper.js +20 -8
- package/dist/esm/carousel/index.js +1 -0
- package/dist/esm/product/index.js +1 -0
- package/package.json +1 -1
- package/dist/cjs/carousel/components/root/load-swiper.js +0 -32
- package/dist/esm/carousel/components/root/load-swiper.js +0 -3
|
@@ -3,20 +3,32 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
|
|
6
|
+
// Preload Swiper use dynamic import and register when swiper is ready
|
|
7
|
+
let swiperModule = null;
|
|
8
|
+
const preloadSwiper = ()=>{
|
|
9
|
+
if (!swiperModule) {
|
|
10
|
+
import('swiper/element/bundle').then((module)=>{
|
|
11
|
+
swiperModule = module;
|
|
12
|
+
module.register();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
preloadSwiper();
|
|
6
17
|
function Swiper(props) {
|
|
7
18
|
const swiperRef = React.useRef(null);
|
|
8
19
|
const { children, totalSlides, onSwiperReady, sliderClass, ...sliderSetting } = props;
|
|
9
20
|
const pauseOnMouseEnter = typeof props.autoplay === 'object' && props.autoplay !== null ? props.autoplay.pauseOnMouseEnter : undefined;
|
|
10
21
|
React.useEffect(()=>{
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
const initializeSwiper = ()=>{
|
|
23
|
+
if (swiperModule) {
|
|
24
|
+
Object.assign(swiperRef.current, sliderSetting);
|
|
25
|
+
swiperRef.current.initialize();
|
|
26
|
+
onSwiperReady?.(swiperRef.current.swiper);
|
|
27
|
+
} else {
|
|
28
|
+
setTimeout(initializeSwiper, 10);
|
|
29
|
+
}
|
|
14
30
|
};
|
|
15
|
-
|
|
16
|
-
Object.assign(swiperRef.current, sliderSetting);
|
|
17
|
-
swiperRef.current.initialize();
|
|
18
|
-
const instance = swiperRef.current.swiper;
|
|
19
|
-
onSwiperReady?.(instance);
|
|
31
|
+
initializeSwiper();
|
|
20
32
|
}, []);
|
|
21
33
|
React.useEffect(()=>{
|
|
22
34
|
if (swiperRef.current?.swiper) {
|
|
@@ -11,6 +11,7 @@ require('../notification/components/Notice.js');
|
|
|
11
11
|
require('./components/product-button/types.js');
|
|
12
12
|
require('./components/product-variants/components/variants/index.js');
|
|
13
13
|
require('next/image');
|
|
14
|
+
require('../carousel/components/root/CustomSwiper.js');
|
|
14
15
|
require('../modal/components/confirm.js');
|
|
15
16
|
require('react-dom');
|
|
16
17
|
require('../video/components/Video.js');
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useRef, useEffect } from 'react';
|
|
3
3
|
|
|
4
|
+
// Preload Swiper use dynamic import and register when swiper is ready
|
|
5
|
+
let swiperModule = null;
|
|
6
|
+
const preloadSwiper = ()=>{
|
|
7
|
+
if (!swiperModule) {
|
|
8
|
+
import('swiper/element/bundle').then((module)=>{
|
|
9
|
+
swiperModule = module;
|
|
10
|
+
module.register();
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
preloadSwiper();
|
|
4
15
|
function Swiper(props) {
|
|
5
16
|
const swiperRef = useRef(null);
|
|
6
17
|
const { children, totalSlides, onSwiperReady, sliderClass, ...sliderSetting } = props;
|
|
7
18
|
const pauseOnMouseEnter = typeof props.autoplay === 'object' && props.autoplay !== null ? props.autoplay.pauseOnMouseEnter : undefined;
|
|
8
19
|
useEffect(()=>{
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
20
|
+
const initializeSwiper = ()=>{
|
|
21
|
+
if (swiperModule) {
|
|
22
|
+
Object.assign(swiperRef.current, sliderSetting);
|
|
23
|
+
swiperRef.current.initialize();
|
|
24
|
+
onSwiperReady?.(swiperRef.current.swiper);
|
|
25
|
+
} else {
|
|
26
|
+
setTimeout(initializeSwiper, 10);
|
|
27
|
+
}
|
|
12
28
|
};
|
|
13
|
-
|
|
14
|
-
Object.assign(swiperRef.current, sliderSetting);
|
|
15
|
-
swiperRef.current.initialize();
|
|
16
|
-
const instance = swiperRef.current.swiper;
|
|
17
|
-
onSwiperReady?.(instance);
|
|
29
|
+
initializeSwiper();
|
|
18
30
|
}, []);
|
|
19
31
|
useEffect(()=>{
|
|
20
32
|
if (swiperRef.current?.swiper) {
|
|
@@ -9,6 +9,7 @@ import '../notification/components/Notice.js';
|
|
|
9
9
|
import './components/product-button/types.js';
|
|
10
10
|
import './components/product-variants/components/variants/index.js';
|
|
11
11
|
import 'next/image';
|
|
12
|
+
import '../carousel/components/root/CustomSwiper.js';
|
|
12
13
|
import '../modal/components/confirm.js';
|
|
13
14
|
import 'react-dom';
|
|
14
15
|
import '../video/components/Video.js';
|
package/package.json
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var bundle = require('swiper/element/bundle');
|
|
4
|
-
var swiper = require('swiper');
|
|
5
|
-
var modules = require('swiper/modules');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, 'register', {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return bundle.register; }
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, 'Swiper', {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return swiper.Swiper; }
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, 'Autoplay', {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return modules.Autoplay; }
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(exports, 'Navigation', {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return modules.Navigation; }
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, 'Pagination', {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return modules.Pagination; }
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, 'Thumbs', {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () { return modules.Thumbs; }
|
|
32
|
-
});
|