summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-04-07 12:46:40 +0200
committerGubolin <gubolin@fantasymail.de>2015-04-07 12:46:40 +0200
commita3edb9bf2f3ee8c15bc1a55b368c1028e2a57715 (patch)
tree471a6b95afc840fe4d8354bcca5438713a4d5d84
parenta4890ed4a01b556ed89fbca30068016c00bbc658 (diff)
downloadsnap-wiki-master.tar.gz
snap-wiki-master.zip
further improve drawOn: use full size in appModeHEADmaster
-rw-r--r--README.md22
1 files changed, 14 insertions, 8 deletions
diff --git a/README.md b/README.md
index 03a123a..1db771b 100644
--- a/README.md
+++ b/README.md
@@ -55,14 +55,20 @@ Outside the deep insides of Snap*!* you need to get the stage object, for exampl
Sometimes you need to have HTML as your 'stage' and a canvas is not enough. Luckily, modifying `StageMorph.prototype.drawOn` is very straightforward.
Get your element, preferrably a `div`. Resizing and positioning can be adopted from the original `drawOn` (`div` is your element):
```javascript
-var div = document.getElementById('div');
-var rectangle, area;
-rectangle = aRect || this.bounds;
-area = rectangle.intersect(this.bounds).round();
-div.style.width = this.dimensions.x * this.scale + 'px';
-div.style.height = this.dimensions.y * this.scale + 'px';
-div.style.left = area.left() + 'px';
-div.style.top = area.top() + 'px';
+var div = document.getElementById('foo'),
+ ide = this.parentThatIsA(IDE_Morph);
+
+if (!ide.isAppMode) {
+ div.style.left = this.left() + 'px';
+ div.style.top = this.top() + 'px';
+ div.style.width = this.dimensions.x * this.scale + 'px';
+ div.style.height = this.dimensions.y * this.scale + 'px';
+} else {
+ div.style.left = ide.left() + 'px';
+ div.style.top = this.top() + 'px';
+ div.style.width = ide.extent().x + 'px';
+ div.style.height = (ide.extent().y - this.top()) + 'px';
+}
optionalCustomRefreshFunction();
```
Todo: There is an issue when a sprite is moved/dragged. The overlaying div then moves to the wrong position.