Skip to content

Commit bdc4ecc

Browse files
Undo some of the previous change
Resetting the scroll positions for both expand and shrink is valuable in a single reset function. Without that, scroll positions were not getting reset properly at all times.
1 parent 921e954 commit bdc4ecc

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/ResizeSensor.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,12 @@
9090
var lastExpandWidth, lastExpandHeight;
9191

9292
var reset = function() {
93-
resetExpand();
94-
resetShrink();
95-
};
96-
97-
var resetExpand = function() {
9893
expandChild.style.width = expand.offsetWidth + 10 + 'px';
9994
expandChild.style.height = expand.offsetHeight + 10 + 'px';
10095
expand.scrollLeft = expand.scrollWidth;
10196
expand.scrollTop = expand.scrollHeight;
102-
lastExpandWidth = element.offsetWidth;
103-
lastExpandHeight = element.offsetHeight;
104-
};
105-
106-
var resetShrink = function() {
10797
shrink.scrollLeft = shrink.scrollWidth;
10898
shrink.scrollTop = shrink.scrollHeight;
109-
lastShrinkWidth = element.offsetWidth;
110-
lastShrinkHeight = element.offsetHeight;
11199
};
112100

113101
reset();
@@ -130,14 +118,18 @@
130118
if (element.offsetWidth > lastExpandWidth || element.offsetHeight > lastExpandHeight) {
131119
changed();
132120
}
133-
resetExpand();
121+
reset();
122+
lastExpandWidth = element.offsetWidth;
123+
lastExpandHeight = element.offsetHeight;
134124
});
135125

136126
addEvent(shrink, 'scroll',function() {
137127
if (element.offsetWidth < lastShrinkWidth || element.offsetHeight < lastShrinkHeight) {
138128
changed();
139129
}
140-
resetShrink();
130+
reset();
131+
lastShrinkWidth = element.offsetWidth;
132+
lastShrinkHeight = element.offsetHeight;
141133
});
142134
}
143135

0 commit comments

Comments
 (0)