Which DOM property for determining vertical size?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gregor Kofler

    Which DOM property for determining vertical size?

    I want to do my own vertical (or whatever direction) smooth expand of a
    block element. The simple approach so far: create and fill container
    element. Set element.style.h eight to 0px, overflow hidden, and use a
    timeout callback to increase element.style.h eight, until it matches
    element.scrollH eight. However, scrollHeight is MSDOM. Is there a W3C
    compliant alternative? Or a smarter approach altogether?

    Gregor


    --
    http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
    http://web.gregorkofler.com ::: meine JS-Spielwiese
    http://www.image2d.com ::: Bildagentur für den alpinen Raum
  • Martin Honnen

    #2
    Re: Which DOM property for determining vertical size?

    Gregor Kofler wrote:
    I want to do my own vertical (or whatever direction) smooth expand of a
    block element. The simple approach so far: create and fill container
    element. Set element.style.h eight to 0px, overflow hidden, and use a
    timeout callback to increase element.style.h eight, until it matches
    element.scrollH eight. However, scrollHeight is MSDOM. Is there a W3C
    compliant alternative?
    Somewhere in the future it might be an W3C standard:


    --

    Martin Honnen

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: Which DOM property for determining vertical size?

      Gregor Kofler wrote:
      I want to do my own vertical (or whatever direction) smooth expand of a
      block element. The simple approach so far: create and fill container
      element. Set element.style.h eight to 0px, overflow hidden, and use a
      timeout callback to increase element.style.h eight, until it matches
      element.scrollH eight. However, scrollHeight is MSDOM. [...]
      _MSHTML DOM_. Nevertheless, Gecko/20080404 also supports it in Standards
      Compliance Mode, and so do Opera/9.27 and Apple WebKit/525.13.

      But, since you would probably want an approach that degrades gracefully, you
      could store the `offsetHeight' property value before you resize the element,
      if supported. Not standards compliant either, but supposedly better supported.


      HTH

      PointedEars
      --
      realism: HTML 4.01 Strict
      evangelism: XHTML 1.0 Strict
      madness: XHTML 1.1 as application/xhtml+xml
      -- Bjoern Hoehrmann

      Comment

      • Gregor Kofler

        #4
        Re: Which DOM property for determining vertical size?

        Thomas 'PointedEars' Lahn meinte:
        Gregor Kofler wrote:
        >I want to do my own vertical (or whatever direction) smooth expand of a
        >block element. The simple approach so far: create and fill container
        >element. Set element.style.h eight to 0px, overflow hidden, and use a
        >timeout callback to increase element.style.h eight, until it matches
        >element.scroll Height. However, scrollHeight is MSDOM. [...]
        >
        _MSHTML DOM_.
        Hmmm... I somehow anticipated this remark. (On developer.mozil la.org
        they call it MSIE DHTML object model, MSDN calls it DHTML DOM.)
        Nevertheless, Gecko/20080404 also supports it in Standards
        Compliance Mode, and so do Opera/9.27 and Apple WebKit/525.13.
        But, since you would probably want an approach that degrades gracefully, you
        could store the `offsetHeight' property value before you resize the element,
        if supported. Not standards compliant either, but supposedly better supported.
        I would use offsetHeight, if the element is visible in the beginning.
        But since the element gets inserted as an "invisible" (display = "none")
        childnode, offsetHeight isn't available (unless I haven't overlooked
        something). Showing the element, reading offsetHeight, and turning it
        off again isn't an option either, because of the flicker. Hacks like
        offscreen-rendering, reading, relocation, etc. is something I try to
        avoid. Rather scrollHeight then.

        Gregor



        --
        http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
        http://web.gregorkofler.com ::: meine JS-Spielwiese
        http://www.image2d.com ::: Bildagentur für den alpinen Raum

        Comment

        Working...