diff options
| author | Gubolin <gubolin@fantasymail.de> | 2015-04-07 12:46:40 +0200 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2015-04-07 12:46:40 +0200 |
| commit | a3edb9bf2f3ee8c15bc1a55b368c1028e2a57715 (patch) | |
| tree | 471a6b95afc840fe4d8354bcca5438713a4d5d84 | |
| parent | a4890ed4a01b556ed89fbca30068016c00bbc658 (diff) | |
| download | snap-wiki-master.tar.gz snap-wiki-master.zip | |
| -rw-r--r-- | README.md | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -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. |
