I thought about this some more, and I think it was also caused by the transition properties on the button.accordion and the button.accordionSecond selectors. Then, as the css loaded in IE, since the font size "changed", it had to transition. Other browsers didn't see this as a change because they parsed the stylesheet as a whole.
I also had a thought that it would be nice to skip the transition on the panel divisions when the page is navigated to or refreshed and persistence enabled. Doing that was a little trickier than I imagined, but not too bad once I got it. If you want to try this, add this in the stylesheet as shown:
Code:
div.panel {
margin-top: .5em;
margin-bottom: .5m;
width: 25%;
background-color: #ffffff;
color: #000000;
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
font-family: "Times New Roman", Times, serif;
}
div.panel.notransition {
transition: none !important;
}
And use this version of the script:
Code:
(function(){
var accs = document.querySelectorAll('.accordion, .accordionSecond'),
cookiename = 'accordionpersiting_73561',
persisted = document.cookie.match('(^|;)\x20*' + cookiename + '=([^;]*)'),
persisting = {}, i = accs.length, toggleClass = accs[0] && accs[0].classList?
function(el, name){el.classList.toggle(name);} : function(el, name){
var classes = el.className.split(' '), i = classes.length, has = false;
while(--i > -1){if(classes[i] === name){has = true; classes.splice(i, 1); break;}}
!has && classes.push(name);
el.className = classes.join(' ');
};
if(persisted && (persisted = persisted[2])){
var p = persisted.split('.'), l = p.length;
while(--l > -1){persisting[p[l]] = true;}
}
function clickfunction(trans){
var panel = this.nextElementSibling;
toggleClass(this, 'active');
if(trans === false){toggleClass(panel, 'notransition');}
panel.style.maxHeight = panel.style.maxHeight? null : panel.scrollHeight + "px";
if(trans === false){panel.offsetHeight; toggleClass(panel, 'notransition');}
persisting[this.getAttribute('data-index')] = !!panel.style.maxHeight;
}
while(--i > -1){
accs[i].setAttribute('data-index', i);
accs[i].addEventListener('click', clickfunction, false);
persisting[i] && clickfunction.apply(accs[i], [false]);
}
window.addEventListener('unload', function(){
var pa = [], p;
for(p in persisting){persisting.hasOwnProperty(p) && persisting[p] && pa.push(p);}
document.cookie = cookiename + "=" + pa.join('.') + "; path=/";
}, false);
})();
It includes enhanced backward compatibility for IE 9's lack of the classList.toggle() function, while allowing those browsers that do support it to use it.
Bookmarks