updateSize.js 703 B

12345678910111213141516171819202122232425262728
  1. export default function updateSize() {
  2. const swiper = this;
  3. let width;
  4. let height;
  5. const el = swiper.el;
  6. if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
  7. width = swiper.params.width;
  8. } else {
  9. width = el.width;
  10. }
  11. if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
  12. height = swiper.params.height;
  13. } else {
  14. height = el.height;
  15. }
  16. if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
  17. return;
  18. } // Subtract paddings
  19. if (Number.isNaN(width)) width = 0;
  20. if (Number.isNaN(height)) height = 0;
  21. Object.assign(swiper, {
  22. width,
  23. height,
  24. size: swiper.isHorizontal() ? width : height
  25. });
  26. }