Fix undefined local variables in sticky JS

Running the sticky JS in Jest raised errors due to
these variables not being assigned properly.

It's JavaScript so any variable not defined by the
`var` prefix will automatically become a property
of the global object. That is not what is intended
by the code so requires changing.
This commit is contained in:
Tom Byers
2019-05-10 13:58:21 +01:00
parent bb16626209
commit 19b68048d0

View File

@@ -11,12 +11,11 @@
var $scrollArea = $el.closest('.sticky-scroll-area');
$scrollArea = $scrollArea.length ? $scrollArea : $el.parent();
scrollArea = $scrollArea.get(0);
this._els = [el];
this.edge = edge;
this.selector = selector;
this.node = scrollArea;
this.node = $scrollArea.get(0);
this.setEvents();
};
ScrollArea.prototype.addEl = function (el) {
@@ -38,7 +37,7 @@
};
ScrollArea.prototype.getFocusedDetails = {
forElement: function ($focusedElement) {
focused = {
var focused = {
'top': $focusedElement.offset().top,
'height': $focusedElement.outerHeight(),
'type': 'element'