Skip to content

Commit f6c797c

Browse files
committed
apply mouse event to separate module
1 parent dc1408c commit f6c797c

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

js/module/array2d.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
3030
this.fontSize = 16;
3131

3232
if (Tracer.prototype._setData.call(this, arguments)) {
33-
$('.mtbl-row').each(function (i) {
33+
this.$table.find('.mtbl-row').each(function (i) {
3434
$(this).children().each(function (j) {
3535
$(this).text(D[i][j]);
3636
});
@@ -233,7 +233,7 @@ Array2DTracer.prototype = $.extend(true, Object.create(Tracer.prototype), {
233233
this.paddingV *= ratio;
234234
this.paddingH *= ratio;
235235
this.fontSize *= ratio;
236-
$('.mtbl-cell').css(this.getCellCss());
236+
this.$table.find('.mtbl-cell').css(this.getCellCss());
237237
this.refresh();
238238
},
239239
paintColor: function (sx, sy, ex, ey, colorClass, addClass) {

js/module/tracer_manager.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,15 @@ TracerManager.prototype = {
162162
capsule.tracer.module.prototype[functionName].apply(capsule.tracer, args);
163163
}
164164
});
165+
},
166+
findOwner: function (container) {
167+
var selectedCapsule = null;
168+
$.each(this.capsules, function (i, capsule) {
169+
if (capsule.$container[0] == container) {
170+
selectedCapsule = capsule;
171+
return false;
172+
}
173+
});
174+
return selectedCapsule.tracer;
165175
}
166176
};

js/script.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,15 @@ for (var i = 0; i < dividers.length; i++) {
340340
})(divider);
341341
}
342342

343-
$module_container.mousedown(function (e) {
344-
tm.command('mousedown', e);
343+
$module_container.on('mousedown', '.module_wrapper', function (e) {
344+
tm.findOwner(this).mousedown(e);
345345
});
346-
$module_container.mousemove(function (e) {
347-
tm.command('mousemove', e);
346+
$module_container.on('mousemove', '.module_wrapper', function (e) {
347+
tm.findOwner(this).mousemove(e);
348348
});
349349
$(document).mouseup(function (e) {
350350
tm.command('mouseup', e);
351351
});
352-
$module_container.bind('DOMMouseScroll mousewheel', function (e) {
353-
tm.command('mousewheel', e);
352+
$module_container.on('DOMMouseScroll mousewheel', '.module_wrapper', function (e) {
353+
tm.findOwner(this).mousewheel(e);
354354
});

0 commit comments

Comments
 (0)