Skip to content

Commit f6bdfa4

Browse files
authored
Merge pull request #594 from gselderslaghs/throttle-util-method-invocation-fixes
fix(Throttle util) refactor method invocations in components, fixes m…
2 parents 4b46164 + 3a66e61 commit f6bdfa4

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

src/carousel.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,8 @@ export class Carousel extends Component<CarouselOptions> {
240240
window.removeEventListener('resize', this._handleThrottledResize);
241241
}
242242

243-
_handleThrottledResize: () => void = Utils.throttle(
244-
function () {
245-
this._handleResize();
246-
},
243+
_handleThrottledResize = (): void => Utils.throttle(
244+
this._handleResize,
247245
200,
248246
null
249247
).bind(this);

src/scrollspy.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ export class ScrollSpy extends Component<ScrollSpyOptions> {
139139
}
140140
}
141141

142-
_handleThrottledResize: () => void = Utils.throttle(function () {
143-
this._handleWindowScroll();
144-
}, 200).bind(this);
142+
_handleThrottledResize = (): void => Utils.throttle(this._handleWindowScroll, 200).bind(this);
145143

146144
_handleTriggerClick = (e: MouseEvent) => {
147145
const trigger = e.target;

src/tapTarget.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ export class TapTarget extends Component<TapTargetOptions> implements Openable {
109109
window.removeEventListener('resize', this._handleThrottledResize);
110110
}
111111

112-
_handleThrottledResize: () => void = Utils.throttle(function () {
113-
this._handleResize();
114-
}, 200).bind(this);
112+
_handleThrottledResize = (): void => Utils.throttle(this._handleResize, 200).bind(this);
115113

116114
_handleKeyboardInteraction = (e: KeyboardEvent) => {
117115
if (Utils.keys.ENTER.includes(e.key)) {

0 commit comments

Comments
 (0)