-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
038d2e7
commit a651283
Showing
28 changed files
with
330 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
dist/components/swiper/swiper-class/components/core/manipulation/addSlide.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Support from '../../../utils/support'; | ||
|
||
export default function (index, slides) { | ||
const swiper = this; | ||
const { $wrapperEl, params, activeIndex } = swiper; | ||
let activeIndexBuffer = activeIndex; | ||
if (params.loop) { | ||
activeIndexBuffer -= swiper.loopedSlides; | ||
swiper.loopDestroy(); | ||
swiper.slides = $wrapperEl.children(`.${params.slideClass}`); | ||
} | ||
const baseLength = swiper.slides.length; | ||
if (index <= 0) { | ||
swiper.prependSlide(slides); | ||
return; | ||
} else if (index >= baseLength) { | ||
swiper.appendSlide(slides); | ||
return; | ||
} | ||
let newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer; | ||
|
||
const slidesBuffer = []; | ||
for (let i = baseLength - 1; i >= index; i -= 1) { | ||
const currentSlide = swiper.slides.eq(i); | ||
currentSlide.remove(); | ||
slidesBuffer.unshift(currentSlide); | ||
} | ||
|
||
if (typeof slides === 'object' && 'length' in slides) { | ||
for (let i = 0; i < slides.length; i += 1) { | ||
if (slides[i]) $wrapperEl.append(slides[i]); | ||
} | ||
newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer; | ||
} else { | ||
$wrapperEl.append(slides); | ||
} | ||
|
||
for (let i = 0; i < slidesBuffer.length; i += 1) { | ||
$wrapperEl.append(slidesBuffer[i]); | ||
} | ||
|
||
if (params.loop) { | ||
swiper.loopCreate(); | ||
} | ||
if (!(params.observer && Support.observer)) { | ||
swiper.update(); | ||
} | ||
if (params.loop) { | ||
swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); | ||
} else { | ||
swiper.slideTo(newActiveIndex, 0, false); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
dist/components/swiper/swiper-class/components/core/manipulation/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import appendSlide from './appendSlide'; | ||
import prependSlide from './prependSlide'; | ||
import addSlide from './addSlide'; | ||
import removeSlide from './removeSlide'; | ||
import removeAllSlides from './removeAllSlides'; | ||
|
||
export default { | ||
appendSlide, | ||
prependSlide, | ||
addSlide, | ||
removeSlide, | ||
removeAllSlides, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.