Skip to content

Commit

Permalink
fix(with-without): fix IE 11 not supporting transform w/in svg
Browse files Browse the repository at this point in the history
  • Loading branch information
glassdimly committed Sep 17, 2019
1 parent ea5bb8a commit 3973bfc
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 17 deletions.
Expand Up @@ -74,14 +74,16 @@ class SvgAnimations extends withLitHtml() {
class="bolt-self-drawing-circle"
is="shadow-root"
>
<svg viewBox="-160 -160 320 320">
<circle
id="bolt-self-drawing-circle-outline"
class="bolt-self-drawing-circle-outline"
r="159"
stroke-dasharray="0 1000"
/>
</svg>
<div class="bolt-self-drawing-circle-rotation">
<svg viewBox="-160 -160 320 320">
<circle
id="bolt-self-drawing-circle-outline"
class="bolt-self-drawing-circle-outline"
r="159"
stroke-dasharray="0 1000"
/>
</svg>
</div>
</div>
`;
}
Expand Down
Expand Up @@ -10,15 +10,20 @@
}
}

.bolt-self-drawing-circle-rotation {
width: 100%;
height: 100%;
transform: rotate(70deg) scaleX(-1);
}

.bolt-self-drawing-circle-outline {
fill: transparent;
stroke: bolt-color(white);
stroke-width: 1;
transform: rotate(70deg) scaleX(-1);
}

@keyframes spin {
100% {
transform: rotateZ(-360deg);
}
}
}
11 changes: 11 additions & 0 deletions packages/with-without/js/handleActiveRegionChange.js
Expand Up @@ -209,29 +209,40 @@ const triggerActiveRegionChange = async (checked, wwoSwiper, init = false) => {
} else {
// The event handler for swiper doesn't respect await, so trigger here directly.

console.error('before restoreContentBeforeSlideIn');
await restoreContentBeforeSlideIn(inGroupAttrVal, mainWrapper);
console.error('before getCurriedAnimateContentOut');

await getCurriedAnimateContentOut(
outGroupAttrVal,
inGroupAttrVal,
mainWrapper,
)();

console.error('before once slideChangeTransitionEnd', wwoSwiper);

wwoSwiper.once(
'slideChangeTransitionEnd',
getCurriedAnimateContentIn(inGroupAttrVal, mainWrapper),
);
console.error('before wwoSwiper.slideNext or slidePrev');

if (withIsBecomingActive) {
wwoSwiper.slideNext();
} else {
wwoSwiper.slidePrev();
}

console.error('withIsBecomingActive', withIsBecomingActive);

}
return true;
};

const handleActiveRegionChangeRequest = (checked, wwoSwiper) => {
const animControllerEl = document.querySelector('#c-pega-wwo__wrapper');
const animIsInProgress = !!animControllerEl.getAttribute('anim-in-progress');
console.error('in handleActiveRegionChangeRequest', animIsInProgress);

if (animIsInProgress) {
return;
Expand Down
15 changes: 14 additions & 1 deletion packages/with-without/js/handleResize.js
@@ -1,6 +1,20 @@
import { triggerAnimateInOnInOnlyContent } from './handleActiveRegionChange';

let lastWindowHeight;
let lastWindowWidth;

const handleResize = () => {
// To fix Edge firing resize constantly.
const heightHasChanged =
window.innerHeight && window.innerHeight !== lastWindowHeight;
const widthHasChanged =
window.innerWidth && window.innerWidth !== lastWindowWidth;
if (!widthHasChanged || !heightHasChanged) {
return; // bail if no change.
}
lastWindowHeight = window.innerHeight;
lastWindowWidth = window.innerWidth;

// @TODO replace with theme token.
const isMobile = window.matchMedia('(max-width: 1200px)').matches;
const slideContentInner = Array.from(
Expand All @@ -13,7 +27,6 @@ const handleResize = () => {
)
? 'wo'
: 'w';

triggerAnimateInOnInOnlyContent(activeSlideString);

if (isMobile) {
Expand Down
5 changes: 4 additions & 1 deletion packages/with-without/js/with-without.js
Expand Up @@ -18,7 +18,7 @@ const toggleInputClass = '.c-pega-www__toggle-input';
const checkedValue = 'w';

// Initialize the swiper for sliding between with and without.
const wwoSwiper = new Swiper('.c-pega-wwo__swiper-container', {
const wwoSwiper = new Swiper('#c-pega-wwo__swiper-container', {
speed: 500,
spaceBetween: 0,
noSwiping: true,
Expand All @@ -45,10 +45,12 @@ Array.from(document.querySelectorAll(toggleInputClass)).forEach(el => {
const animControllerEl = document.querySelector('#c-pega-wwo__wrapper');

animControllerEl.addEventListener('animateStart', e => {
console.error('animateStart');
e.target.setAttribute('anim-in-progress', 1);
});

animControllerEl.addEventListener('animateEnd', e => {
console.error('animateEnd');
e.target.removeAttribute('anim-in-progress');
// If the animation state doesn't match the state of the toggle, transition.
const activeAttr = animControllerEl.getAttribute('active');
Expand All @@ -68,6 +70,7 @@ document.querySelectorAll('.c-pega-wwo__region-blocks').forEach(el => {
el.addEventListener('click', handleBlockTitleMobileAccordionClick);
});

// Set up the modals.
const learnMoreModal = document.querySelector('.c-pega-www__modal--learn-more');
const learnMoreVideo = document.querySelector('.c-pega-www__video--learn-more');

Expand Down
8 changes: 4 additions & 4 deletions packages/with-without/with-without.scss
Expand Up @@ -120,7 +120,7 @@ bolt-animate {
overflow: hidden;

@include bolt-mq(xlarge) {
min-height: unset;
min-height: 100%;
}
}

Expand Down Expand Up @@ -164,7 +164,7 @@ bolt-animate {
top: 0;
bottom: 0;
width: 100%;
max-width: unset;
max-width: 100%;
height: 100%;
}

Expand Down Expand Up @@ -251,7 +251,7 @@ bolt-animate {
}

&__circles-wrapper {
$pega-wwo--circles-top-padding: 17%;
$pega-wwo--circles-top-padding: 18%;
// For some reason, the calculation was off, and the circle wobbled.
$pega-wwo--circles-top-padding--height-calculation: 17.98225%;
display: none;
Expand Down Expand Up @@ -778,7 +778,7 @@ bolt-animate {
}

@include bolt-mq($from: xlarge) {
max-height: unset;
max-height: 100%;
overflow: visible;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/with-without/with-without.twig
Expand Up @@ -25,7 +25,7 @@
</div>
</div>
<div class="c-pega-wwo__swiper-container-wrapper">
<div class="c-pega-wwo__swiper-container">
<div class="c-pega-wwo__swiper-container" id="c-pega-wwo__swiper-container">
<article class="c-pega-wwo__swiper-wrapper swiper-wrapper swiper-no-swiping">
{# wo stands for "without" #}
<div class="c-pega-wwo__swiper-slide c-pega-wwo__swiper-slide-wo swiper-no-swiping swiper-slide">
Expand Down

0 comments on commit 3973bfc

Please sign in to comment.