Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. How should I measure scroll position in different browsers

How should I measure scroll position in different browsers

Scheduled Pinned Locked Moved Web Development
csharpdockertutorialquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    woomla
    wrote on last edited by
    #1

    I cannot exactly figure out how the scroll position is measured. I have a container with a specific height (400) and some elements (30) in it with specific heights (18). The container displays about 7.2 items in it. The maximum scroll position in firefox is 142. In chrome 141. If the container can display an exact number of items then the calculation is simple: number-of-items * item-height - container-height. But how is it calculated if the container displays 7.2 items? And worse, if the container has padding top and bottom? See this example[^] [edit] The reason why I want this is because I want some kind of ScrollBar. I have it kind of working, but there are differences in browsers. In firefox, this example works: http://jsfiddle.net/woomla/ma88D/7/[^] In chrome this example workds: http://jsfiddle.net/woomla/ma88D/8/[^] The difference is that in the chrome version I need to add padding-top and padding-bottom to the max scroller distance. In firefox I need to add only padding-top.

    Z 1 Reply Last reply
    0
    • W woomla

      I cannot exactly figure out how the scroll position is measured. I have a container with a specific height (400) and some elements (30) in it with specific heights (18). The container displays about 7.2 items in it. The maximum scroll position in firefox is 142. In chrome 141. If the container can display an exact number of items then the calculation is simple: number-of-items * item-height - container-height. But how is it calculated if the container displays 7.2 items? And worse, if the container has padding top and bottom? See this example[^] [edit] The reason why I want this is because I want some kind of ScrollBar. I have it kind of working, but there are differences in browsers. In firefox, this example works: http://jsfiddle.net/woomla/ma88D/7/[^] In chrome this example workds: http://jsfiddle.net/woomla/ma88D/8/[^] The difference is that in the chrome version I need to add padding-top and padding-bottom to the max scroller distance. In firefox I need to add only padding-top.

      Z Offline
      Z Offline
      Zaf Khan
      wrote on last edited by
      #2

      What about rounding your items count up from 7.2 to 8 ? And then calculating the height based on that?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups