mirror of
https://github.com/konvajs/konva.git
synced 2025-04-29 07:08:17 +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
31
dist/kinetic-core.js
vendored
31
dist/kinetic-core.js
vendored
@ -46,6 +46,7 @@ Kinetic.GlobalObject = {
|
||||
animIdCounter: 0,
|
||||
dragTimeInterval: 0,
|
||||
maxDragTimeInterval: 20,
|
||||
isChrome: navigator.userAgent.toLowerCase().indexOf('chrome') > -1,
|
||||
frame: {
|
||||
time: 0,
|
||||
timeDiff: 0,
|
||||
@ -1779,20 +1780,24 @@ Kinetic.Stage.prototype = {
|
||||
};
|
||||
|
||||
/*
|
||||
* handle dynamice drag time interval. As the distance between
|
||||
* the mouse and cursor increases, we need to increase the drag
|
||||
* time interval to reduce the number of layer draws so that
|
||||
* the node position can catch back up to the cursor. When the difference
|
||||
* is zero, the time interval is zero. When the difference approahces
|
||||
* infinity, the time interval approaches the max drag time interval
|
||||
* 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
|
||||
*/
|
||||
/*
|
||||
var dragDiffX = Math.abs(newNodePos.x - node.attrs.x);
|
||||
var dragDiffY = Math.abs(newNodePos.y - node.attrs.y);
|
||||
var dragDiff = Math.sqrt(Math.pow(dragDiffX, 2) + Math.pow(dragDiffY, 2));
|
||||
go.dragTimeInterval = go.maxDragTimeInterval * (dragDiff - 1) / (dragDiff + 1);
|
||||
console.log(dragDiff + ',' + go.dragTimeInterval);
|
||||
*/
|
||||
if(go.isChrome) {
|
||||
/*
|
||||
* handle dynamice drag time interval. As the distance between
|
||||
* the mouse and cursor increases, we need to increase the drag
|
||||
* time interval to reduce the number of layer draws so that
|
||||
* the node position can catch back up to the cursor. When the difference
|
||||
* is zero, the time interval is zero. When the difference approahces
|
||||
* infinity, the time interval approaches the max drag time interval
|
||||
*/
|
||||
var dragDiffX = Math.abs(newNodePos.x - node.attrs.x);
|
||||
var dragDiffY = Math.abs(newNodePos.y - node.attrs.y);
|
||||
var dragDiff = Math.sqrt(Math.pow(dragDiffX, 2) + Math.pow(dragDiffY, 2));
|
||||
go.dragTimeInterval = go.maxDragTimeInterval * (dragDiff - 1) / (dragDiff + 1);
|
||||
}
|
||||
|
||||
// bounds overrides
|
||||
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,
|
||||
dragTimeInterval: 0,
|
||||
maxDragTimeInterval: 20,
|
||||
isChrome: navigator.userAgent.toLowerCase().indexOf('chrome') > -1,
|
||||
frame: {
|
||||
time: 0,
|
||||
timeDiff: 0,
|
||||
|
30
src/Stage.js
30
src/Stage.js
@ -725,20 +725,24 @@ Kinetic.Stage.prototype = {
|
||||
};
|
||||
|
||||
/*
|
||||
* handle dynamice drag time interval. As the distance between
|
||||
* the mouse and cursor increases, we need to increase the drag
|
||||
* time interval to reduce the number of layer draws so that
|
||||
* the node position can catch back up to the cursor. When the difference
|
||||
* is zero, the time interval is zero. When the difference approahces
|
||||
* infinity, the time interval approaches the max drag time interval
|
||||
* 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
|
||||
*/
|
||||
/*
|
||||
var dragDiffX = Math.abs(newNodePos.x - node.attrs.x);
|
||||
var dragDiffY = Math.abs(newNodePos.y - node.attrs.y);
|
||||
var dragDiff = Math.sqrt(Math.pow(dragDiffX, 2) + Math.pow(dragDiffY, 2));
|
||||
go.dragTimeInterval = go.maxDragTimeInterval * (dragDiff - 1) / (dragDiff + 1);
|
||||
console.log(dragDiff + ',' + go.dragTimeInterval);
|
||||
*/
|
||||
if(go.isChrome) {
|
||||
/*
|
||||
* handle dynamice drag time interval. As the distance between
|
||||
* the mouse and cursor increases, we need to increase the drag
|
||||
* time interval to reduce the number of layer draws so that
|
||||
* the node position can catch back up to the cursor. When the difference
|
||||
* is zero, the time interval is zero. When the difference approahces
|
||||
* infinity, the time interval approaches the max drag time interval
|
||||
*/
|
||||
var dragDiffX = Math.abs(newNodePos.x - node.attrs.x);
|
||||
var dragDiffY = Math.abs(newNodePos.y - node.attrs.y);
|
||||
var dragDiff = Math.sqrt(Math.pow(dragDiffX, 2) + Math.pow(dragDiffY, 2));
|
||||
go.dragTimeInterval = go.maxDragTimeInterval * (dragDiff - 1) / (dragDiff + 1);
|
||||
}
|
||||
|
||||
// bounds overrides
|
||||
if(db.left !== undefined && newNodePos.x < db.left) {
|
||||
|
Loading…
Reference in New Issue
Block a user