Answer the question
In order to leave comments, you need to log in
About transform: rotate(). How to spin?
Good afternoon! I have a question about the frontend.
There is a regional vehicle tracking system. And there, for the bus icons, rotation is used to indicate the direction of its movement.
Previously, the rotation was implemented in JS like this:
$(marker._icon)[0].style.transform = $(marker._icon)[0].style.transform + " rotate("+pos.v.c+"deg)";
$(marker._icon)[0].style.transform = $(marker._icon)[0].style.transform + " rotate("+pos.v.c+"deg)";
$(marker._icon)[0].style['-webkit-transform'] = $(marker._icon)[0].style['-webkit-transform'] + " rotate("+pos.v.c+"deg)";
$(marker._icon)[0].style['-ms-transform'] = $(marker._icon)[0].style['-ms-transform'] + " rotate("+pos.v.c+"deg)";
$(marker._icon)[0].style['-moz-transform'] = $(marker._icon)[0].style['-moz-transform'] + " rotate("+pos.v.c+"deg)";
$(marker._icon)[0].style.transform = $(marker._icon)[0].style.transform + " rotate("+pos.v.c+"deg)";
and left only vendor prefixes, everything was restored in Chromium, but Mozilla began to completely ignore the turn (except for "nightly" builds). Answer the question
In order to leave comments, you need to log in
1. It's better to add/remove a class instead of winding up inline styles.
in tss it is easier to shove vendor prefixes. and the element will change the class that adds rotation to it through css.
2. https://github.com/Modernizr/Modernizr/wiki/HTML5-... -> imsky.github.io/cssFx
polyfill is a support script (js) that will help those browsers where there is no implementation of some things.
3. if you need custom rotations, then here's what
3.1 theoretically, in a few millennia, attr () support will appear inside any css property. so far only content: attr(some-attribute) is supported, i.e. pseudo element. in general, when it will be possible to use something like
div{
transform:rotate(attr(ang, deg));
}
var angle=12.5;
$(marker._icon).css({
transform:"rotate("+angle+"deg)"
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question