[英]How to Rotate 180 Deg
I implemented spectrum color picker . 我实现了光谱颜色选择器 。 I'm trying to rotate the
.alphaSlider
180 deg. 我正在尝试将
.alphaSlider
旋转180度。 Of course I can do it with CSS (using transform: rotate(180deg)
), but that's sort of a hack, and, there will anyway be other problems. 当然,我可以使用CSS来做到这一点(使用
transform: rotate(180deg)
),但这有点像hack,而且总会有其他问题。 I want to do it using the JavaScript source file . 我想用JavaScript源文件来做。
How can I edit the source file so that I can rotate 180 Deg the .alphaSlider
? 如何编辑源文件,以便可以旋转180度
.alphaSlider
?
Here's the relevant code: 以下是相关代码:
Source: (Lines: 387-395) 来源:(行:387-395)
draggable(alphaSlider, function (dragX, dragY, e) {
currentAlpha = (dragX / alphaWidth);
isEmpty = false;
if (e.shiftKey) {
currentAlpha = Math.round(currentAlpha * 10) / 10;
}
move();
}, dragStart, dragStop);
Source: (Lines: 1068 - 1073) 资料来源:(行:1068-1073)
var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0];
var pageX = t0 && t0.pageX || e.pageX;
var pageY = t0 && t0.pageY || e.pageY;
var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
BOOM! 繁荣! Done.
做完了 See jsfiddle.
参见jsfiddle。 (Snippet doesn't allow me to post all the code.)
(摘录不允许我发布所有代码。)
Haven't tested in IE. 尚未在IE中进行测试。
http://jsfiddle.net/4z7d6ze5/2/ http://jsfiddle.net/4z7d6ze5/2/
Called like this: 这样称呼:
$(document).ready(function() {
$("#custom").spectrum({
color: "#FF0000",
showAlpha: true
});
$("#custom2").spectrum({
color: "#0000FF",
showAlpha: true,
alphaVertical: true
});
$("#custom3").spectrum({
color: "#00FF00",
showAlpha: true,
flipAlpha: true
});
$("#custom4").spectrum({
color: "#00FFFF",
showAlpha: true,
flipAlpha: true,
alphaVertical: true
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.