vitch / jScrollPane

Pretty, customisable, cross browser replacement scrollbars

Home Page:http://jscrollpane.kelvinluck.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

maintainPosition fails to maintain position when content resizes

cognivator opened this issue · comments

Summary

If the content of the scrollable pane resizes, the content scrolls to the top even if maintainPosition is true.

Steps to reproduce

  1. Initialize jScrollPane (jsp) with maintainPosition: true. For the complete settings object, see System Under Test below.
  2. place a collapsible section in the jsp content area somewhere below the bottom of the jsp pane. In other words, make the content longer than the pane, so you must scroll down to get to the collapsible section.
  3. expand or collapse the section

EXPECTED: with maintainPosition: true, the content area should not scroll
ACTUAL: the content area scrolls to top

Symptoms

It appears maintainPosition relies on several conditions, one of which is verticalDragPosition. Under certain conditions -- essentially any time manual scrolling has come to a stop -- verticalDragPosition is NaN, which causes maintainPosition tests to fail, and jsp assumes it should scroll to the top of the content area during a reinitialize.

verticalDragPosition gets its value ultimately from calculations involving deltaY which is presumably returned from browser events, and which is NaN whenever scrolling ends.

Technical Direction

Trapping and recovering from the NaN condition keeps dragPositionY valid, and allows maintainPosition to function correctly. The desired fix should trap the NaN condition as close to the browser event as possible, without adversely affecting other tests and conditions that rely on the condition to know if scrolling has ended.

System Under Test

  • jScrollPane v2.0.17
  • jScrollPane (jsp) is in use in a Wordpress 4.0 theme
  • Collapse-O-Matic Wordpress plugin is in use within jScrollPane
  • Chrome 50+
  • OS X 10.10.5

Settings object:
{ autoReinitialise: true, mouseWheelSpeed: 6, maintainPosition: true }

Planning to resolve this in a fork. Will open a PR when ready.

Traced the source of the problem to the minified version of v3.1.12 of jquery-mousewheel.

Testing with an updated version (v. 3.1.13). If fixed, will close this ticket.

preparing two PRs:

  • one that updates jquery.mousewheel plugin to 3.1.13
  • one that moves the native source files to a dedicated /src folder, and uses the build process to generate /script and /style folders from /src and the jquery.mousewheel plugin from npm

Thanks - I'll look at the PRs