我有3个包含X,Y,Z坐标的点:
var A = {x: 100, y: 100, z: 80},
B = {x: 100, y: 175, z: 80},
C = {x: 100, y: 100, z: 120};
Run Code Online (Sandbox Code Playgroud)
坐标是来自3d CSS变换的像素.如何获得向量BA和BC之间的角度?数学公式会做,JavaScript代码会更好.谢谢.

我有一个简单的jQuery函数:
$('#selectable1 span').live('mousedown', function() {
var ff = $(this).css("font-family");
$("#family").val(ff);
});
Run Code Online (Sandbox Code Playgroud)
单击span元素(mousedown)时,输入(#family)将获取其字体系列值.它适用于FireFox,但在Chrome中,它仅适用于仅由一个单词组成的字体系列.格鲁吉亚将工作,但Times New Roman不会.
你可以在这里看到代码:
这有什么问题?感谢名单
我有一大段代码需要在某些时候插入到DOM中.该代码还包含一些变量:
<ul id="info'+value+'" class="info"><li class="hide"></li><li class="lock"><ul>
// just a piece of the code with variable "value"
Run Code Online (Sandbox Code Playgroud)
现在我在做:
var codeToInsert = "<some code/>"
codeToInsert.insertAfter('#someID');
Run Code Online (Sandbox Code Playgroud)
从性能的角度来看,有更好的方法吗?
我有一个获取所选文本的函数,通过鼠标选择文本,并将其添加到变量中.我想在所选文本中的变量周围添加标签 - 在该段落中.
$("p").live("mouseup",function() {
selection = getSelectedText();
if(selection.length >= 3) {
var $spn = $("<span></span>").html(selection).addClass("selected");
$("p").wrap($spn);
}
});
//Grab selected text
function getSelectedText(){
if(window.getSelection){
return window.getSelection().toString();
}
else if(document.getSelection){
return document.getSelection();
}
else if(document.selection){
return document.selection.createRange().text;
}
}
Run Code Online (Sandbox Code Playgroud)
我可以得到文本选择变量,但不是放置<span></span>段落中选定的文本<p>,我的函数将其包装在外面.
如何在段落中替换它?谢谢.
我可以检查元素是否具有以下特定属性:
if ($('#A').attr('myattr') !== undefined) {
// attribute exists
} else {
// attribute does not exist
}
Run Code Online (Sandbox Code Playgroud)
如何检查元素是否具有任何属性?
谢谢
我想在一个用77deg旋转的div上调整jQuery UI大小.结果完全无法控制.
要复制这个请:
有没有办法来解决这个问题?谢谢
我正在运行一个简单的本机 element.animate:
element.animate([{
transform: "translate(0px, 0)"
}, {
transform: "translate(200px, 0)"
}], {
duration: 1000,
iterations: 1,
delay: 0,
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
direction: 'normal',
fill: 'both'
});
Run Code Online (Sandbox Code Playgroud)
小提琴: http: //jsfiddle.net/tox47k28/
问题是动画结束后我无法为该元素设置任何变换样式。变换属性似乎被冻结了。
“解冻”该属性的唯一方法是在该动画上调用 .cancel() ,但随后该元素将恢复到其初始状态。
2014 年 10 月 29 日更新
演示: http: //jsfiddle.net/f27hpnjL/1/
您不能再使用“填充:两者”来“解冻”动画。如果你想稍后操作样式,你需要“fill:backwards”:
element.animate([{
transform: "translate(0px, 0)"
}, {
transform: "translate(200px, 0)"
}], {
duration: 1000,
iterations: 1,
delay: 0,
easing: 'cubic-bezier(0.4, 0, 0.2, 1)',
direction: 'normal',
fill: 'backwards' // Use this inorder to manipulate the style …Run Code Online (Sandbox Code Playgroud) 我正在尝试为一个简单的SVG SMIL动画添加一个计时功能.显然可以使用keySplines属性设置计时/缓动,但在我的示例中它不起作用:
<svg xmlns="http://www.w3.org/2000/svg" width="214" height="214" viewBox="0 0 24 24">
<rect style="fill:#000;" width="4" height="4" x="3" y="11">
<animateTransform attributeName="transform"
begin="0s" dur="2s" type="translate" from="0 0" to="40 0" repeatCount="4" fill="freeze"
calcMode="spline"
keySplines="0.4, 0, 0.2, 1"/>
</rect>
<rect style="fill:#ff0000;" width="4" height="4" x="3" y="16">
<animateTransform attributeName="transform"
begin="0s" dur="2s" type="translate" from="0 0" to="40 0" repeatCount="4" fill="freeze" />
</rect>
</svg>
Run Code Online (Sandbox Code Playgroud)
这是一个演示:http://jsfiddle.net/q4e4049s/,黑色应该有缓和
我想在Shopify主题中使用超过30个svg图标.为了便于阅读,我不想直接在.liquid模板中添加,而是使用include:
{% include 'some-icon' %}
Run Code Online (Sandbox Code Playgroud)
和some-icon.liquid有SVG代码
问题是所有这30个文件都必须驻留在我的Snippets目录中.对于Snippets中的所有其他文件,它将是一团糟.
是否可以在Shopify中创建一个额外的目录并从那里导入它们:
{% include 'MyIcons/some-icon' %}
Run Code Online (Sandbox Code Playgroud)
还有其他办法吗?谢谢
jquery ×6
svg ×2
text ×2
3d ×1
attributes ×1
dom ×1
html ×1
insert ×1
javascript ×1
performance ×1
polymer ×1
resizable ×1
rotation ×1
select ×1
shopify ×1
svg-animate ×1