为什么这段代码不适用于IE 8?

时间:2011-09-08 12:49:48

标签: javascript javascript-events raphael

任何人都可以帮我弄清楚为什么这段代码在IE 8上不起作用? (适用于Chrome,Firefox,Opera)。

代码使用Raphäel.js库,代码允许用户鼠标拖动Raphäel.js元素(例如circle,rectanglar)

请看这里:

var paper = Raphael(0, 0, '100%', '100%');

var circle = paper.circle(75, 75, 50);
var rect = paper.rect(150, 150, 50, 50);

var set = paper.set();

set.push(circle, rect);
set.attr({
    fill: 'red',
    stroke: 0
});

var ox = 0;
var oy = 0;
var dragging = false;

set.mousedown(function(event) {
    ox = event.screenX;
    oy = event.screenY;
    set.attr({
        opacity: .5
    });
    dragging = true;
});

set.mousemove(function(event) {
    if (dragging) {
        set.translate(event.screenX - ox, event.screenY - oy);
        ox = event.screenX;
        oy = event.screenY;
    }
});

set.mouseup(function(event) {
    dragging = false;
    set.attr({
        opacity: 1
    });
});

1 个答案:

答案 0 :(得分:1)

ie8和ie9处理鼠标移动事件的方式似乎有错误http://css.dzone.com/news/internet-explorer-8-fix-event-