开发者

how to make changes permanently to css elements with -moz-transform?

开发者 https://www.devze.com 2023-03-11 21:20 出处:网络
var transform = [\'scale(\' + scale + \')\']; $.merge(transform, [\'rotate(\' + rotate + \'deg)\']); $(this).css(-moz-transform, transform.join(\' \'));
        var transform = ['scale(' + scale + ')'];
        $.merge(transform, ['rotate(' + rotate + 'deg)']);
        $(this).css(-moz-transform, transform.join(' '));

this block of code executes when an event is generated , the new scaling and rotation is added to css element,but whenever the same event is generated again the css element resets itself to the original size and position .The transformation is carried out after resetting during the second time开发者_高级运维.I want to eliminate the resetting of the element to original size and position.How can i make the change permanent in the first time when event is fired ,and build on it when the event is fired the second time? Please help thanks in advance


There's nothing wrong with this code, but keep in mind you're setting scale and rotate in absolute terms, not relative to its 'initial' state.

So each time this code executes, the -moz-transform property of your element is being overwritten. If you want to rotate and scale it based on it's current state, you'll have to keep track of your scale and rotate values and adjust them as necessary. e.g., if this code is in a loop, you can do rotate=rotate+5; or something like that.

You can also request these properties from the CSS using ($this).css('-moz-transform'), parse that to get the values you want, and update scale and rotate accordingly.

0

精彩评论

暂无评论...
验证码 换一张
取 消