mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 08:22:44 +08:00
added chrome specific logic to improve the drag and drop performance until the chrome bug is fixed
This commit is contained in:
parent
1c8669eb7a
commit
2108736df7
11
dist/kinetic-core.js
vendored
11
dist/kinetic-core.js
vendored
@ -46,6 +46,7 @@ Kinetic.GlobalObject = {
|
|||||||
animIdCounter: 0,
|
animIdCounter: 0,
|
||||||
dragTimeInterval: 0,
|
dragTimeInterval: 0,
|
||||||
maxDragTimeInterval: 20,
|
maxDragTimeInterval: 20,
|
||||||
|
isChrome: navigator.userAgent.toLowerCase().indexOf('chrome') > -1,
|
||||||
frame: {
|
frame: {
|
||||||
time: 0,
|
time: 0,
|
||||||
timeDiff: 0,
|
timeDiff: 0,
|
||||||
@ -1778,6 +1779,12 @@ Kinetic.Stage.prototype = {
|
|||||||
y: pos.y - go.drag.offset.y
|
y: pos.y - go.drag.offset.y
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* chrome currently has a bug that slows down drag and drop.
|
||||||
|
* For google chrome instances, dynamically set the dragTimeInterval
|
||||||
|
* to improve drag and drop performance while not effecting other browsers
|
||||||
|
*/
|
||||||
|
if(go.isChrome) {
|
||||||
/*
|
/*
|
||||||
* handle dynamice drag time interval. As the distance between
|
* handle dynamice drag time interval. As the distance between
|
||||||
* the mouse and cursor increases, we need to increase the drag
|
* the mouse and cursor increases, we need to increase the drag
|
||||||
@ -1786,13 +1793,11 @@ Kinetic.Stage.prototype = {
|
|||||||
* is zero, the time interval is zero. When the difference approahces
|
* is zero, the time interval is zero. When the difference approahces
|
||||||
* infinity, the time interval approaches the max drag time interval
|
* infinity, the time interval approaches the max drag time interval
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
var dragDiffX = Math.abs(newNodePos.x - node.attrs.x);
|
var dragDiffX = Math.abs(newNodePos.x - node.attrs.x);
|
||||||
var dragDiffY = Math.abs(newNodePos.y - node.attrs.y);
|
var dragDiffY = Math.abs(newNodePos.y - node.attrs.y);
|
||||||
var dragDiff = Math.sqrt(Math.pow(dragDiffX, 2) + Math.pow(dragDiffY, 2));
|
var dragDiff = Math.sqrt(Math.pow(dragDiffX, 2) + Math.pow(dragDiffY, 2));
|
||||||
go.dragTimeInterval = go.maxDragTimeInterval * (dragDiff - 1) / (dragDiff + 1);
|
go.dragTimeInterval = go.maxDragTimeInterval * (dragDiff - 1) / (dragDiff + 1);
|
||||||
console.log(dragDiff + ',' + go.dragTimeInterval);
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// bounds overrides
|
// bounds overrides
|
||||||
if(db.left !== undefined && newNodePos.x < db.left) {
|
if(db.left !== undefined && newNodePos.x < db.left) {
|
||||||
|
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
@ -18,6 +18,7 @@ Kinetic.GlobalObject = {
|
|||||||
animIdCounter: 0,
|
animIdCounter: 0,
|
||||||
dragTimeInterval: 0,
|
dragTimeInterval: 0,
|
||||||
maxDragTimeInterval: 20,
|
maxDragTimeInterval: 20,
|
||||||
|
isChrome: navigator.userAgent.toLowerCase().indexOf('chrome') > -1,
|
||||||
frame: {
|
frame: {
|
||||||
time: 0,
|
time: 0,
|
||||||
timeDiff: 0,
|
timeDiff: 0,
|
||||||
|
10
src/Stage.js
10
src/Stage.js
@ -724,6 +724,12 @@ Kinetic.Stage.prototype = {
|
|||||||
y: pos.y - go.drag.offset.y
|
y: pos.y - go.drag.offset.y
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* chrome currently has a bug that slows down drag and drop.
|
||||||
|
* For google chrome instances, dynamically set the dragTimeInterval
|
||||||
|
* to improve drag and drop performance while not effecting other browsers
|
||||||
|
*/
|
||||||
|
if(go.isChrome) {
|
||||||
/*
|
/*
|
||||||
* handle dynamice drag time interval. As the distance between
|
* handle dynamice drag time interval. As the distance between
|
||||||
* the mouse and cursor increases, we need to increase the drag
|
* the mouse and cursor increases, we need to increase the drag
|
||||||
@ -732,13 +738,11 @@ Kinetic.Stage.prototype = {
|
|||||||
* is zero, the time interval is zero. When the difference approahces
|
* is zero, the time interval is zero. When the difference approahces
|
||||||
* infinity, the time interval approaches the max drag time interval
|
* infinity, the time interval approaches the max drag time interval
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
var dragDiffX = Math.abs(newNodePos.x - node.attrs.x);
|
var dragDiffX = Math.abs(newNodePos.x - node.attrs.x);
|
||||||
var dragDiffY = Math.abs(newNodePos.y - node.attrs.y);
|
var dragDiffY = Math.abs(newNodePos.y - node.attrs.y);
|
||||||
var dragDiff = Math.sqrt(Math.pow(dragDiffX, 2) + Math.pow(dragDiffY, 2));
|
var dragDiff = Math.sqrt(Math.pow(dragDiffX, 2) + Math.pow(dragDiffY, 2));
|
||||||
go.dragTimeInterval = go.maxDragTimeInterval * (dragDiff - 1) / (dragDiff + 1);
|
go.dragTimeInterval = go.maxDragTimeInterval * (dragDiff - 1) / (dragDiff + 1);
|
||||||
console.log(dragDiff + ',' + go.dragTimeInterval);
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// bounds overrides
|
// bounds overrides
|
||||||
if(db.left !== undefined && newNodePos.x < db.left) {
|
if(db.left !== undefined && newNodePos.x < db.left) {
|
||||||
|
Loading…
Reference in New Issue
Block a user