effect-init.js 889 B

12345678910111213141516171819202122232425262728293031
  1. export default function effectInit(params) {
  2. const {
  3. effect,
  4. swiper,
  5. on,
  6. setTranslate,
  7. setTransition,
  8. overwriteParams,
  9. perspective
  10. } = params;
  11. on('beforeInit', () => {
  12. if (swiper.params.effect !== effect) return;
  13. swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`);
  14. if (perspective && perspective()) {
  15. swiper.classNames.push(`${swiper.params.containerModifierClass}3d`);
  16. }
  17. const overwriteParamsResult = overwriteParams ? overwriteParams() : {};
  18. Object.assign(swiper.params, overwriteParamsResult);
  19. Object.assign(swiper.originalParams, overwriteParamsResult);
  20. });
  21. on('setTranslate', () => {
  22. if (swiper.params.effect !== effect) return;
  23. setTranslate();
  24. });
  25. on('setTransition', (_s, duration) => {
  26. if (swiper.params.effect !== effect) return;
  27. setTransition(duration);
  28. });
  29. }