1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- export default function effectInit(params) {
- const {
- effect,
- swiper,
- on,
- setTranslate,
- setTransition,
- overwriteParams,
- perspective
- } = params;
- on('beforeInit', () => {
- if (swiper.params.effect !== effect) return;
- swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`);
- if (perspective && perspective()) {
- swiper.classNames.push(`${swiper.params.containerModifierClass}3d`);
- }
- const overwriteParamsResult = overwriteParams ? overwriteParams() : {};
- Object.assign(swiper.params, overwriteParamsResult);
- Object.assign(swiper.originalParams, overwriteParamsResult);
- });
- on('setTranslate', () => {
- if (swiper.params.effect !== effect) return;
- setTranslate();
- });
- on('setTransition', (_s, duration) => {
- if (swiper.params.effect !== effect) return;
- setTransition(duration);
- });
- let requireUpdateOnVirtual;
- on('virtualUpdate', () => {
- if (!swiper.slides.length) {
- requireUpdateOnVirtual = true;
- }
- requestAnimationFrame(() => {
- if (requireUpdateOnVirtual && swiper.slides.length) {
- setTranslate();
- requireUpdateOnVirtual = false;
- }
- });
- });
- }
|