Skip to content

Commit

Permalink
This commit changes the handling of sticky-kit.js in financial-view.js
Browse files Browse the repository at this point in the history
so that event handlers are not attached multiple times.
  • Loading branch information
mistergone committed Aug 24, 2017
1 parent 9c1969b commit 905fb7c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/disclosures/js/views/financial-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,18 +806,22 @@ var financialView = {
stickySummariesListener: function() {
var $stickyOffers = $( '.offer-part_summary-wrapper' ),
$win = $(window);

// "detach" event handler before re-attaching
$stickyOffers.trigger( 'sticky_kit:detach' );

if ( $win.width() >= 600 ) {
// Attach event handler
$stickyOffers.stick_in_parent()
.on( 'sticky_kit:bottom', function( evt ) {
$( evt.target ).addClass( 'is_bottomed' );
} )
.on( 'sticky_kit:unbottom', function( evt ) {
$( evt.target ).removeClass( 'is_bottomed' );
} );
} else {
$stickyOffers.trigger( 'sticky_kit:detach' );
}

// On resize, check if event handler should be attached
$win.resize( function() {
financialView.stickySummariesListener();
} );
Expand Down

0 comments on commit 905fb7c

Please sign in to comment.