Skip to content

Option for setting the scroll container #224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions sticky-kit.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $.fn.stick_in_parent = (opts={}) ->
offset_top
spacer: manual_spacer
bottoming: enable_bottoming
container: container
} = opts

win_height = win.height()
Expand All @@ -27,6 +28,7 @@ $.fn.stick_in_parent = (opts={}) ->
sticky_class ?= "is_stuck"

enable_bottoming = true unless enable_bottoming?
win = container if manual_spacer?

# we need this because jquery's version (along with css()) rounds everything
outer_width = (el) ->
Expand Down Expand Up @@ -72,7 +74,7 @@ $.fn.stick_in_parent = (opts={}) ->
padding_top = parseInt parent.css("padding-top"), 10
padding_bottom = parseInt parent.css("padding-bottom"), 10

parent_top = parent.offset().top + border_top + padding_top
parent_top = parent.offset().top + border_top + padding_top + win.scrollTop()
parent_height = parent.height()

if fixed
Expand All @@ -92,7 +94,7 @@ $.fn.stick_in_parent = (opts={}) ->

restore = true

top = elm.offset().top - (parseInt(elm.css("margin-top"), 10) or 0) - offset_top
top = elm.offset().top - (parseInt(elm.css("margin-top"), 10) or 0) - offset_top + win.scrollTop()

height = elm.outerHeight true

Expand Down