Kinetic.HotspotDropItem = function(config){ Kinetic.Group.call(this, config); this.data = config.data; this.createItem(); this.currentItem = null; } Kinetic.HotspotDropItem.prototype = { createItem: function(){ this.bg = new Kinetic.Rect({ 'width': this.data.sizeX, 'height': this.data.sizeY, 'fill': '#FFFFFF', 'stroke': '#000000', 'strokeWidth': 0.2, 'opacity': 0.6 }); this.add(this.bg); }, getWidth: function(){ return this.bg.getWidth(); }, getHeight: function(){ return this.bg.getHeight(); }, addItem: function(item){ this.currentItem = item; var itemWidth = item.getWidth(); var itemHeight = item.getHeight(); var xPos = this.getX() - item.getParent().getX() + ((this.bg.getWidth() - itemWidth) / 2); var yPos = this.getY() - item.getParent().getY() + ((this.bg.getHeight() - itemHeight) / 2); var tween = new Kinetic.Tween({ 'node': item, 'x': xPos, 'y': yPos, 'duration': 0.2, 'easing': Kinetic.Easings.EaseInOut }); tween.play(); }, removeItem: function(){ if (this.currentItem != null){ this.currentItem.dropItem = null; this.currentItem = null; } } } Kinetic.Util.extend(Kinetic.HotspotDropItem, Kinetic.Group);