IOS Safari transition transform not working
34,047
Old versions of iOS Safari support only vendor-prefixed properties and values for transition
and transform
, so you should use -webkit-transition: -webkit-transform
instead -webkit-transition: transform
:
$('button').on('click', function() {
$('.mydiv').toggleClass('added-class');
});
.mydiv {
display: inline-block;
width: 100px;
height: 50px;
background-color: red;
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
-ms-transform: translateY(0);
-o-transform: translateY(0);
transform: translateY(0);
-webkit-transition: -webkit-transform 0.6s ease-out;
-moz-transition: transform 0.6s ease-out;
-o-transition: transform 0.6s ease-out;
transition: transform 0.6s ease-out;
}
.added-class {
-webkit-transform: translateY(100%);
-moz-transform: translateY(100%);
-ms-transform: translateY(100%);
-o-transform: translateY(100%);
transform: translateY(100%);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="mydiv"></div>
<button type="button">Toggle class</button>
Author by
ui-matt
Updated on June 19, 2020Comments
-
ui-matt almost 4 years
Whenever I seem to apply some code to let's say move a div for example using the latest iOS Safari browser it doesn't actually transition between the two rules set. I have tried changing to use other than percentage values but still to this day, I have never been able to get it to work when I use
transition: transform;
for anytranslate
property applied.I'm using the correct prefixes and checked support and should be working no problem.
http://caniuse.com/#search=transition
http://caniuse.com/#search=translate
$('button').on('click', function() { $('.mydiv').toggleClass('added-class'); });
.mydiv { display: inline-block; width: 100px; height: 50px; background-color: red; -moz-transform: translateY(0); -ms-transform: translateY(0); -o-transform: translateY(0); -webkit-transform: translateY(0); transform: translateY(0); -moz-transition: transform 0.6s ease-out; -o-transition: transform 0.6s ease-out; -webkit-transition: transform 0.6s ease-out; transition: transform 0.6s ease-out; } .added-class { -moz-transform: translateY(100%); -ms-transform: translateY(100%); -o-transform: translateY(100%); -webkit-transform: translateY(100%); transform: translateY(100%); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="mydiv"></div> <button type="button">Toggle class</button>