Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nolimits4web/swiper into …
Browse files Browse the repository at this point in the history
…feat/swiper7/angular-1
  • Loading branch information
vltansky committed Aug 18, 2021
2 parents e132ee8 + 8c77840 commit f2d873a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swiper-src",
"version": "7.0.0-alpha.34",
"version": "7.0.0-alpha.35",
"description": "Most modern mobile touch slider and framework with hardware accelerated transitions",
"scripts": {
"build:dev": "node scripts/build",
Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swiper",
"version": "7.0.0-alpha.34",
"version": "7.0.0-alpha.35",
"description": "Most modern mobile touch slider and framework with hardware accelerated transitions",
"typings": "swiper.d.ts",
"type": "module",
Expand Down
14 changes: 9 additions & 5 deletions src/modules/effect-creative/effect-creative.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default function EffectCreative({ swiper, extendParams, on }) {
creativeEffect: {
transformEl: null,
limitProgress: 1,
progressMultiplier: 1,
perspective: true,
prev: {
translate: [0, 0, 0],
Expand All @@ -32,6 +33,7 @@ export default function EffectCreative({ swiper, extendParams, on }) {
const setTranslate = () => {
const { slides } = swiper;
const params = swiper.params.creativeEffect;
const { progressMultiplier: multiplier } = params;
for (let i = 0; i < slides.length; i += 1) {
const $slideEl = slides.eq(i);
const slideProgress = $slideEl[0].progress;
Expand Down Expand Up @@ -63,12 +65,12 @@ export default function EffectCreative({ swiper, extendParams, on }) {
// set translate
t.forEach((value, index) => {
t[index] = `calc(${value}px + (${getTranslateValue(data.translate[index])} * ${Math.abs(
progress,
progress * multiplier,
)}))`;
});
// set rotates
r.forEach((value, index) => {
r[index] = data.rotate[index] * Math.abs(progress);
r[index] = data.rotate[index] * Math.abs(progress * multiplier);
});

$slideEl[0].style.zIndex = -Math.abs(Math.round(slideProgress)) + slides.length;
Expand All @@ -77,10 +79,12 @@ export default function EffectCreative({ swiper, extendParams, on }) {
const rotateString = `rotateX(${r[0]}deg) rotateY(${r[1]}deg) rotateZ(${r[2]}deg)`;
const scaleString =
progress < 0
? `scale(${1 + (1 - data.scale) * progress})`
: `scale(${1 - (1 - data.scale) * progress})`;
? `scale(${1 + (1 - data.scale) * progress * multiplier})`
: `scale(${1 - (1 - data.scale) * progress * multiplier})`;
const opacityString =
progress < 0 ? 1 + (1 - data.opacity) * progress : 1 - (1 - data.opacity) * progress;
progress < 0
? 1 + (1 - data.opacity) * progress * multiplier
: 1 - (1 - data.opacity) * progress * multiplier;
const transform = `translate3d(${translateString}) ${rotateString} ${scaleString}`;

// Set shadows
Expand Down
6 changes: 6 additions & 0 deletions src/types/modules/effect-creative.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ export interface CreativeEffectOptions {
* @default 1
*/
limitProgress?: number;
/**
* Allows to multiply slides transformations and opacity.
*
* @default 1
*/
progressMultipler?: number;
/**
* Enable this parameter if your custom transforms require 3D transformations (`translateZ`, `rotateX`, `rotateY` )
*
Expand Down

0 comments on commit f2d873a

Please sign in to comment.