当方法angular.module('delightMeterApp', [
])
.directive('delightMeter', function () {
function link($scope, $element, $attrs) {
document.getElementById("arc1").setAttribute("d", describeArc(200, 200, 100, -90, -56));
document.getElementById("arc2").setAttribute("d", describeArc(200, 200, 100, -54, -20));
document.getElementById("arc3").setAttribute("d", describeArc(200, 200, 100, -18, 16));
document.getElementById("arc4").setAttribute("d", describeArc(200, 200, 100, 18, 52));
document.getElementById("arc5").setAttribute("d", describeArc(200, 200, 100, 54, 90));
function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
var angleInRadians = (angleInDegrees - 90) * Math.PI / 180.0;
return {
x: centerX + (radius * Math.cos(angleInRadians)),
y: centerY + (radius * Math.sin(angleInRadians))
};
}
/* Function to draw single arcs recieving (start co-ordinateX,start co-ordinateY,radius,start angle, end angle) */
function describeArc(x, y, radius, startAngle, endAngle) {
var start = polarToCartesian(x, y, radius, endAngle);
var end = polarToCartesian(x, y, radius, startAngle);
var arcSweep = endAngle - startAngle <= 180 ? "0" : "1";
var d = [
"M", start.x, start.y,
"A", radius, radius, 0, arcSweep, 0, end.x, end.y
].join(" ");
return d;
}
function ScoreRotateNeedle(delightScore) {
$('.needleset').css({
"transform": "rotate(" + delightScore + "deg)",
"transform-origin": "50% 95%"
});
}
$scope.$watch('score', function () {
ScoreRotateNeedle($scope.score);
});
}
return {
restrict: 'E',
templateUrl: 'svgmeter.html',
scope: {
score: '=ngModel'
},
link: link
};
})
.controller('delightMeterController', function ($scope) {
$scope.delightScore = 0;
})
由于NSTimer而运行时如此:
delightScore
aMethod
是否在调用NSTimer* theTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0
target: self
selector: @selector(aMethod:)
userInfo: nil
repeats: YES];
的主线程(主线程)上运行,还是在单独的线程上运行?此外,NSTimer在aMethod
运行时是继续重复,还是等到theTimer
完成?
答案 0 :(得分:1)
NSTimer
调用在计划定时器的线程上的selector:
参数中传递的选择器。这可能是也可能不是主线。