optimized getIntersection function. fix #17. close #13

This commit is contained in:
lavrton 2015-01-29 00:21:02 +07:00
parent 11de1dc6d2
commit 09eb72b0a0
7 changed files with 96 additions and 18 deletions

View File

@ -1,3 +1,11 @@
## 0.7.1
* Bug Fixes
* fixed when browser is crashing on pointer events fixed (and optimized `getIntersection` function)
* Enhancements
## Rebranding release 2015-01-28 (Differents from last official KineticJS release)
* Bug Fixes

View File

@ -1,6 +1,6 @@
{
"name": "konva",
"version": "0.7.0",
"version": "0.7.1",
"authors": [
"Eric Rowell", "Anton Lavrenov"
],

View File

@ -1,9 +1,9 @@
/*
* Konva JavaScript Framework v0.7.0
* Konva JavaScript Framework v0.7.1
* http://konvajs.github.io/
* Licensed under the MIT or GPL Version 2 licenses.
* Date: 2015-01-28
* Date: 2015-01-29
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
@ -36,7 +36,7 @@ var Konva = {};
Konva = {
// public
version: '0.7.0',
version: '0.7.1',
// private
stages: [],
@ -10244,8 +10244,12 @@ var Konva = {};
}
// we should continue search if we found antialiased pixel
// that means our node somewhere very close
else if (obj.antialiased) {
continueSearch = true;
else {
continueSearch = !!obj.antialiased;
// stop search if found empty pixel
if (!obj.antialiased) {
break;
}
}
}
// if no shape, and no antialiased pixel, we should end searching
@ -10284,9 +10288,16 @@ var Konva = {};
if(p3 === 255) {
colorKey = Konva.Util._rgbToHex(p[0], p[1], p[2]);
shape = Konva.shapes[HASH + colorKey];
return {
shape: shape
};
if (shape) {
return {
shape: shape
};
} else {
return {
antialiased: true
};
}
}
// antialiased pixel
else if(p3 > 0) {

6
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "konva",
"version": "0.7.0",
"version": "0.7.1",
"author": "Anton Lavrenov",
"devDependencies": {
"chai": "1.9.2",

View File

@ -75,8 +75,12 @@
}
// we should continue search if we found antialiased pixel
// that means our node somewhere very close
else if (obj.antialiased) {
continueSearch = true;
else {
continueSearch = !!obj.antialiased;
// stop search if found empty pixel
if (!obj.antialiased) {
break;
}
}
}
// if no shape, and no antialiased pixel, we should end searching
@ -115,9 +119,16 @@
if(p3 === 255) {
colorKey = Konva.Util._rgbToHex(p[0], p[1], p[2]);
shape = Konva.shapes[HASH + colorKey];
return {
shape: shape
};
if (shape) {
return {
shape: shape
};
} else {
return {
antialiased: true
};
}
}
// antialiased pixel
else if(p3 > 0) {

View File

@ -751,6 +751,54 @@ suite('MouseEvents', function() {
});
assert.equal(groupMousedowns, 1, 'groupMousedowns should be 1');
});
test('test mousemove events with antialiasing', function() {
var stage = addStage();
var layer = new Konva.Layer();
var group = new Konva.Group({
name: 'group'
});
var rect1 = new Konva.Rect({
x:0,
y:0,
width: 100,
height: 100,
fill: 'red'
});
var rect2 = new Konva.Rect({
x:50,
y:0,
width: 70,
height: 70,
rotation: 45,
fill: 'green'
});
group.add(rect1).add(rect2);
layer.add(group);
group.cache({
width : rect1.width(),
height : rect1.height()
});
group.scaleX(5);
group.scaleY(5);
var mouseenterCount = 0;
group.on('mouseenter', function() {
mouseenterCount++;
});
stage.add(layer);
var top = stage.content.getBoundingClientRect().top;
// move mouse slowly
for (var i = 99; i < 129; i++) {
stage._mousemove({
clientX: i,
clientY: 135 + top
});
}
assert.equal(mouseenterCount, 1, 'mouseenterCount should be 1');
});
// ======================================================
test('group mouseenter events', function(done) {