From a3edb9bf2f3ee8c15bc1a55b368c1028e2a57715 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Tue, 7 Apr 2015 12:46:40 +0200 Subject: further improve drawOn: use full size in appMode --- README.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'README.md') 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. -- cgit v1.3.1