Skip to content

Commit

Permalink
fixed: Mouswheel over pinned element bug
Browse files Browse the repository at this point in the history
as documented in these issues:
#34
#50
#82
#139
#140
  • Loading branch information
janpaepke committed Aug 27, 2014
1 parent ec9edfa commit f6a3fd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
7 changes: 0 additions & 7 deletions css/examples.css
Original file line number Diff line number Diff line change
Expand Up @@ -758,13 +758,6 @@ a.viewsource:before {
margin-top: 20px;
}

.disablePointerEvents {
pointer-events: none;
}
.disablePointerEvents a {
pointer-events: auto;
}

/*
Codehighlighting
Expand Down
15 changes: 12 additions & 3 deletions dev/src/class.ScrollScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@
* @private
*/
var updateRelativePinSpacer = function () {
if ( _parent && _pin &&// well, duh
(_state === "DURING" || _state === "AFTER" && _options.duration === 0) &&// element in pinned state?
( // is width or height relatively sized, but not in relation to body? then we need to recalc.
if ( _parent && _pin &&// well, duh
(_state === "DURING" || _state === "AFTER" && _options.duration === 0) &&// element in pinned state?
( // is width or height relatively sized, but not in relation to body? then we need to recalc.
(_pinOptions.relSize.width && $(window).width() != _pinOptions.spacer.parent().width()) ||
(_pinOptions.relSize.height && $(window).height() != _pinOptions.spacer.parent().height())
)
Expand All @@ -483,6 +483,12 @@
}
};

var onMousewheelOverPin = function (e) {
if (_parent && _pin && (_state === "DURING" || _state === "AFTER" && _options.duration === 0)) { // in pin state
_parent.scrollTo(_parent.info("scrollPos") - (e.originalEvent.wheelDelta/3 || -e.originalEvent.detail*30));
}
};


/*
* ----------------------------------------------------------------
Expand Down Expand Up @@ -1140,6 +1146,8 @@

// add listener to document to update pin position in case controller is not the document.
$(window).on("scroll." + NAMESPACE + "_pin resize." + NAMESPACE + "_pin", updatePinInContainer);
// add mousewheel listener to catch scrolls over fixed elements
_pin.on("mousewheel DOMMouseScroll", onMousewheelOverPin);

log(3, "added pin");

Expand Down Expand Up @@ -1174,6 +1182,7 @@
}
}
$(window).off("scroll." + NAMESPACE + "_pin resize." + NAMESPACE + "_pin");
_pin.off("mousewheel DOMMouseScroll", onMousewheelOverPin);
_pin = undefined;
log(3, "removed pin (reset: " + (reset ? "true" : "false") + ")");
}
Expand Down

0 comments on commit f6a3fd7

Please sign in to comment.