mirror of
https://github.com/konvajs/konva.git
synced 2025-09-22 20:14:01 +08:00
refactor + docs
This commit is contained in:
45
kinetic.js
45
kinetic.js
@@ -4,7 +4,7 @@
|
|||||||
* http://www.kineticjs.com/
|
* http://www.kineticjs.com/
|
||||||
* Copyright 2013, Eric Rowell
|
* Copyright 2013, Eric Rowell
|
||||||
* Licensed under the MIT or GPL Version 2 licenses.
|
* Licensed under the MIT or GPL Version 2 licenses.
|
||||||
* Date: 2014-04-29
|
* Date: 2014-05-01
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 - 2013 by Eric Rowell
|
* Copyright (C) 2011 - 2013 by Eric Rowell
|
||||||
*
|
*
|
||||||
@@ -6129,7 +6129,8 @@ var Kinetic = {};
|
|||||||
* timeDiff, lastTime, time, and frameRate properties. The timeDiff property is the number of milliseconds that have passed
|
* timeDiff, lastTime, time, and frameRate properties. The timeDiff property is the number of milliseconds that have passed
|
||||||
* since the last animation frame. The lastTime property is time in milliseconds that elapsed from the moment the animation started
|
* since the last animation frame. The lastTime property is time in milliseconds that elapsed from the moment the animation started
|
||||||
* to the last animation frame. The time property is the time in milliseconds that ellapsed from the moment the animation started
|
* to the last animation frame. The time property is the time in milliseconds that ellapsed from the moment the animation started
|
||||||
* to the current animation frame. The frameRate property is the current frame rate in frames / second
|
* to the current animation frame. The frameRate property is the current frame rate in frames / second. Return false from function,
|
||||||
|
* if you don't need to redraw layer/layers on some frames.
|
||||||
* @param {Kinetic.Layer|Array} [layers] layer(s) to be redrawn on each animation frame. Can be a layer, an array of layers, or null.
|
* @param {Kinetic.Layer|Array} [layers] layer(s) to be redrawn on each animation frame. Can be a layer, an array of layers, or null.
|
||||||
* Not specifying a node will result in no redraw.
|
* Not specifying a node will result in no redraw.
|
||||||
* @example
|
* @example
|
||||||
@@ -6300,6 +6301,7 @@ var Kinetic = {};
|
|||||||
* WARNING: don't cache animations.length because it could change while
|
* WARNING: don't cache animations.length because it could change while
|
||||||
* the for loop is running, causing a JS error
|
* the for loop is running, causing a JS error
|
||||||
*/
|
*/
|
||||||
|
var needRedraw = false;
|
||||||
for(n = 0; n < animations.length; n++) {
|
for(n = 0; n < animations.length; n++) {
|
||||||
anim = animations[n];
|
anim = animations[n];
|
||||||
layers = anim.layers;
|
layers = anim.layers;
|
||||||
@@ -6317,12 +6319,15 @@ var Kinetic = {};
|
|||||||
|
|
||||||
// if animation object has a function, execute it
|
// if animation object has a function, execute it
|
||||||
if(func) {
|
if(func) {
|
||||||
func.call(anim, anim.frame);
|
// allow anim bypassing drawing
|
||||||
|
needRedraw = (func.call(anim, anim.frame) !== false) || needRedraw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(key in layerHash) {
|
if (needRedraw) {
|
||||||
layerHash[key].draw();
|
for(key in layerHash) {
|
||||||
|
layerHash[key].draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Kinetic.Animation._animationLoop = function() {
|
Kinetic.Animation._animationLoop = function() {
|
||||||
@@ -6384,7 +6389,8 @@ var Kinetic = {};
|
|||||||
layer.batchDraw();
|
layer.batchDraw();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
})(this);;(function() {
|
})(this);
|
||||||
|
;(function() {
|
||||||
var blacklist = {
|
var blacklist = {
|
||||||
node: 1,
|
node: 1,
|
||||||
duration: 1,
|
duration: 1,
|
||||||
@@ -6986,8 +6992,13 @@ var Kinetic = {};
|
|||||||
;(function() {
|
;(function() {
|
||||||
Kinetic.DD = {
|
Kinetic.DD = {
|
||||||
// properties
|
// properties
|
||||||
anim: new Kinetic.Animation(),
|
anim: new Kinetic.Animation(function(frame) {
|
||||||
|
var b = this.dirty;
|
||||||
|
this.dirty = false;
|
||||||
|
return b;
|
||||||
|
}),
|
||||||
isDragging: false,
|
isDragging: false,
|
||||||
|
justDragged: false,
|
||||||
offset: {
|
offset: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0
|
y: 0
|
||||||
@@ -7045,6 +7056,7 @@ var Kinetic = {};
|
|||||||
// operation actually started.
|
// operation actually started.
|
||||||
if(dd.isDragging) {
|
if(dd.isDragging) {
|
||||||
dd.isDragging = false;
|
dd.isDragging = false;
|
||||||
|
dd.justDragged = true;
|
||||||
Kinetic.listenClickTap = false;
|
Kinetic.listenClickTap = false;
|
||||||
|
|
||||||
if (evt) {
|
if (evt) {
|
||||||
@@ -7119,6 +7131,14 @@ var Kinetic = {};
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setAbsolutePosition(newNodePos);
|
this.setAbsolutePosition(newNodePos);
|
||||||
|
|
||||||
|
if (!this._lastPos ||
|
||||||
|
this._lastPos.x !== newNodePos.x ||
|
||||||
|
this._lastPos.y !== newNodePos.y) {
|
||||||
|
dd.anim.dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._lastPos = newNodePos;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9571,17 +9591,20 @@ var Kinetic = {};
|
|||||||
_mouseup: function(evt) {
|
_mouseup: function(evt) {
|
||||||
if (!Kinetic.UA.mobile) {
|
if (!Kinetic.UA.mobile) {
|
||||||
this._setPointerPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var that = this,
|
var shape = this.getIntersection(this.getPointerPosition()),
|
||||||
shape = this.getIntersection(this.getPointerPosition()),
|
|
||||||
clickStartShape = this.clickStartShape,
|
clickStartShape = this.clickStartShape,
|
||||||
fireDblClick = false;
|
fireDblClick = false,
|
||||||
|
dd = Kinetic.DD;
|
||||||
|
|
||||||
if(Kinetic.inDblClickWindow) {
|
if(Kinetic.inDblClickWindow) {
|
||||||
fireDblClick = true;
|
fireDblClick = true;
|
||||||
Kinetic.inDblClickWindow = false;
|
Kinetic.inDblClickWindow = false;
|
||||||
}
|
}
|
||||||
else {
|
// don't set inDblClickWindow after dragging
|
||||||
|
else if (!dd || !dd.justDragged) {
|
||||||
Kinetic.inDblClickWindow = true;
|
Kinetic.inDblClickWindow = true;
|
||||||
|
} else if (dd) {
|
||||||
|
dd.justDragged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
8
kinetic.min.js
vendored
8
kinetic.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -39,7 +39,8 @@
|
|||||||
* timeDiff, lastTime, time, and frameRate properties. The timeDiff property is the number of milliseconds that have passed
|
* timeDiff, lastTime, time, and frameRate properties. The timeDiff property is the number of milliseconds that have passed
|
||||||
* since the last animation frame. The lastTime property is time in milliseconds that elapsed from the moment the animation started
|
* since the last animation frame. The lastTime property is time in milliseconds that elapsed from the moment the animation started
|
||||||
* to the last animation frame. The time property is the time in milliseconds that ellapsed from the moment the animation started
|
* to the last animation frame. The time property is the time in milliseconds that ellapsed from the moment the animation started
|
||||||
* to the current animation frame. The frameRate property is the current frame rate in frames / second
|
* to the current animation frame. The frameRate property is the current frame rate in frames / second. Return false from function,
|
||||||
|
* if you don't need to redraw layer/layers on some frames.
|
||||||
* @param {Kinetic.Layer|Array} [layers] layer(s) to be redrawn on each animation frame. Can be a layer, an array of layers, or null.
|
* @param {Kinetic.Layer|Array} [layers] layer(s) to be redrawn on each animation frame. Can be a layer, an array of layers, or null.
|
||||||
* Not specifying a node will result in no redraw.
|
* Not specifying a node will result in no redraw.
|
||||||
* @example
|
* @example
|
||||||
@@ -210,6 +211,7 @@
|
|||||||
* WARNING: don't cache animations.length because it could change while
|
* WARNING: don't cache animations.length because it could change while
|
||||||
* the for loop is running, causing a JS error
|
* the for loop is running, causing a JS error
|
||||||
*/
|
*/
|
||||||
|
var needRedraw = false;
|
||||||
for(n = 0; n < animations.length; n++) {
|
for(n = 0; n < animations.length; n++) {
|
||||||
anim = animations[n];
|
anim = animations[n];
|
||||||
layers = anim.layers;
|
layers = anim.layers;
|
||||||
@@ -228,14 +230,14 @@
|
|||||||
// if animation object has a function, execute it
|
// if animation object has a function, execute it
|
||||||
if(func) {
|
if(func) {
|
||||||
// allow anim bypassing drawing
|
// allow anim bypassing drawing
|
||||||
if (false === func.call(anim, anim.frame)) {
|
needRedraw = (func.call(anim, anim.frame) !== false) || needRedraw;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(key in layerHash) {
|
if (needRedraw) {
|
||||||
layerHash[key].draw();
|
for(key in layerHash) {
|
||||||
|
layerHash[key].draw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Kinetic.Animation._animationLoop = function() {
|
Kinetic.Animation._animationLoop = function() {
|
||||||
|
Reference in New Issue
Block a user