>
>
>
> On Wed, Feb 13, 2019 at 3:56 PM Simon Huber <[email protected] 
> <javascript:>> wrote:
>
>> Hi stefano,
>>
>> from within the render method it should be possible to access the parent 
>> if I recall correctly,
>>
>> could you post a bit of code to work with?
>>
>>
> Well, it is all very rudimentary still, but the idea is the following:
> In my plugin I import the library and instantiate it, then create the div 
> to pass to it. Then I call the constructor of my library's main object with 
> the div as its argument:
> ''''
> (function(){
> /*jslint node: true, browser: true */
> /*global $tw: false */
> "use strict";
> var    Widget = require("$:/core/modules/widgets/widget.js").widget;
>
> //The library I use, besogo:
> var     besogoPlayer = 
> require("$:/plugins/cleinias/SgfEditor/besogo").besogo
>
> var GoGameWidget = function(parseTreeNode,options) {
>     this.initialise(parseTreeNode,options);
> };
>
> GoGameWidget.prototype = new Widget();
>     
> /*
> Render this widget into the DOM
> */
> GoGameWidget.prototype.render = function(parent,nextSibling) {
>     this.parentDomNode = parent;
>     this.computeAttributes();
>     var div = this.document.createElement("div");
>     this.goGamePlayer = besogoPlayer;
>

Stefano, here you should be able to get dimensions of the parent domnode by

var rect = this.parentDomNode.getBoundingClientRect();

for example ...

var width = rect.width;

hope this helps

//
> // This is where I would need to know the width of the future widget, so I 
> can pass it to the create function
> //   this.goGamePlayer.create(div);
>     var twSgfFile = this.getAttribute("sgfFile");
>     parent.insertBefore(div,nextSibling);
>     this.domNodes.push(div);
> };
> ''''
> he goGamePlayer.create(div) function is the call to the besogo library,  
> where all the magic happens.  Its resizer function computes a bunch of 
> parameters. Withouth going into unnecessary details (I append the function 
> below, relevant lines are bolded and italicized), the width of the 
> parentElement is crucial to determining the overall width of the final 
> widget. For now, I got around the problem in testing by hardcoding a number 
> into the code, but it would really be nice to have a flexible and 
> responsive solution
>
> Cheers,
>
> S.
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/3dc56a47-152b-46a2-b923-35900f77d8a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to