From 3930d933ca1109737e62703efa3cb882d744a46b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 12 Aug 2014 16:23:44 -0400 Subject: [PATCH] Revert "CLEANUP: This file no longer seems to be used" This reverts commit 5c2893c8f9c2b64e99f24cf75f525ec1ac693bb9. --- .../discourse/lib/transition_helper.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 app/assets/javascripts/discourse/lib/transition_helper.js diff --git a/app/assets/javascripts/discourse/lib/transition_helper.js b/app/assets/javascripts/discourse/lib/transition_helper.js new file mode 100644 index 00000000000..262bc887ea9 --- /dev/null +++ b/app/assets/javascripts/discourse/lib/transition_helper.js @@ -0,0 +1,43 @@ +/** + CSS transitions are a PITA, often we need to queue some js after a transition, this helper ensures + it happens after the transition. + + SO: http://stackoverflow.com/questions/9943435/css3-animation-end-techniques + + + @class TransitionHelper + @namespace Discourse + @module Discourse +**/ + +var dummy, eventNameHash, transitionEnd, _getTransitionEndEventName; + +dummy = document.createElement("div"); + +eventNameHash = { + webkit: "webkitTransitionEnd", + Moz: "transitionend", + O: "oTransitionEnd", + ms: "MSTransitionEnd" +}; + +_getTransitionEndEventName = function() { + var retValue; + retValue = "transitionend"; + Object.keys(eventNameHash).some(function(vendor) { + if (vendor + "TransitionProperty" in dummy.style) { + retValue = eventNameHash[vendor]; + return true; + } + }); + return retValue; +}; +transitionEnd = _getTransitionEndEventName(); + +Discourse.TransitionHelper = { + after: function(element, callback) { + return $(element).on(transitionEnd, callback); + } +}; + +