Lots of changes to the cmap stuff
This commit is contained in:
+38
-4
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* racket-wiki cmap component 0.2.94
|
||||
* racket-wiki cmap component 0.2.95
|
||||
* Based on cmap v0.1.3.
|
||||
* (c) 2015 iOnStage
|
||||
* Released under the MIT License.
|
||||
@@ -370,6 +370,12 @@
|
||||
|
||||
var Component = function() {};
|
||||
|
||||
Component.prototype.disposed = false;
|
||||
|
||||
Component.prototype.dispose = function() {
|
||||
this.disposed = true;
|
||||
};
|
||||
|
||||
Component.prototype.prop = function(initialValue, defaultValue, converter) {
|
||||
if (typeof converter !== 'function')
|
||||
converter = helper.identity;
|
||||
@@ -407,8 +413,11 @@
|
||||
var updateRelations = function(index) {
|
||||
for (var i = index, len = dirtyComponents.length; i < len; i++) {
|
||||
var component = dirtyComponents[i];
|
||||
if (component.disposed)
|
||||
continue;
|
||||
component.relations().forEach(function(relation) {
|
||||
relation.update(component);
|
||||
if (!relation.disposed)
|
||||
relation.update(component);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -421,7 +430,8 @@
|
||||
updateRelations(0);
|
||||
|
||||
dirtyComponents.forEach(function(component) {
|
||||
component.redraw();
|
||||
if (!component.disposed)
|
||||
component.redraw();
|
||||
});
|
||||
|
||||
dirtyComponents = [];
|
||||
@@ -429,7 +439,7 @@
|
||||
};
|
||||
|
||||
return function() {
|
||||
if (dom.disabled())
|
||||
if (dom.disabled() || this.disposed)
|
||||
return;
|
||||
|
||||
if (dirtyComponents.indexOf(this) === -1)
|
||||
@@ -1808,6 +1818,9 @@
|
||||
};
|
||||
|
||||
Cmap.prototype.redraw = function() {
|
||||
if (this.disposed)
|
||||
return;
|
||||
|
||||
var rootElement = this.rootElement();
|
||||
|
||||
if (!rootElement) {
|
||||
@@ -1820,6 +1833,7 @@
|
||||
this.rootElement(rootElement);
|
||||
}
|
||||
|
||||
var previousElement = this.element();
|
||||
var element = dom.el('<div>');
|
||||
element.className = 'rw-cmap-surface';
|
||||
dom.draggable(element, function(x, y, event) {
|
||||
@@ -1844,6 +1858,8 @@
|
||||
this.unfixScrollSize();
|
||||
|
||||
dom.css(element, this.style());
|
||||
if (previousElement && previousElement.parentNode)
|
||||
previousElement.parentNode.removeChild(previousElement);
|
||||
dom.append(rootElement, element);
|
||||
};
|
||||
|
||||
@@ -2190,6 +2206,24 @@
|
||||
this.activationHandler = handler;
|
||||
};
|
||||
|
||||
CmapModule.prototype.destroy = function() {
|
||||
var component = this.component;
|
||||
var element = component.element();
|
||||
|
||||
this.selectionHandler = null;
|
||||
this.activationHandler = null;
|
||||
component.selectionHandler = null;
|
||||
component.activationHandler = null;
|
||||
component.componentList().toArray().forEach(function(child) {
|
||||
child.dispose();
|
||||
child.parentElement(null);
|
||||
});
|
||||
component.dispose();
|
||||
|
||||
if (element && element.parentNode)
|
||||
element.parentNode.removeChild(element);
|
||||
};
|
||||
|
||||
CmapModule.prototype.zoom = function(value) {
|
||||
if (typeof value === 'undefined')
|
||||
return this.component.zoomFactor;
|
||||
|
||||
Reference in New Issue
Block a user