Here is a reliable method for skipping an element's CSS transition, the code comes from Mozilla's X-Tag Web Components library:
var prefix = (function () {
var styles = window.getComputedStyle(document.documentElement, ''),
pre = (Array.prototype.slice
.call(styles)
.join('')
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1];
return {
dom: pre == 'ms' ? pre.toUpperCase() : pre,
lowercase: pre,
css: '-' + pre + '-',
js: pre[0].toUpperCase() + pre.substr(1)
};
})();
var requestFrame = (function(){
var raf = window.requestAnimationFrame ||
window[prefix.lowercase + 'RequestAnimationFrame'] ||
function(fn){ return window.setTimeout(fn, 20); };
return function(fn){
return raf.call(window, fn);
};
})();
var skipTransition = function(element, fn, bind){
var prop = prefix.js + 'TransitionProperty';
element.style[prop] = element.style.transitionProperty = 'none';
var callback;
if (fn) callback = fn.call(bind);
requestFrame(function(){
requestFrame(function(){
element.style[prop] = element.style.transitionProperty = '';
if (callback) requestFrame(callback);
});
});
};
HOW TO USE IT - this snippet assumes you have set a transition on the foo element's width and want to change it to 100px immediately without the element transitioning.
var foo = document.querySelector('#foo')
skipTransition(foo, function(){
foo.style.width = '100px';
});
LIVE EXAMPLE
Click each of the colored divs in the example - the red div has its width style set within the skipTransition function, thus preventing the transition and setting the style immediately. The blue div has its width set normally without skipTransition and the CSS transition effect occurs as normal: http://codepen.io/csuwldcat/pen/nFlse