我搜索了这么多链接,并且不能很好地了解经典继承和原型继承之间的区别?
我从中学到了一些东西,但我仍然对这些概念感到困惑.
经典继承
// Shape - superclass
function Shape() {
this.x = 0;
this.y = 0;
}
//superclass method
Shape.prototype.move = function(x, y) {
this.x += x;
this.y += y;
console.info("Shape moved.");
};
// Rectangle - subclass
function Rectangle() {
Shape.call(this); //call super constructor.
}
//subclass extends superclass
Rectangle.prototype = Object.create(Shape.prototype);
Run Code Online (Sandbox Code Playgroud)
经典继承是否在内部使用原型继承?
http://aaditmshah.github.io/why-prototypal-inheritance-matters/
从上面的链接,我了解到我们不能在运行时在经典继承中添加新方法.它是否正确?但是你可以查看上面的代码我可以在运行时通过原型添加"move"方法和任何方法.那么这是基于原型的经典继承吗?如果是这样,什么是实际的经典继承和原型继承?我很困惑.
原型继承.
function Circle(radius) {
this.radius = radius;
}
Circle.prototype.area = function () {
var radius = this.radius;
return Math.PI * …
Run Code Online (Sandbox Code Playgroud) 请参考以下代码我试过的内容
<div class="row">
<div class="center-block">First Div</div>
<div class="center-block">Second DIV </div>
</div>
Run Code Online (Sandbox Code Playgroud)
输出:
First Div
SecondDiv
Run Code Online (Sandbox Code Playgroud)
预期产量:
First Div Second Div
Run Code Online (Sandbox Code Playgroud)
我想使用bootstrap css将两个div水平对齐到页面.我怎样才能做到这一点 ?我不想使用简单的CSS和浮动概念来做到这一点.因为我需要使用bootstrap css来处理所有类型的布局(即所有窗口大小和分辨率),而不是使用媒体查询.
我想通过jquery/javascript计算div元素的边界框.
我试过这样的.
//Left side of box
document.getElementById("myElement").offsetLeft;
//Top side of box
document.getElementById("myElement").offsetTop;
//Right side of box
document.getElementById("myElement").offsetLeft + document.getElementById("myElement").offsetWidth;
//Bottom side of box
document.getElementById("myElement").offsetTop + document.getElementById("myElement").offsetHeight;
Run Code Online (Sandbox Code Playgroud)
它返回一些值.是否正确获取div元素的边界框jquery / javascript
.
我需要像元素中的getBBox()
方法 一样的东西SVG
.它将返回元素的x,y,宽度和高度.同样如何才能获得div元素的边界框.
谢谢,
湿婆
请参考以下代码.
$(this.element).on("mousewheel", this.chartMouseWheel);
chartMouseWheel:function(e) {
if(e.originalEvent.wheelDelta /120 > 0) {
alert('scrolling up !');
}
else{
alert('scrolling down !');
}
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
},
Run Code Online (Sandbox Code Playgroud)
这个事件在IE中正确触发,Chrome并没有在Firefox中触发?
我想在jquery中获取svg路径的getBBox().我试过这样的
$("#"+ path id)[0].getBBox() -> returns x=0,y=0,width=0,height=0
Run Code Online (Sandbox Code Playgroud)
我已经添加了SVG元素的路径.我在SVG中尝试了一些其他元素,例如文本节点,在这种情况下它返回一些边界框值.
如何计算SVG中路径的边界框?
<path id="container_svg_John_0" fill="none" stroke-width="3" stroke="url(#container_svg_John0Gradient)" stroke-linecap="butt" stroke-linejoin="round" d="M -2390.2 -125.8888888888889 L 0 0 M 0 0 L 251.60000000000002 -45.77777777777778 M 251.60000000000002 -45.77777777777778 L 503.20000000000005 -11.444444444444445 M 503.20000000000005 -11.444444444444445 L 629 -183.11111111111111 "/>
Run Code Online (Sandbox Code Playgroud) ASAIK jquery动画功能仅接受样式属性.但我想动画一个元素的属性.考虑一个SVG元素矩形
<svg>
<rect id="rect1" x=10 y=20 width="100px" height="100px">
</svg>
Run Code Online (Sandbox Code Playgroud)
我想动画矩形元素属性"x"和"y",如下所示
$("#rect1").animate({
x: 30,
y: 40
}, 1500 );
Run Code Online (Sandbox Code Playgroud)
但这不是正确的方法,因为动画功能会影响样式而不是元素的属性.
我知道有很多自定义插件就像raphel.js.
但我不想使用自定义插件来做到这一点.我想简单地在jquery.animate函数中这样做.
这可能吗 ?
谢谢,
湿婆
我是ASP.NET Web API的新手.有谁能告诉我
我想在固定位置缩放下面的元素.
<path id="container_svg_rectsymbol1" fill="red" stroke-width="1" stroke="Gray" d="M 73.1111111111111 -71.75 L 83.1111111111111 -71.75 L 83.1111111111111 -61.75 L 73.1111111111111 -61.75 L 73.1111111111111 -71.75" transform="scale(1)"/>
Run Code Online (Sandbox Code Playgroud)
当我开始缩放时,它从一个位置移动到另一个位置.我不想移动对象我只想扩大对象的大小.
我已经提到以下链接.
http://commons.oreilly.com/wiki/index.php/SVG_Essentials/Transforming_the_Coordinate_System
怎么做固定缩放?
我想为元素设置动画,即在固定位置放大尺寸.我已按以下方式实施.但它会从原点移动元素.请参考以下代码.
var box = element.getBBox();
var scaleVal=null, x=null, y=null;
$(element).animate(
{
scale: 1,
centerX:box.x+(4*transX),
centerY:box.y+(4*transY)
},
{
duration: 4000,
step: function(now,fx) {
if (fx.prop == "scale") {
scaleVal = now;
} else if (fx.prop == "centerX") {
x = now;
} else if (fx.prop == "centerY") {
y = now;
}
if(!sf.util.isNullOrUndefined(scaleVal) && !sf.util.isNullOrUndefined(x) …
Run Code Online (Sandbox Code Playgroud) svg scale coordinate-transformation jquery-svg jquery-animate
我们刚开始使用NPOI组件.
我们遇到了设置ICellStyle属性的FillForegroundColor的问题.
ICellStyle HeaderCellStyle = xssfworkbook.CreateCellStyle();
HeaderCellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.RED.index;
Run Code Online (Sandbox Code Playgroud)
FillForegroundColor期望类型为short.
我们如何设置不同的颜色而不是在HSSFColor中使用颜色.
我们需要设置"RGB192:0:0"
以及如何为ICellStyle属性FillForegroundColor执行此操作
Colud有人通过一些例子来帮助我们吗?
我想基于鼠标移动移动矩形.请参考以下链接.
http://atomicrobotdesign.com/blog_media/draw/draw1.html
在mousedown事件中获取矩形起始位置并开始拖动它将在鼠标移动事件中创建矩形.但是当我移动到先前的值(即移动到小于鼠标按下值时,它将返回负值),因此宽度变为负值.
上面的链接是画布矩形.但我创建了具有相同逻辑的svg矩形.
不支持矩形的负宽度?或者如何根据鼠标移动移动矩形?
什么出错了?
我的代码片段.
ChartMouseDown:function(e){
// e = this.normalizeMouseEvent(e);
var mousedownCords=this.calMousePosition(e);
this.mouseDownX=mousedownCords.X;
this.mouseDownY=mousedownCords.Y;
this.chartMouseDownPoint= this.GetValuebyPoint(Math.abs(this.mouseDownX-this.model.m_AreaBounds.X),Math.abs(this.mouseDownY-(this.model.m_AreaBounds.Y + this.model.m_AreaBounds.Height)));
this.zoomingX=true;
},
ChartMouseMove: function (evt) {
if( this.zoomingX)
{
var mouseMoveX,mouseMoveY;
var mouseMoveCords=this.calMousePosition(evt);
mouseMoveX=mouseMoveCords.X;
mouseMoveY=mouseMoveCords.Y;
$(this.ZoomAreaRect).remove();
var width = Math.abs(mouseMoveX - this.mouseDownX);
var height = mouseMoveY - this.mouseDownY;
var x;
if(mouseMoveX > this.mouseDownX)
x= this.mouseDownX;
else
x= mouseMoveX;
this.ZoomAreaRect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
$(this.ZoomAreaRect).attr({
'id': 'ZoomArea', 'x': x, 'y': this.model.m_AreaBounds.Y, 'width': width, 'height': this.model.m_AreaBounds.Height,
'fill': 'gray', 'stroke-width': 1, 'stroke':'gray'
});
$(this.ZoomAreaRect).appendTo(this.SvgObject); …
Run Code Online (Sandbox Code Playgroud) svg ×5
jquery-svg ×4
javascript ×3
jquery ×3
css ×2
html ×2
c# ×1
c#-4.0 ×1
inheritance ×1
mouseevent ×1
npoi ×1
rect ×1
scale ×1