0

the situation: The rendered document is bigger than the available cocktailview.viewport.

I understand, the HTML intrinsic scrolling is not yet available (issue #358).

Is there a way to scroll the complete content of the cocktailview (scrollRect et al.)? I used the debugger to dive into the depth of the Cocktail class structure (at runtime) but couldn’t find a display object that is bigger than the viewport. It seems the masking/clipping is done somewhere deep, deep down…

hamid toosi
  • 95
  • 1
  • 10
  • I couldn't find anything like the things you mentioned in haxe std. You should tell us what is the library you use and what's it version so anyone could have a chance to give an answer. I've checked [the issue](https://github.com/HaxeFoundation/haxe/issues/358) you mentioned but it have nothing in common with your question. – stroncium Jun 25 '14 at 12:58
  • @stroncium the library is probably cocktail by Silex Labs: http://www.silexlabs.org/haxe/cocktail/ ... I shared the question on the Silex Labs Google+ group to see if anyone knows the answer... – Jason O'Neil Jun 25 '14 at 22:19
  • I want to view a html document using cocktail library: http://www.silexlabs.org/haxe/cocktail – hamid toosi Jun 26 '14 at 05:46

2 Answers2

1

Cocktail renders most of its content on a single BitmapData, that's why you won't see many DisplayObject. When you scroll the bitmap is redrawn at the right offset.

You can scroll using the following DOM attributes:

  • scrollTop
  • scrollLeft
  • scrollHeight
  • scrollWidth

So to scroll the whole document, you can do:

document.body.scrollTop = 100 //scroll 100 pixels from the top
  • It does not work. The document.body is null on document load, so I use onMouseMove event: var cv = new CocktailView(); cv.viewport = { x:0, y:100, width:480, height:800 }; cv.loadURL("index.html"); cv.document.onmousemove = function(e) { cv.document.body.scrollTop += 1; } – hamid toosi Jun 26 '14 at 10:40
  • @hamid toosi I didn't try it myself, but that's totally wrong way to do that. This declaration can lead to anything from infinite loop or momentary scrolling all the way down to not doing anything at all. – stroncium Jun 26 '14 at 11:33
  • Ahamid toosi I mean, that's a wrong way to test, because it may not work even when everything else is working properly. – stroncium Jun 27 '14 at 09:03
  • I debug it but document.body.scrollTop is not available at runtime. other codes I put to onMouseMove work properly on flash target. eg: `cv.root.scrollRect = new Rectangle(0, 100, 480, 800);` It cause scrolling of 100 pixels, but it does not work properly on android target. – hamid toosi Jun 28 '14 at 05:59
0

This is how you can do in a full cocktail application. I never used the cocktailview, but maybe this can help. With this you can move the body with the mouse wheel.

First you need to set this css for the body:

body {
  overflow: scroll;
  height: 100%;
}

Then in your code:

Browser.document.body.onmousewheel = function(e)
{
    Browser.document.body.scrollTop += Std.int(e.deltaY * 10);
}

e.deltaY returns 1 or -1, so multiply by a value of your choice.