顺时针旋转图标360度
Rotate Icon 360 degrees clockwise angularjs
Angular新手在这里,我试图创建一个按钮,将有一个图标里面旋转360度一旦点击。现在我有了旋转,但它旋转了整个按钮,而不仅仅是元素。希望当按钮被点击时,它会旋转"蓝色方块"。(是的,我明白到目前为止,我只让按钮本身旋转,因为ng-click在按钮上,而div.box上没有任何内容)
HTML代码:<button ng-controller="fullRotation" ng-click="fullRotate()">Rotate
<div class="box"></div>
</button>
NG代码
var app = angular.module('app', []);
var fullRotation = function ($scope, $element) {
var degrees = 360;
$element.css('transition', '-webkit-transform 800ms ease');
$scope.fullRotate = function() {
$element.css('-webkit-transform', 'rotate(' + degrees + 'deg)');
degrees += 360;
};
}
演示这是一个寻找孩子的父母的简单回答。
对于将来寻找这个答案的任何人,我将所有。css()移动到fullRotate函数中,并添加了children()
$scope.fullRotate = function() {
console.log('im here');
$element.children().css('transition', '-webkit-transform 800ms ease');
$element.children().css('-webkit-transform', 'rotate(' + degrees + 'deg)');
degrees += 360;
};
Chrome demo
当你点击蓝框时,只有蓝框会旋转
<button >Rotate
<div class="box" ng-controller="fullRotation" ng-click="fullRotate()"></div>
</button>
当你点击按钮
时,只有蓝框旋转
$scope.fullRotate = function() {
console.log('im here');
$element.children().css('transition', 'transform 800ms ease');
$element.children().css('transform', 'rotate(' + degrees + 'deg)');
degrees += 360;
};
另一种方法是添加过渡到按钮css
/* Styles go here */
.box{
width: 70px;
height: 70px;
background: skyblue;
margin: 50px;
display: block;
transition: 800ms ease;
}
$scope.fullRotate = function() {
$element.children().css('-webkit-transform', 'rotate(' + degrees + 'deg)');
degrees += 360;
};
相关文章:
- 检测YouTube上的360度视频
- HTML/Javascript-360度图片的路径更改(显示不同的变化)
- 如何使我的功能360度旋转并上下移动
- 我有来自OpenWeatherMap API的风向数据,数据以0到360度表示.我想将其转换为文本格式
- Javascript动画和360度图像
- 如何防止物体在达到完整圆时旋转 360 度
- CSS3 变换从 360 度旋转到 0 度
- 360 度图像旋转指示器
- 360度画布圆弧中的间隙
- 旋转(360度)圆形分区内的文本框动画
- 使用Fabricjs将文本反转到360度
- 将2D画布(图像+文本)应用于3D表面,并进行360度旋转/动画-可以使用HTML5/CSS3/Javascript或F
- Three JS Camera Orientation以180度而不是360度返回值
- 图像旋转360度点击
- 是否有可能在手机浏览器上使用陀螺仪传感器播放360度Html5视频?
- 使用three.js和tween.js以90度增量旋转对象以创建360度循环
- 360度查看器中的图层更新空白-传单
- 360度全景与移动设备传感器控制
- 我可以用浏览器中的陀螺仪改变360度YouTube视频的视图吗?
- 顺时针旋转图标360度