lib/assets/javascripts/up/flow.js.coffee in upjs-rails-0.10.5 vs lib/assets/javascripts/up/flow.js.coffee in upjs-rails-0.11.0

- old
+ new

@@ -62,11 +62,11 @@ @return {Promise} A promise that will be resolved when the page has been updated. ### replace = (selectorOrElement, url, options) -> - u.debug("Replace %o with %o", selectorOrElement, url) + u.debug("Replace %o with %o (options %o)", selectorOrElement, url, options) options = u.options(options) selector = if u.presence(selectorOrElement) selectorOrElement @@ -208,34 +208,31 @@ $old[insertionMethod]($wrapper) u.copyAttributes($new, $old) elementsInserted($wrapper.children(), options) - # Show the first element that was being prepended/appended. + # Reveal element that was being prepended/appended. reveal($wrapper, options) .then -> # Since we're adding content instead of replacing, we'll only # animate $new instead of morphing between $old and $new return up.animate($wrapper, transition, options) .then -> u.unwrapElement($wrapper) return else - # Make sure the old element is visible before replacing it. - # This mimicks what the browser does during a full page load. - reveal($old, options) - .then -> - # Wrap the replacement as a destroy animation, so $old will - # get marked as .up-destroying right away. - destroy $old, animation: -> - # Don't insert the new element after the old element. - # For some reason this will make the browser scroll to the - # bottom of the new element. - $new.insertBefore($old) - elementsInserted($new, options) - if $old.is('body') && transition != 'none' - u.error('Cannot apply transitions to body-elements (%o)', transition) - up.morph($old, $new, transition, options) + # Wrap the replacement as a destroy animation, so $old will + # get marked as .up-destroying right away. + destroy $old, animation: -> + # Don't insert the new element after the old element. + # For some reason this will make the browser scroll to the + # bottom of the new element. + $new.insertBefore($old) + elementsInserted($new, options) + if $old.is('body') && transition != 'none' + u.error('Cannot apply transitions to body-elements (%o)', transition) + # Morphing will also process options.reveal + up.morph($old, $new, transition, options) parseImplantSteps = (selector, options) -> transitionString = options.transition || options.animation || 'none' comma = /\ *,\ */ disjunction = selector.split(comma)