【发布时间】:2018-02-13 21:40:30
【问题描述】:
我正在使用Jquery和css来实现Following
1) 图像翻转(左、右)
2) 图像旋转(左、右)
下面的图片会更好地解释它。
现在我正在使用以下代码来执行此操作..
var transform = 180;
var ImgRotate = 0;
$(".tab_content").hide();
$(".tab_content:first").show();
$('#ibtnFlipRight').click(function () {
var Img = $('#ImgPopUpTab2').find('img');
$(".ImgOfPopUpTab2").css({ 'transform': 'rotateY(' + transform + 'deg)' });
transform = transform + 180;
});
$('#ibtnFlipLeft').click(function () {
var Img = $('#ImgPopUpTab2').find('img');
$(".ImgOfPopUpTab2").css({ 'transform': 'rotateY(' + transform + 'deg)' });
transform = transform - 180;
});
$('#ibtnRotateRight').click(function () {
ImgRotate = ImgRotate + 90;
var Img = $('#ImgPopUpTab2').find('img');
$(".ImgOfPopUpTab2").css({ 'transform': 'rotateZ(' + ImgRotate + 'deg)' });
});
$('#ibtnRotateLeft').click(function () {
ImgRotate = ImgRotate - 90;
var Img = $('#ImgPopUpTab2').find('img');
$(".ImgOfPopUpTab2").css({ 'transform': 'rotateZ(' + ImgRotate + 'deg)' });
});
现在假设我点击向右/向左旋转 然后点击翻转它会覆盖旋转。
所以我需要一个使用它的解决方案,用户可以旋转图像并翻转它。
谢谢
【问题讨论】:
-
将当前的旋转(度)和翻转(true/false)保存在img的属性中,如data-rot="90" data-flipped="true"
标签: javascript jquery css jquery-plugins