mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-13 22:07:15 +00:00
Fix #5308 - WidgetSubclassingMechanism not working with widgets that add EventListeners (or logic ?) in constructor (#5382)
* add EventListeners in the render() method instead of the constructor * scrollable widget: add EventListeners in render() method instead of constructor + ... move logic from constructor to render() * linkcatcher: add EventListeners in render() instead of constructor * fieldmangler: add EventListeners in render() instead of constructor * edit-bitmap: initialise editorOperations in render() instead of constructor * list-widget: initialise storyviews in render() instead of constructor * vars widget: execute Widget.call(this) in render() instead of constructor ... not shure what this should do * Update fieldmangler.js * Update edit-bitmap.js * Update linkcatcher.js * Update navigator.js * Update scrollable.js * Update list.js * Update vars.js
This commit is contained in:
@@ -16,26 +16,6 @@ var Widget = require("$:/core/modules/widgets/widget.js").widget;
|
||||
|
||||
var ScrollableWidget = function(parseTreeNode,options) {
|
||||
this.initialise(parseTreeNode,options);
|
||||
this.scaleFactor = 1;
|
||||
this.addEventListeners([
|
||||
{type: "tm-scroll", handler: "handleScrollEvent"}
|
||||
]);
|
||||
if($tw.browser) {
|
||||
this.requestAnimationFrame = window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
function(callback) {
|
||||
return window.setTimeout(callback, 1000/60);
|
||||
};
|
||||
this.cancelAnimationFrame = window.cancelAnimationFrame ||
|
||||
window.webkitCancelAnimationFrame ||
|
||||
window.webkitCancelRequestAnimationFrame ||
|
||||
window.mozCancelAnimationFrame ||
|
||||
window.mozCancelRequestAnimationFrame ||
|
||||
function(id) {
|
||||
window.clearTimeout(id);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -147,6 +127,26 @@ Render this widget into the DOM
|
||||
*/
|
||||
ScrollableWidget.prototype.render = function(parent,nextSibling) {
|
||||
var self = this;
|
||||
this.scaleFactor = 1;
|
||||
this.addEventListeners([
|
||||
{type: "tm-scroll", handler: "handleScrollEvent"}
|
||||
]);
|
||||
if($tw.browser) {
|
||||
this.requestAnimationFrame = window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
function(callback) {
|
||||
return window.setTimeout(callback, 1000/60);
|
||||
};
|
||||
this.cancelAnimationFrame = window.cancelAnimationFrame ||
|
||||
window.webkitCancelAnimationFrame ||
|
||||
window.webkitCancelRequestAnimationFrame ||
|
||||
window.mozCancelAnimationFrame ||
|
||||
window.mozCancelRequestAnimationFrame ||
|
||||
function(id) {
|
||||
window.clearTimeout(id);
|
||||
};
|
||||
}
|
||||
// Remember parent
|
||||
this.parentDomNode = parent;
|
||||
// Compute attributes and execute state
|
||||
|
||||
Reference in New Issue
Block a user