我需要通过单击按钮来移动圆圈.并且圆圈不应远离边界.
这只是向左和向下按钮,但它不是一个使用边距的好方法.有一种方法可以改变位置相对left\right\top\down而不是边距?
(function(){
var button = document.getElementsByClassName("button");
var circle = document.getElementById("circle");
var down=0, up=0, left=0, right=0;
for (var i = 0; i < button.length; i++) {
button[i].addEventListener('click',function(e){
var position = e.currentTarget.value;
if(position==="down"){
down+=5;
circle.style.marginTop = down +"px";
}
if(position==="up"){
up+=5;
circle.style.marginBottom = up+'px';
}
if(position==="left"){
left+=5;
circle.style.marginRight = left+'px';
}
if(position==="right"){
right+=5;
circle.style.marginLeft = right+'px';
}
}
)
}
}());Run Code Online (Sandbox Code Playgroud)
html, body {
font-size: 62.5%;
}
.border{
position: relative;
overflow: hidden;
float: left;
width: 70% ;
height: 50rem;
border: 1rem …Run Code Online (Sandbox Code Playgroud)我在这里搜索 fabricJS-circle,但没有发现有一种方法可以添加数字 1 或 2 或 3 之类的文本......在画布上的圆圈内?
这是我在画布上的圆对象:
function makeStaion(left, top, stationID) {
var c = new fabric.Circle({
left: left,
top: top,
radius: 2,
fill: '#5afffa',
stroke: '#666',
selectable: true,
centeredScaling:true,
padding:2,
hasRotatingPoint: false,
borderColor: 'black',
cornerColor: 'black'
});
c.hasControls = true;
c.station = true;
c.stationID = stationID;
c.stationName = stations[stationID].name;
c.description = stations[stationID].desc;
c.image = stations[stationID].image;
return c;
}
Run Code Online (Sandbox Code Playgroud) 检查数学表达式不起作用的函数.
我在chrome上调试了这个,我看到当它到达第一个pop(stack.pop()!== chars[i])时,它返回false,但它不应该.
var smarter_validate = function(str) {
var chars = str.split('');
var stack = [];
var lookup = {
'(': ')',
'[': ']',
'{': '}',
'<': '>'
};
var left = Object.keys(lookup);
var right = Object.keys(lookup).map(function(key) {
return lookup[key]
});
for (var i = 0; i < chars.length; i++) {
if (left.indexOf(chars[i]) !== (-1)) {
stack.push(chars[i]);
} else if (right.indexOf(chars[i]) !== (-1)) {
if ((stack.length === 0) || (stack.pop() !== chars[i])) {
return false;
}
}
} …Run Code Online (Sandbox Code Playgroud) 在我的项目中:http://moransh4.github.io/Luca/
我需要在最后一节将swiper-pagination-bullet更改为:
绿色的"活跃"变化.
我阅读(来自:http://idangero.us/swiper/api/)我可以自定义:
paginationBulletRender: function (index, className) {
return '<span class="' + className + '">' + (index + 1) + '</span>';
}
Run Code Online (Sandbox Code Playgroud)
对不起,我迷失了,
怎么做?
frontend ×2
html5 ×2
javascript ×2
jquery ×2
web-frontend ×2
canvas ×1
css3 ×1
fabricjs ×1
stack ×1
swiper ×1