rstacruz / jquery.transit

Super-smooth CSS3 transformations and transitions for jQuery
http://ricostacruz.com/jquery.transit
7.3k stars 864 forks source link

Need clear transitions method. #158

Open jaunkst opened 10 years ago

jaunkst commented 10 years ago

Should remove all webkit transitions from the style. Example, Transitions can break css fixed styles and one may want to remove the transitions so their is no conflict.

jaunkst commented 10 years ago

an example.

parent_element

.fixed_element{style: "position:fixed; bottom:0px;}

$('parent_element').transition({ y: '40px' });

This would break the .fixed_element fixed position because the transform on its parent.

rolbr commented 10 years ago

While no duplicate of #18 (stop a transition), this might still be kind of related.

You may remove a transition by setting an empty transform like so:

var $element = $('parent_element');
$element.css('-webkit-transform', '');
$element.css('-ms-transform', '');
[...] // add vendor prefixes as necessary
$element.css('transform', '');
ullmark commented 10 years ago

:+1: I'm also in need of this, also in combination with a fixed element :)

pingram3541 commented 10 years ago

How about something like this...adds detection for browser prefixes.

var target = $('some_element');

target.transition({ blah: 'blah'},'','',transReset); //calls transReset after complete

function transReset(target){
  var transPrefix = ($.browser.webkit)  ? '-webkit-transform' :
                   ($.browser.mozilla) ? '-moz-transform' :
                   ($.browser.msie)    ? '-ms-transform' :
                   ($.browser.opera)   ? '-o-transform' : 'transform';
  target.css(transPrefix,'');
}
rharrell-southern commented 10 years ago

Just a note, $.browser is no longer used in jQuery 1.9+

pingram3541 commented 10 years ago

yup, there are a few others out there that would work...prefixfree.js, modernizr, https://github.com/codler/jQuery-Css3-Finalize or maybe even http://www.verious.com/qa/dynamic-css3-prefix-user-agent-detection/

dminkovsky commented 10 years ago

+1 on this. It would be great to have some method to clean up after .transition() and .css()

dminkovsky commented 10 years ago

By the way, these lines:

https://github.com/rstacruz/jquery.transit/blob/master/jquery.transit.js#L63:

  support.transition      = getVendorPropertyName('transition');

https://github.com/rstacruz/jquery.transit/blob/master/jquery.transit.js#L81-L88

  // Populate jQuery's `$.support` with the vendor prefixes we know.
  // As per [jQuery's cssHooks documentation](http://api.jquery.com/jQuery.cssHooks/),
  // we set $.support.transition to a string of the actual property name used.
  for (var key in support) {
    if (support.hasOwnProperty(key) && typeof $.support[key] === 'undefined') {
      $.support[key] = support[key];
    }
  }
cbess commented 9 years ago

+1 on this. Right now I use something like:

$panel.css('transition', 'none')

Baccanno commented 9 years ago

This is what I use for now too but isn't perfect at all